Skip to content

Commit

Permalink
[#9595] Fix missing close of DisableTrace
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Feb 10, 2023
1 parent d4cc508 commit d3440f6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public AsyncDisableTrace(LocalTraceRoot traceRoot,
public void close() {
if (asyncState.await()) {
// flush.
super.flush();
if (isDebug) {
logger.debug("Await trace={}, asyncState={}", this, this.asyncState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ private SpanEvent traceBlockBegin0(final int stackId) {

private void stackDump(String caused) {
PinpointException exception = new PinpointException(caused);
logger.warn("[DefaultTrace] Corrupted call stack found TraceRoot:{}, CallStack:{}", getTraceRoot(), callStack, exception);
if (logger.isWarnEnabled()) {
logger.warn("[{}] Corrupted call stack found TraceRoot:{}, CallStack:{}", getClass().getSimpleName(), getTraceRoot(), callStack, exception);
}
}

@Override
Expand Down Expand Up @@ -199,7 +201,7 @@ public void close() {
}


void flush() {
protected void flush() {
this.storage.flush();
this.closed = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ public void close() {
this.closeListener.close(purgeTime);
}

protected void flush() {
this.closed = true;
}

private boolean getStatus() {
return getShared().getErrorCode() == 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,17 @@ private boolean await0() {

@InterfaceAudience.LimitedPrivate("LocalTraceContext")
public interface AsyncStateListener {
AsyncStateListener EMPTY = () -> {
};
AsyncStateListener EMPTY = new DisableAsyncStateListener();

void finish();
}

static class DisableAsyncStateListener implements AsyncStateListener {
@Override
public void finish() {
}
}

@Override
public String toString() {
return "ListenableAsyncState{" +
Expand Down

0 comments on commit d3440f6

Please # to comment.