BlockHound#install(BlockHoundIntegration...)
or BlockHound#builder().
On installation, it will run the instrumentation and add the check to the blocking methods.
Note that the installation can (and should) only be done once, subsequent install calls will be ignored.
Hence, the best place to put the install call is before all tests
or in the beginning of your "public static void main" method.
If you have it automatically installed (e.g. via a testing framework integration), you can apply the customizations
by using the SPI mechanism (see BlockHoundIntegration).
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| public static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final AtomicBoolean | |
| pack-priv static final String |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static BlockHound. | Returns: a freshBlockHound.Creates a completely new |
| public static void | install(BlockHoundIntegration...
an array of integrations to automatically apply on the intermediate builder integrations)Loads integrations with |
| public static void | premain(String
Options for the agent. agentArgs, Instrumentation Instrumentation API. inst)Entrypoint for installation via the |
| INITIALIZED | back to summary |
|---|---|
| private static final AtomicBoolean INITIALIZED | |
| PREFIX | back to summary |
|---|---|
| pack-priv static final String PREFIX | |
| BlockHound | back to summary |
|---|---|
| private BlockHound() | |
| builder | back to summary |
|---|---|
| public static BlockHound. Creates a completely new
| |
| install | back to summary |
|---|---|
| public static void install(BlockHoundIntegration... integrations) Loads integrations with
| |
| premain | back to summary |
|---|---|
| public static void premain(String agentArgs, Instrumentation inst) Entrypoint for installation via the
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final AgentBuilder. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public TypePool | typePool(ClassFileLocator
The class file locator to use. classFileLocator, ClassLoader The class loader for which the class file locator
was created or classLoader, String null if the boot loader.The name of the currently instrumented type. name)Implements net. |
| public TypePool | typePool(ClassFileLocator
The class file locator to use. classFileLocator, ClassLoader The class loader for which the class file locator was
created or classLoader)null if the boot loader.Implements net. |
| INSTANCE | back to summary |
|---|---|
| public static final AgentBuilder. | |
| BlockHoundPoolStrategy | back to summary |
|---|---|
| private BlockHoundPoolStrategy() | |
| typePool | back to summary |
|---|---|
| public TypePool typePool(ClassFileLocator classFileLocator, ClassLoader classLoader, String name) Implements net. Doc from net. Creates a type pool for a given class file locator. If a cache is used, the type that is currently instrumented is not used.
| |
| typePool | back to summary |
|---|---|
| public TypePool typePool(ClassFileLocator classFileLocator, ClassLoader classLoader) Implements net. Doc from net. Creates a type pool for a given class file locator.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private final Map | |
| private Instrumentation | |
| private Predicate | |
| private Consumer | |
| private Predicate |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public BlockHound. | Returns: thisa predicate to append to the current instance of the predicate predicate)Appends the provided predicate to the current one. |
| public BlockHound. | Returns: thisclass' name (e.g. "java.lang.Thread") className, String a method name methodName)Allows blocking calls inside any method of a class with name identified by the provided className and which name matches the provided methodName. |
| public BlockHound. | Returns: thisa consumer of the detected blocking method call's description ( consumer)BlockingMethod).Overrides the callback that is being triggered when a blocking method is detected |
| public BlockHound. | Returns: thisclass' name (e.g. "java.lang.Thread") className, String a method name methodName)Disallows blocking calls inside any method of a class with name identified by the provided className and which name matches the provided methodName. |
| public BlockHound. | |
| public void | install()
Installs the agent and runs the instrumentation, but only if BlockHound wasn't installed yet (it is global). |
| private void | |
| public BlockHound. | Returns: thisan array of integrations to automatically apply on the builder using
integrations)with(BlockHoundIntegration)Loads integrations with |
| public BlockHound. | Returns: thisa class reference clazz, String a method name methodName, String a method descriptor in JVM's format signature)Marks provided method of the provided class as "blocking". |
| public BlockHound. | Returns: thisclass' name (e.g. "java.lang.Thread") className, String a method name methodName, String a method signature (in JVM's format) signature)Marks provided method of the class identified by the provided name as "blocking". |
| public BlockHound. | |
| private void | |
| public BlockHound. | Returns: thisan integration to apply integration)Applies the provided |
| public BlockHound. | Returns: thisThe instrumentation instance to use. instrumentation)Configure the |
| allowances | back to summary |
|---|---|
| private final Map<String, Map<String, Boolean>> allowances | |
| blockingMethods | back to summary |
|---|---|
| private final Map<String, Map<String, Set<String>>> blockingMethods | |
| configuredInstrumentation | back to summary |
|---|---|
| private Instrumentation configuredInstrumentation | |
| dynamicThreadPredicate | back to summary |
|---|---|
| private Predicate<Thread> dynamicThreadPredicate | |
| onBlockingMethod | back to summary |
|---|---|
| private Consumer<BlockingMethod> onBlockingMethod | |
| threadPredicate | back to summary |
|---|---|
| private Predicate<Thread> threadPredicate | |
| Builder | back to summary |
|---|---|
| pack-priv Builder() | |
| addDynamicThreadPredicate | back to summary |
|---|---|
| public BlockHound. Appends the provided predicate to the current one.
| |
| allowBlockingCallsInside | back to summary |
|---|---|
| public BlockHound. Allows blocking calls inside any method of a class with name identified by the provided className and which name matches the provided methodName.
There are two special cases for
| |
| blockingMethodCallback | back to summary |
|---|---|
| public BlockHound. Overrides the callback that is being triggered when a blocking method is detected
| |
| disallowBlockingCallsInside | back to summary |
|---|---|
| public BlockHound. Disallows blocking calls inside any method of a class with name identified by the provided className and which name matches the provided methodName.
There are two special cases for
| |
| dynamicThreadPredicate | back to summary |
|---|---|
| public BlockHound. Replaces the current dynamic thread predicate with the result of applying the provided function. Warning Consider always using | |
| install | back to summary |
|---|---|
| public void install() Installs the agent and runs the instrumentation, but only if BlockHound wasn't installed yet (it is global). | |
| instrument | back to summary |
|---|---|
| private void instrument(Instrumentation instrumentation) | |
| loadIntegrations | back to summary |
|---|---|
| public BlockHound. Loads integrations with
| |
| markAsBlocking | back to summary |
|---|---|
| public BlockHound. Marks provided method of the provided class as "blocking". The descriptor should be in JVM's format: https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/types.html#wp276
| |
| markAsBlocking | back to summary |
|---|---|
| public BlockHound. Marks provided method of the class identified by the provided name as "blocking". The descriptor should be in JVM's format: https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/types.html#wp276
| |
| nonBlockingThreadPredicate | back to summary |
|---|---|
| public BlockHound. Replaces the current non-blocking thread predicate with the result of applying the provided function. Warning Consider always using | |
| testInstrumentation | back to summary |
|---|---|
| private void testInstrumentation() | |
| with | back to summary |
|---|---|
| public BlockHound. Applies the provided
| |
| with | back to summary |
|---|---|
| public BlockHound. Configure the
| |