Safe InetSocketAddress init for WebSocket and SockJS
Issue: SPR-14295
This commit is contained in:
parent
9c02a99d38
commit
a9217d51c2
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -105,8 +105,20 @@ public abstract class AbstractStandardUpgradeStrategy implements RequestUpgradeS
|
||||||
WebSocketHandler wsHandler, Map<String, Object> attrs) throws HandshakeFailureException {
|
WebSocketHandler wsHandler, Map<String, Object> attrs) throws HandshakeFailureException {
|
||||||
|
|
||||||
HttpHeaders headers = request.getHeaders();
|
HttpHeaders headers = request.getHeaders();
|
||||||
InetSocketAddress localAddr = request.getLocalAddress();
|
InetSocketAddress localAddr = null;
|
||||||
InetSocketAddress remoteAddr = request.getRemoteAddress();
|
try {
|
||||||
|
localAddr = request.getLocalAddress();
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
InetSocketAddress remoteAddr = null;
|
||||||
|
try {
|
||||||
|
remoteAddr = request.getRemoteAddress();
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
|
||||||
StandardWebSocketSession session = new StandardWebSocketSession(headers, attrs, localAddr, remoteAddr, user);
|
StandardWebSocketSession session = new StandardWebSocketSession(headers, attrs, localAddr, remoteAddr, user);
|
||||||
StandardWebSocketHandlerAdapter endpoint = new StandardWebSocketHandlerAdapter(wsHandler, session);
|
StandardWebSocketHandlerAdapter endpoint = new StandardWebSocketHandlerAdapter(wsHandler, session);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -196,8 +196,18 @@ public abstract class AbstractHttpSockJsSession extends AbstractSockJsSession {
|
||||||
this.uri = request.getURI();
|
this.uri = request.getURI();
|
||||||
this.handshakeHeaders = request.getHeaders();
|
this.handshakeHeaders = request.getHeaders();
|
||||||
this.principal = request.getPrincipal();
|
this.principal = request.getPrincipal();
|
||||||
this.localAddress = request.getLocalAddress();
|
try {
|
||||||
this.remoteAddress = request.getRemoteAddress();
|
this.localAddress = request.getLocalAddress();
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
this.remoteAddress = request.getRemoteAddress();
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
|
||||||
synchronized (this.responseLock) {
|
synchronized (this.responseLock) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue