package io.opentracing.contrib.jaxrs2.internal;

import io.opentracing.Scope;
import io.opentracing.Span;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * Wrapper class used for exchanging span between filters.
 *
 * @author Pavol Loffay
 */
public class SpanWrapper {

    public static final String PROPERTY_NAME = SpanWrapper.class.getName() + ".activeSpanWrapper";

    private Scope scope;
    private Span span;
    private AtomicBoolean finished = new AtomicBoolean();

    public SpanWrapper(Span span, Scope scope) {
        this.span = span;
        this.scope = scope;

    }

    public Span get() {
        return span;
    }

    public Scope getScope() {
        return scope;
    }

    public synchronized void finish() {
        if (!finished.get()) {
            finished.set(true);
            span.finish();
        }
    }

    public boolean isFinished() {
        return finished.get();
    }
}

@@ -716,21 +716,8 @@
 lic 
-synchronized 
 void
@@ -744,9 +744,8 @@
 if (
-!
 fini
@@ -753,48 +753,37 @@
 hed.
-get()) %7B%0A            finished.set(
+compareAndSet(false, 
 true)
-;
+) %7B
 %0A   

Remove unneeded synchronized on SpanWrapper.finish (#149)