ServerCommandTest: Occasional failures
One of the tests seems to fail occasionally:
Error: Errors:
Error: ServerCommandTest>CommandTest.after:65->CommandTest.cleanUp:57 » BaseX User 'Sandbox2' is logged in.
The failure occurs in ServerCommandTest.kill. An actual occurrence of it looks like this:
Error: Tests run: 44, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.293 s <<< FAILURE! -- in org.basex.core.ServerCommandTest
Error: org.basex.core.ServerCommandTest.kill -- Time elapsed: 0.009 s <<< ERROR!
org.basex.core.BaseXException:
User 'Sandbox2' is logged in.
at org.basex.api.client.ClientSession.receive(ClientSession.java:190)
at org.basex.api.client.ClientSession.execute(ClientSession.java:160)
at org.basex.api.client.ClientSession.execute(ClientSession.java:165)
at org.basex.api.client.Session.execute(Session.java:36)
at org.basex.core.CommandTest.cleanUp(CommandTest.java:57)
at org.basex.core.CommandTest.after(CommandTest.java:65)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
The failure is detected when the @AfterEach method after() invokes cleanUp() after ServerCommandTest.kill has completed, as follows: cleanUp calls session.execute(new DropUser("Sandbox2")), and DropUser.run(String, String) finds an unexpected ClientListener for user Sandbox2 in context.getSessions().
The ClientListener would have been removed from Context.sessions by ClientListener.close(), which has multiple chances to get invoked:
- usually from
Kill.run(String, String):60called forServerCommandTest.kill():58 - additionally in several places in
ClientListener.run(), which is called byClientSession.close()on behalf of the try-with-resource inServerCommandTest.kill():57
I have no explanation yet how all of those can be bypassed silently, such that the ClientListener remains in Context.sessions.
Discarded; difficult to reproduce.