code: public HttpSession resolve(ServerSocket socket) {
      ServerTransport transport = socket.unwrap(ServerTransport.class);
  
      ServerWebSocket ws = transport.unwrap(ServerWebSocket.class);
      if (ws != null) {
        String key = HttpSession.class.getName();
        return (HttpSession) ws.unwrap(Session.class).getUserProperties().get(key);
      }
  
      ServerHttpExchange http = transport.unwrap(ServerHttpExchange.class);
      if (http != null) {
        return http.unwrap(HttpServletRequest.class).getSession(false);
      }
  
      return null;
    }
docs: Resolves the current session.
  <p>
  Note that it doesn't create a session and returns <code>null</code> if there's no
  current session.