Adds bytesRead() method to RequestContext#2776
Adds bytesRead() method to RequestContext#2776daanjanschouten wants to merge 4 commits intodevelopfrom
bytesRead() method to RequestContext#2776Conversation
Generate changelog in
|
✅ Successfully generated changelog entry!Need to regenerate?Simply interact with the changelog bot comment again to regenerate these entries. 📋Changelog Preview✨ Features
|
| justification: "Add bytesRead() method to RequestContext. RequestContext is\ | ||
| \ only implemented by conjure-java-undertow-runtime per its documented contract." |
There was a problem hiding this comment.
That's not actually true and if you search for implementations, you'll see that there are a few other places that implement it https://pl.ntr/2Aq. They seem to be fake/empty contexts, but these appear in prod code https://pl.ntr/2As.
I don't remember off the top of my head the exact impact on the binary compatibility of adding an unused method to an interface, but I could see this break class validation when loading a class that implements an interface but not all the methods
There was a problem hiding this comment.
Good find, thank you. The RequestContext interface does specify that it should only be implemented within conjure-java-undertow-runtime, so unfortunate in that regard.
I've modified the interface method to instead provide a default, to ensure existing implementations don't break. The only remaining risk now is that some implementation was additionally implementing another interface that has the same default method, but that seems extremely unlikely, and would be caught at compile time. None of the existing implementations from your link suffer from this.
There was a problem hiding this comment.
Note that being caught at compilation does not mean we can't hit this at runtime in prod, since ABI break issues typically happen due to diamond transitive dependencies. I agree with you that this doesn't seem like it would happen here though
|
Closing this PR out for now after today's discussion, may revive at a later point in time. |
This change exposes
bytesRead()onRequestContextfor use in application code. The implementation tracks bytes at the I/O layer via an Undertow conduit wrapper, providing accurate measurements with minimal overhead.The byte count is stored using the existing attachment mechanism, in line with how the existing
UNVERIFIED_JWTandFAILUREattachments are used. For requests with empty bodies, Undertow may not create an input conduit, in which casebytesRead()returns 0.This change is a better version of #2771 because it exposes significantly less API surface area.
After this PR
==COMMIT_MSG==
Adds
bytesRead()method toRequestContext==COMMIT_MSG==