Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFLY-6288] Guard against IllegalStateException during transfer #8737

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -54,6 +54,7 @@
import org.jboss.msc.value.InjectedValue;
import org.wildfly.extension.messaging.activemq.logging.MessagingLogger;
import org.xnio.ChannelListener;
import org.xnio.IoUtils;
import org.xnio.StreamConnection;
import org.xnio.netty.transport.WrappingXnioSocketChannel;

Expand Down Expand Up @@ -147,12 +148,20 @@ private static ChannelListener<StreamConnection> switchToMessagingProtocol(final
@Override
public void handleEvent(final StreamConnection connection) {
MessagingLogger.ROOT_LOGGER.debugf("Switching to %s protocol for %s http-acceptor", protocolName, acceptorName);
SocketChannel channel = new WrappingXnioSocketChannel(connection);
RemotingService remotingService = activemqServer.getRemotingService();

NettyAcceptor acceptor = (NettyAcceptor)remotingService.getAcceptor(acceptorName);
acceptor.transfer(channel);
connection.getSourceChannel().resumeReads();
if (!remotingService.isStarted()) {
// ActiveMQ no longer accepts connection
IoUtils.safeClose(connection);
return;
}
NettyAcceptor acceptor = (NettyAcceptor) remotingService.getAcceptor(acceptorName);
SocketChannel channel = new WrappingXnioSocketChannel(connection);
try {
acceptor.transfer(channel);
connection.getSourceChannel().resumeReads();
} catch (IllegalStateException e) {
IoUtils.safeClose(connection);
}
}
};
}
Expand All @@ -178,8 +187,7 @@ protected String getHttpUpgradeEndpointKey() {
* Service to handle HTTP upgrade for legacy (HornetQ) clients.
*
* Legacy clients use different protocol and security key and accept headers during the HTTP Upgrade handshake.
*/
static class LegacyHttpUpgradeService extends HTTPUpgradeService {
*/static class LegacyHttpUpgradeService extends HTTPUpgradeService {

public static void installService(final ServiceTarget serviceTarget, String activeMQServerName, final String acceptorName, final String httpListenerName) {

Expand Down