[UNDERTOW-2403] Fix race condition in read from buffer at ServletInpu…#1602
[UNDERTOW-2403] Fix race condition in read from buffer at ServletInpu…#1602fl4via wants to merge 1 commit intoundertow-io:mainfrom
Conversation
|
|
||
| private void closePoolIfNotNull() { | ||
| try { | ||
| if (pooled != null) { |
There was a problem hiding this comment.
ONly thing Id consider is to have local var? unless thats calculated choice to sometimes pay price of exception, rather than constant cost of local var and assignment.
There was a problem hiding this comment.
We will pay the price of the NPE anyway, but, yes, I think adding the local var is a good idea because it will make the exception less likely.
if (pooled != null) {
final PooledByteBuffer pooled = this.pooled; // we can still read a null value here, hence, NPE when closing
this.pooled = null;
pooled.close(); // marginal risk of NPE here
}
There was a problem hiding this comment.
As a secod thought, will it make it less likely, if the time spent seting it to a variable might be the same time it takes to invoke close directly? Or is it not? I'll try to see if I can find some information on this. But the code I suggested above might have the same statistical risk of getting the NPE as the one we have without the local variable.
|
Im going to trigger CI once more. Most likely this either needs to disable on mac or expect failure. Most likely we should have some sort of OS specific annotations or utility to make this kind of exclusion easier. |
|
@fl4via @baranowb refering to the ticket and discusion on the thread, seems like this could happen in all recent versions of undertow, but we started seeing the similar exception only after updating from undertow 2.3.18.Final to 2.3.20.Final as part of spring boot 3.5, was there a change in either of 2.3.19 , 2.3.20 which is causing the NPE ? and how does this impact the request processing ? |
|
@AkashB23 not that I recall. |
|
This relates to UNDERTOW-2298 #1509 |
…tStreamImpl: prevent a NPE from being thrown to invoker in case input stream is closed by another thread (which can happen typically in timeouts) Signed-off-by: Flavia Rainone <frainone@redhat.com>
…tStreamImpl: prevent a NPE from being thrown to invoker in case input stream is closed by another thread (which can happen typically in timeouts)
Jira: https://issues.redhat.com/browse/UNDERTOW-2403