Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#8663] Fix to generate DummySpanEvent on stack overflow of callstack #8664

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public interface CallStack<T> {

int getMaxSequence();

T newInstance();

Factory<T> getFactory();

interface Factory<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ private boolean isSequenceOverflow() {
return maxSequence != -1 && maxSequence <= sequence;
}

@Override
public T newInstance() {
if (isOverflow()) {
return factory.dummyInstance();
} else {
return factory.newInstance();
}
}

@Override
public Factory<T> getFactory() {
return factory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public SpanEventRecorder currentSpanEventRecorder() {
}

private SpanEvent newSpanEvent(int stackId) {
final SpanEvent spanEvent = callStack.getFactory().newInstance();
final SpanEvent spanEvent = callStack.newInstance();
spanEvent.markStartTime();
spanEvent.setStackId(stackId);
return spanEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,17 @@ public void testPop_Fail() {
callStack.pop();
assertNull(callStack.pop());
}


@Test
public void newInstance() {
CallStack<SpanEvent> callStack = newCallStack(0);
SpanEvent spanEvent1 = callStack.newInstance();
callStack.push(spanEvent1);

SpanEvent spanEvent2 = callStack.newInstance();
Assert.assertTrue(callStack.getFactory().isDummy(spanEvent2));
}

@Test
public void overflow() {
final int maxDepth = 3;
Expand Down
65 changes: 0 additions & 65 deletions web/src/main/java/com/navercorp/pinpoint/web/util/Stack.java

This file was deleted.