-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BlockHound integration and make sure tests don't use blocking calls
- Loading branch information
Stephane Maldini
committed
May 14, 2019
1 parent
1e08b10
commit a984c19
Showing
7 changed files
with
78 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/reactor/netty/resources/NettyBlockHoundIntegration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package reactor.netty.resources; | ||
|
||
import io.netty.channel.ChannelInitializer; | ||
import io.netty.util.concurrent.AbstractEventExecutor; | ||
import reactor.blockhound.BlockHound; | ||
import reactor.blockhound.integration.BlockHoundIntegration; | ||
import reactor.core.scheduler.NonBlocking; | ||
|
||
/** | ||
* An internal service for automatic integration with {@link BlockHound#install(BlockHoundIntegration...)} | ||
* | ||
* @author Stephane Maldini | ||
*/ | ||
public class NettyBlockHoundIntegration implements BlockHoundIntegration { | ||
@Override | ||
public void applyTo(BlockHound.Builder builder) { | ||
builder.nonBlockingThreadPredicate(current -> current.or(NonBlocking.class::isInstance)); | ||
|
||
//allow set initialization that might use Yield | ||
builder.allowBlockingCallsInside(ChannelInitializer.class.getName(), "initChannel"); | ||
|
||
//prevent blocking call in any netty event executor | ||
builder.disallowBlockingCallsInside(AbstractEventExecutor.class.getName(), "safeExecute"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters