[#1143] Do not report a Notice of Disconnection that cannot reach an already-closed client as an unhandled error - #1146
Merged
vharseko merged 1 commit intoOct 1, 2026
Conversation
…hat cannot reach an already-closed client as an unhandled error ClientConnectionImpl.disconnect(ResultCode, String) subscribed to the notification with no error consumer. When the client had closed its end first, the failed write went to RxJavaPlugins.onError: the server printed an OnErrorNotImplementedException stack trace, and on a worker thread logged ERR_UNCAUGHT_THREAD_EXCEPTION and raised an uncaught-exception alert. Subscribe with an error consumer that only traces the failure. The connection is still closed on both outcomes by doAfterTerminate. Remove the try/catch (OnErrorNotImplementedException) around s.onError() in sendUnsolicitedNotification(): RxJavaPlugins.onError does not throw, so the catch could never see the exception. Fixes OpenIdentityPlatform#1143
maximthomas
approved these changes
Oct 1, 2026
maximthomas
left a comment
Contributor
There was a problem hiding this comment.
praise: The fix is on the subscribe that lost the error, and the test proves it.
LDAPServerFilter.ClientConnectionImpl.disconnect(ResultCode, String)now subscribes with an error consumer that only traces the failure (opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPServerFilter.java:545-557).doAfterTerminate(connection.closeSilently())still closes the connection whether or not the notice was written.testDisconnectWithNotificationToClosedClientIsNotReportedAsUnhandledErrorfails with the baseLDAPServerFilter(OnErrorNotImplementedException ... | java.io.EOFException) and passes at the head (ConnectionFactoryTestCase78/78). It restores the previousRxJavaPluginserror handler infinally.- Under RxJava 3 the removed
try/catch (OnErrorNotImplementedException)arounds.onErrorcould never catch anything, as the description explains.disconnectis the only production subscriber ofsendUnsolicitedNotification, and it now handles the error, so removing the catch is safe
maximthomas
approved these changes
Oct 1, 2026
maximthomas
left a comment
Contributor
There was a problem hiding this comment.
praise: The fix is on the subscribe that lost the error, and the test proves it.
LDAPServerFilter.ClientConnectionImpl.disconnect(ResultCode, String)now subscribes with an error consumer that only traces the failure (opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPServerFilter.java:545-557).doAfterTerminate(connection.closeSilently())still closes the connection whether or not the notice was written.testDisconnectWithNotificationToClosedClientIsNotReportedAsUnhandledErrorfails with the baseLDAPServerFilter(OnErrorNotImplementedException ... | java.io.EOFException) and passes at the head (ConnectionFactoryTestCase78/78). It restores the previousRxJavaPluginserror handler infinally.- Under RxJava 3 the removed
try/catch (OnErrorNotImplementedException)arounds.onErrorcould never catch anything, as the description explains.disconnectis the only production subscriber ofsendUnsolicitedNotification, and it now handles the error, so removing the catch is safe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The server can drop a connection with a Notice of Disconnection after the client has already closed its end. For example,
AuthenticatedUsers.doPostResponsedoes this after a DELETE of the bound user. The notice then cannot be written, and the failure is reported as an uncaught RxJava error. The server prints anOnErrorNotImplementedException ... | java.io.EOFExceptionstack trace. According to the code, on a worker thread it also logsERR_UNCAUGHT_THREAD_EXCEPTIONand raises anALERT_TYPE_UNCAUGHT_EXCEPTIONalert. This produces 7 to 11 traces per run in thebuild-docker-alpinebenchmark log. See #1143.Cause
LDAPServerFilter.ClientConnectionImpl.disconnect(ResultCode, String)subscribed to the notification with a bare.subscribe(). In RxJava 3.1.10,EmptyCompletableObserver.onErrordoes not throw. It hands the error toRxJavaPlugins.onError, which prints it and passes it to the thread's uncaught-exception handler. So thetry/catch (OnErrorNotImplementedException)arounds.onError()insendUnsolicitedNotification()(added in #555) never saw anything.Change
disconnect(ResultCode, String)subscribes with an error consumer that only traces the failure: a client that is already gone is an expected outcome.doAfterTerminate(connection.closeSilently())is unchanged, so the connection is closed whether or not the notice was written.try/catchand its import are removed.Test
ConnectionFactoryTestCase.testDisconnectWithNotificationToClosedClientIsNotReportedAsUnhandledErrorcloses the client and waits until the server context reportsisClosed(). It then callsdisconnect(BUSY, "busy")with a capturingRxJavaPluginserror handler installed, and asserts that nothing reached it. The write fails beforedisconnect()returns, so the assertion needs no wait.LDAPServerFilterfrom master): fails withexpecting empty, but was:<[OnErrorNotImplementedException ... | java.io.EOFException]>.opendj-grizzlysuite (1040 tests) is green.Fixes #1143