Connect manager connect fail when upgrade openfire 4.9.0

use cmmanager conenct to openfire 4.9.0. openfire log error:

2024.10.25 09:32:51.592 ^[[1;31mERROR^[[m [connection_manager-thread-2]: org.jivesoftware.openfire.nio.NettyConnectionHandler - Closing connection on /192.168.0.106:5262--/218.66.13.70:34785 due to error while processing message: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:connectionmanager" to="gr5tm/Connection Worker - 2" version="1.0">
java.lang.NullPointerException: null
        at org.dom4j.tree.AbstractElement.addNode(AbstractElement.java:1371) ~[dom4j-2.1.4.jar:?]
        at org.dom4j.tree.AbstractElement.add(AbstractElement.java:910) ~[dom4j-2.1.4.jar:?]
        at org.jivesoftware.openfire.net.StanzaHandler.tlsNegotiated(StanzaHandler.java:493) ~[xmppserver-4.9.0.jar:4.9.0]
        at org.jivesoftware.openfire.net.StanzaHandler.initiateSession(StanzaHandler.java:135) ~[xmppserver-4.9.0.jar:4.9.0]
        at org.jivesoftware.openfire.net.StanzaHandler.process(StanzaHandler.java:112) ~[xmppserver-4.9.0.jar:4.9.0]
        at org.jivesoftware.openfire.nio.NettyConnectionHandler.channelRead0(NettyConnectionHandler.java:142) [xmppserver-4.9.0.jar:4.9.0]
        at org.jivesoftware.openfire.nio.NettyConnectionHandler.channelRead0(NettyConnectionHandler.java:50) [xmppserver-4.9.0.jar:4.9.0]
        at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) [netty-transport-4.1.108.Final.jar:4.1.108.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) [netty-transport-4.1.108.Final.jar:4.1.108.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) [netty-transport-4.1.108.Final.jar:4.1.108.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) [netty-transport-4.1.108.Final.jar:4.1.108.Final]

because .connect manager session(LocalConnectionMultiplexerSession) have not SASLMechanisms in code:
org.jivesoftware.openfire.net.SASLAuthentication.getSASLMechanisms method

 public static Element getSASLMechanisms( LocalSession session )
    {
        if ( session instanceof ClientSession )
        {
            return getSASLMechanismsElement( (ClientSession) session );
        }
        else if ( session instanceof LocalIncomingServerSession )
        {
            return getSASLMechanismsElement( (LocalIncomingServerSession) session );
        }
        else
        {
            Log.debug( "Unable to determine SASL mechanisms that are applicable to session '{}'. Unrecognized session type.", session );
            return null;
        }
    }

use we change org.jivesoftware.openfire.net.StanzaHandler.java tlsNegotiated method when getSASLMechanisms() method return null. not add to features:

protected void tlsNegotiated(XmlPullParser xpp) throws XmlPullParserException, IOException {
        final Document document = getStreamHeader();

        // Offer stream features including SASL Mechanisms
        final Element features = DocumentHelper.createElement(QName.get("features", "stream", "http://etherx.jabber.org/streams"));
        document.getRootElement().add(features);

        // Include available SASL Mechanisms
        //when mechanismsElement is null not add to features. add by Condy 2024.10.25
        final Element mechanismsElement=SASLAuthentication.getSASLMechanisms(session);
        if(mechanismsElement!=null) {
        	features.add(mechanismsElement);
        }
        
        // Include specific features such as auth and register for client sessions
        final List<Element> specificFeatures = session.getAvailableStreamFeatures();
        if (specificFeatures != null) {
            for (final Element feature : specificFeatures) {
                features.add(feature);
            }
        }

        connection.deliverRawText(StringUtils.asUnclosedStream(document));
    }

i fix this bug. can merge my code to github master?
StanzaHandler.java (35.8 KB)

Please submit a pull request with your suggested changes!

Please be aware that the connection manager project has not seen any development in many, many years. I am not sure if it is safe to use anymore. That said, I’d welcome a pull request.

already submit pull request #2571

Thank you. This change will be part of the next release of Openfire.

Openfire 4.9.1, that contains the fix for this problem, has now been released! Please upgrade and let us know if that fixes your problem once and for all!