/*
 * Copyright 2018 NAVER Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.navercorp.pinpoint.profiler.context;

/**
 * @author Woonduk Kang(emeroad)
 */
public class SpanEventFactory implements CallStack.Factory<SpanEvent> {
    private static final SpanEvent DUMMY = new SpanEvent();

    @Override
    public Class<SpanEvent> getType() {
        return SpanEvent.class;
    }

    @Override
    public SpanEvent newInstance() {
        return new SpanEvent();
    }

    @Override
    public SpanEvent dummyInstance() {
        return DUMMY;
    }

    @Override
    public boolean isDummy(SpanEvent element) {
        return DUMMY == element;
    }

    @Override
    public void markDepth(SpanEvent element, int index) {
        element.setDepth(index);
    }

    @Override
    public void setSequence(SpanEvent element, short sequence) {
        element.setSequence(sequence);
    }

    @Override
    public String toString() {
        return "SpanEventFactory{}";
    }
}

@@ -752,69 +752,8 @@
 %3E %7B%0A
-    private static final SpanEvent DUMMY = new SpanEvent();%0A%0A
     
@@ -992,28 +992,90 @@
         
-return DUMMY
+final SpanEvent spanEvent = new DummySpanEvent();%0A        return spanEvent
 ;%0A    %7D%0A
@@ -1149,31 +1149,104 @@
     
-return DUMMY == element
+if (element instanceof DummySpanEvent) %7B%0A            return true;%0A        %7D%0A        return false
 ;%0A  
@@ -1575,10 +1575,176 @@
 ;%0A    %7D%0A
-%7D
 %0A
+    private static class DummySpanEvent extends SpanEvent %7B%0A        @Override%0A        public String toString() %7B%0A            return %22DummySpanEvent%22;%0A        %7D%0A    %7D%0A%7D

Fix CallStackFactory dummy