protected final SubProtocolHandler findProtocolHandler(WebSocketSession session) {
   String protocol = null;
   try {
     protocol = session.getAcceptedProtocol();
   } catch (Exception ex) {
     // Shouldn't happen
     logger.error(
         "Failed to obtain session.getAcceptedProtocol(). Will use the "
             + "default protocol handler (if configured).",
         ex);
   }
   SubProtocolHandler handler;
   if (!StringUtils.isEmpty(protocol)) {
     handler = this.protocolHandlerLookup.get(protocol);
     Assert.state(
         handler != null, "No handler for '" + protocol + "' among " + this.protocolHandlerLookup);
   } else {
     if (this.defaultProtocolHandler != null) {
       handler = this.defaultProtocolHandler;
     } else if (this.protocolHandlers.size() == 1) {
       handler = this.protocolHandlers.iterator().next();
     } else {
       throw new IllegalStateException(
           "Multiple protocol handlers configured and "
               + "no protocol was negotiated. Consider configuring a default SubProtocolHandler.");
     }
   }
   return handler;
 }