Skip to content

Commit

Permalink
Return "is blocking" by default if no frames are matched (#32)
Browse files Browse the repository at this point in the history
By returning `true` by default, we say "if there are no known frames, we should still consider it a blocking call".
The current implementation misses some blocking calls if the thread is marked but the stacktrace does not contain any blacklisted method (the native agent was returning `JNI_FALSE`)
  • Loading branch information
bsideup authored May 29, 2019
1 parent 533869e commit af6e0c9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void applyTo(BlockHound.Builder builder) {

// `ScheduledThreadPoolExecutor$DelayedWorkQueue.offer` parks the Thread with Unsafe#park.
builder.allowBlockingCallsInside(ScheduledThreadPoolExecutor.class.getName(), "scheduleAtFixedRate");
builder.allowBlockingCallsInside(ScheduledThreadPoolExecutor.class.getName() + "$DelayedWorkQueue", "take");

builder.nonBlockingThreadPredicate(current -> current.or(NonBlocking.class::isInstance));

Expand Down
5 changes: 4 additions & 1 deletion example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ test {
configurations {
reactor_3_3_x {
extendsFrom(testCompile, testRuntime)
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
}

Expand All @@ -43,5 +44,7 @@ dependencies {
testCompile 'junit:junit:4.12'
testCompile 'org.assertj:assertj-core:3.11.1'

reactor_3_3_x 'io.projectreactor:reactor-core:3.3.0.BUILD-SNAPSHOT'
reactor_3_3_x 'io.projectreactor:reactor-core:3.3.0.BUILD-SNAPSHOT', {
changing = true
}
}
2 changes: 1 addition & 1 deletion native-agent/src/main/cpp/agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,5 @@ extern "C" JNIEXPORT jboolean JNICALL Java_reactor_blockhound_BlockHoundRuntime_
start_depth += page_size;
} while (frames_count == page_size);

return JNI_FALSE;
return JNI_TRUE;
}

0 comments on commit af6e0c9

Please sign in to comment.