Provide API/documentation on how to allow/disallow blocking calls inside static initializer
simonbasle opened this issue · 1 comments
See also #174, where a similar API/documentation should be provided for constructors.
Quoting from the above:
There is no guidance I could find on how to allow/disallow blocking in a constructor or static initializer. There is one test that shows how to do it for a static initializer but it would be nicer if it was easier to find. One option could be a dedicated method, e.g.
allowBlockingCallsInsideConstructor(String classname)
, or otherwise provide guidance in the Javadoc onallowBlockingCallsInside
and a mention on the Customizations page.
@rstoyanchev you suggested that additional methods would maybe increase the API too much, and suggested enums or varargs. How about a couple constants? Something like:
//in Blockhound.Builder class, or directly at root Blockhound.java
public static final String STATIC_INITIALIZER = "<clinit>";
//in user code
BlockHound.install(b -> b.allowBlockingCallsInside(ClassWithStaticInit.class.getName(), BlockHound.Builder.STATIC_INITIALIZER));
going with the minimum viable solution of directly documenting <clinit>
in the methods javadocs