Openfire not closing stream gracefully (</stream:stream>)

In NIOConnection the close() method first sets the state to State.CLOSED and then delivers the closing stream element:

@Override
public void close() {

if (state.compareAndSet(State.OPEN, State.CLOSED)) {

//,

deliverRawText( flashClient ? “</flash:stream>” : “</stream:stream>” );

However, the deliverRawText method check for !isClosed() which is false by then, because it’s aleady closed:

@Override
public void deliverRawText(String text) {

if (!isClosed()) {

As consequence the closing stream element is never sent.

Thoughts?

Thought: “that’s not good.” PR please?

I recall lots of pain when the last time we attempted fixes in this area

[OF-881] NIOConnection Thread Deadlock when two clients in each others roster simultaneously disconnect - IgniteRealtime…

seems like MINA issues were at play as well, but we dare never attempt to upgrade it again!

Is the check for !isClosed() useful at all?

The easy fix would be to remove that line.

Other options: Introduce State.CLOSING

Or introduce some kind of a “forceDelivery” flag.

Created OF-1308