Author: markt Date: Wed Apr 8 21:29:05 2015 New Revision: 1672190 URL: http://svn.apache.org/r1672190 Log: Fix a crash when I put it all together. Get the negotiated protocol after the handshake.
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1672190&r1=1672189&r2=1672190&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Wed Apr 8 21:29:05 2015 @@ -832,7 +832,8 @@ public class AprEndpoint extends Abstrac /** * Process the specified connection. */ - protected boolean setSocketOptions(long socket) { + protected boolean setSocketOptions(SocketWrapperBase<Long> socketWrapper) { + long socket = socketWrapper.getSocket().longValue(); // Process the connection int step = 1; try { @@ -854,8 +855,20 @@ public class AprEndpoint extends Abstrac } return false; } - } + if (negotiableProtocols.size() > 0) { + byte[] negotiated = new byte[256]; + int len = SSLSocket.getALPN(socket, negotiated); + String negotiatedProtocol = + new String(negotiated, 0, len, StandardCharsets.UTF_8); + if (negotiatedProtocol.length() > 0) { + socketWrapper.setNegotiatedProtocol(negotiatedProtocol); + if (log.isDebugEnabled()) { + log.debug(sm.getString("endpoint.alpn.negotiated", negotiatedProtocol)); + } + } + } + } } catch (Throwable t) { ExceptionUtils.handleThrowable(t); if (log.isDebugEnabled()) { @@ -906,18 +919,6 @@ public class AprEndpoint extends Abstrac wrapper.setSecure(isSSLEnabled()); wrapper.setReadTimeout(getSoTimeout()); wrapper.setWriteTimeout(getSoTimeout()); - if (isSSLEnabled() && negotiableProtocols.size() > 0) { - byte[] negotiated = new byte[256]; - int len = SSLSocket.getALPN(socket, negotiated); - String negotiatedProtocol = - new String(negotiated, 0, len, StandardCharsets.UTF_8); - if (negotiatedProtocol.length() > 0) { - wrapper.setNegotiatedProtocol(negotiatedProtocol); - if (log.isDebugEnabled()) { - log.debug(sm.getString("endpoint.alpn.negotiated", negotiatedProtocol)); - } - } - } connections.put(Long.valueOf(socket), wrapper); getExecutor().execute(new SocketWithOptionsProcessor(wrapper)); } @@ -2359,7 +2360,7 @@ public class AprEndpoint extends Abstrac synchronized (socket) { if (!deferAccept) { - if (setSocketOptions(socket.getSocket().longValue())) { + if (setSocketOptions(socket)) { getPoller().add(socket.getSocket().longValue(), getSoTimeout(), Poll.APR_POLLIN); } else { @@ -2369,7 +2370,7 @@ public class AprEndpoint extends Abstrac } } else { // Process the request from this socket - if (!setSocketOptions(socket.getSocket().longValue())) { + if (!setSocketOptions(socket)) { // Close socket and pool closeSocket(socket.getSocket().longValue()); socket = null; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org