-
Notifications
You must be signed in to change notification settings - Fork 98
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
Provide API or document how to allow/disallow blocking inside constructors #174
Comments
This one is interesting. I naively tried to use
After toying a little with the @Advice.OnMethodExit(onThrowable = Throwable.class) @bsideup any insight to share? As far as I understand this is so a throwing method is caught, but do we really need that? Isn't the allowance working by marking the thread as blocking-friendly, so the exception is never actually raised? Note that we could have a slightly different Advice for constructors, if needed. @rstoyanchev the static initializer works already, so we could indeed either document the |
The challenge is that with a pair of methods to allow/disallow, it would take 6 similarly named methods Maybe |
for the constructor, we have to defer a bit because it is not even sure allowBlockingCallsInside can work with constructors due to the aforementioned ByteBuddy limitation... let me split this issue in two. this one will be dedicated to the constructor part, and I'll open an issue dedicated to improving discoverability of the static initializer part. |
I can assure you that nothing in BlockHound is done without a reason. |
@bsideup I think it would be good to know. Are constructors supported? It seems the answer is no, but maybe you can clarify. If they are not, do you see a way for that to be supported, i.e. should we create a separate issue? |
@rstoyanchev let's create an issue for the constructors support. Java does not support |
note that this is intended as the issue for constructor support. |
I think documenting the current status quo is a sufficient for this issue, for me at least. Having a different issue for constructor support allows for that to be addressed separately, especially since it is more involved. The documentation could even reference such a separate issue. |
More informations related to this issue: |
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.The text was updated successfully, but these errors were encountered: