-
Notifications
You must be signed in to change notification settings - Fork 25k
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
HttpServer#createContext() catches Error #68967
Comments
Pinging @elastic/es-delivery (Team:Delivery) |
One option is to simply define a class in our test framework that simply extends |
I just love how you used the word "simply" twice in that first sentence 😁 Yeah that's an option that I tried, but it's not simple, there are a bunch of forbidden dependent classes we'd also need to wrap: |
Yeah, this is annoying. There doesn't seem to be anyway to do precision overrides like this. Our usage of the
Well, there's loads of "public" and "documented" APIs that are not part of the Java SE API to include One option we potentially have here is to remove the usage of |
Can we use different signature bundles in test code vs prod? I think it's right to avoid this stuff in production, but IMO we can be more liberal with tests since we control the environment and breakage only affects us internally. I've no idea whether this bundle covers anything sufficiently dangerous that we'd want to avoid it in tests too. |
We can. Right now we configured them identically but we could relax the constraints on test code. I'm not aware of all the potential side-effects of this. There's likely historical precedent for adding these checks to begin with. |
Ok that sounds like a good direction to me then, thanks. I'm not sure who owns the question of whether it's acceptable to relax these checks, my best guess would be @elastic/es-core-infra so I'll mark this for their discussion. SummaryWe use I would like to relax the forbidden API signature bundle from I have tried to determine the precise impact of this proposal without much success: |
It would be a build change so I think delivery would still own making the actual change. I do think whether or now we should make the change though would be a larger discussion. |
acked, yes, reworded slightly:
|
We already have separate signature files for test vs server (as well as "all" that applies to both). It would be trivial to move the bundled signatures to this condition. However, I want to first understand a little more what it is we are talking about:
Do you mean in memory fixtures for unit tests, or the test fixtures we build in gradle to be used with integration tests? If the latter, we shouldn't need to run forbidden apis on the fixture at all (and I thought we didn't). If the former, jdk.httpserver seems like the better choice long term, but in the meantime having a centralized utility for this seems useful. We already use MockSocket for building these in the rest client tests. |
We use these APIs both in standalone fixtures (e.g.
I am not clear what |
The confusion was on my end, I misunderstood a comment above and referring to jdk.httpserver thinking it was a future official Java API, but now realize it is just the module that contains the existing HttpServer. Going back to the original issue, as long as we keep |
Today we use
com.sun.net.httpserver.HttpServer
for writing test fixtures that emulate various third-party HTTP services. Unfortunately the handlers are executed in a context that catches and swallowsThrowable
, so that server-side assertions do not directly cause tests to fail.I would like to forbid the bare use of
HttpServer#createContext
and instead provide a utility method that does the same thing except that it adds a wrapper which usesExceptionsHelper.maybeDieOnAnotherThread
to fail tests on anError
. The trouble is that the wholecom.sun.net.httpserver.*
is already forbidden by forbidden-APIs (reportingnon-portable or internal runtime class
) so we@SuppressForbidden
liberally in these fixtures and I cannot see any obvious way to indicate thatHttpServer#createContext
is really forbidden, unlike the rest of this stuff that's ok in these contexts.Can we make Forbidden-APIs less sensitive to the use of these internal classes in a test context so that we can drop most of the
@SuppressForbidden
annotations? Any other ideas?Relates #68957
The text was updated successfully, but these errors were encountered: