Skip to content

Removed duplicit completion#6098

Merged
dmatej merged 6 commits into
eclipse-ee4j:3.1from
dmatej:6044-duplicit-completition
Jul 19, 2026
Merged

Removed duplicit completion#6098
dmatej merged 6 commits into
eclipse-ee4j:3.1from
dmatej:6044-duplicit-completition

Conversation

@dmatej

@dmatej dmatej commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Inspired and based on #6086 I am creating this PR. The main difference is that I removed the listener completely, and replaced the original unit test which used proxies with another using Mockito.

With @guerrillalg we still coordinate in a hunt of HTTP codes 500 and 200 - I cannot reproduce them neither with the original code nor with his nor mine PR.

Quick test

export JAVA_HOME=/usr/lib/jvm/jdk25; export MAVEN_SKIP_RC=true; mvn -V clean install -DskipTests -Dcyclonedx.skip=true && mvn clean install -pl :jersey-container-servlet,:jersey-6044

Tested with JDK17, 11 skips as Jetty 12 requires 17+.

Note

The author of the JettyHttpContainerDuringShutdownTest is @guerrillalg , I just contributed a bit. For the purpose of comparison of both PRs I checked out and committed the test here too.

dmatej added 4 commits July 1, 2026 21:13
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
- Is be visible in test logs

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
…cessing

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
@dmatej dmatej added this to the 3.1.13 milestone Jul 1, 2026
@dmatej
dmatej force-pushed the 6044-duplicit-completition branch from e64f6ec to 0e9c854 Compare July 8, 2026 20:04
@dmatej
dmatej marked this pull request as ready for review July 8, 2026 20:05
- The original test was created by guerrillakg, and was squashed and further
  updated by David Matejcek.
- Both users signed ECA.

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
@dmatej
dmatej force-pushed the 6044-duplicit-completition branch from 0e9c854 to 1a77c3f Compare July 9, 2026 17:05
@dmatej
dmatej requested a review from a team July 9, 2026 22:22

@mkarg mkarg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual change looks good at me; didn't have time to check the modified tests.

It would be beneficial to have a brief description what actual problem this change fixes.

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
@Override
public void complete() {
if (isCompleted()) {
LOGGER.log(Level.WARNING, "The processing was already completed!",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to have a WARNING here (which possibly is forwarded to the end user running Jersey)? IMHO if this message is logged, it proofs a bug in Jersey itself, so it might be better to have it on debug level?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything has consequences. If it would be already in the completed state, server would send the message to the client once more, the second time, when the client doesn't expect it. That was happening, causing weird errors.

However it was not well reproducible and it seems to me there's yet something - but maybe not, because on any hardware I used for testing this PR, I wasn't able to break relevant tests.

I really hate swallowing errors, because then we have just reports in issues, but no clue what really happened, no warning, and we burn lot of time by investigation and reproducing the problem. Same applies to users, it is hard to report something when incorrect situations are silently dropped.

So whatever breaks after this, we know at least something. And if this change is correct, there will be no warnings.

The now deleted listener (and the unit test for it) was added in 431b933 with this commit message:

Prevent NPE in the servlet container by writing the entity when the servlet container is shutdown

However now there are no NPE any more, it was probably fixed too somehow later.

I might be wrong too, but then it is easier to fix it from this state of code base than from the previous one.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not support this policy. Either we assume our code is correct, then the right way to deal with the situation is throwing an AssertionException. Or we assume our code is incorrent, the we should fix it. In case we assume the situation may happen, throwing a RuntimeException (or even a checked exception in case of specified behavior) would be correct. But in no case I support logging a warning given to end users, as it is not his fault. BTW, reducing to debug does not swallow anything. The administrator can enable logging these events, if he likes to.

What happens with such "useless" log entries is shown in the discussion between Lenny and Ondro: It produces complaints from customers, it produces arguments between committers, it does neither prevent a problematic situation nor solve one.

Having said that, kindly asking to not merge PRs as long a discussions are ongoing, in particular in production branches. This is considered unfriendly, as you are ignoring other committer's concerns without any need. Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First you approved this PR, this your comment came too late.

While you complain about hypothetical warning which doesn't break features (while exception could and no log at all would cause that we all forget about this for another 5 years until first user complains again), we have much more serious issues and nobody cares about them - 4.x fails randomly in tests, deployment needs to be rewritten, there are branches with no usage, ...

Btw the warning can be easily suppressed as a temporary workaround (if it would happen). With JUL:

org.glassfish.jersey.servlet.async.AsyncContextDelegateProviderImpl.level=OFF

Throwing exceptions have consequences - something would react somehow, throwing exceptions in a completion phase is quite risky.

@dmatej
dmatej merged commit 4125f30 into eclipse-ee4j:3.1 Jul 19, 2026
7 checks passed
@dmatej
dmatej deleted the 6044-duplicit-completition branch July 19, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Jersey 3.1.11 CompletedAsyncContextListener causes Unexpected 200 response during Jetty server Shutdown

3 participants