Issue #4747 - SessionID should return same String instance

Using the object hash code is not random enough to use as a unique ID.
Now using UUID.randomUUID() instead which sufficiently random.

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2020-04-06 11:54:16 +10:00
parent 664cb81e6d
commit 2028b99e83
1 changed files with 4 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.websocket.CloseReason;
@ -62,6 +63,7 @@ public class JavaxWebSocketSession implements javax.websocket.Session
private final AvailableDecoders availableDecoders;
private final AvailableEncoders availableEncoders;
private final Map<String, String> pathParameters;
private final String sessionId;
private Map<String, Object> userProperties;
private List<Extension> negotiatedExtensions;
@ -76,8 +78,8 @@ public class JavaxWebSocketSession implements javax.websocket.Session
this.container = container;
this.coreSession = coreSession;
this.frameHandler = frameHandler;
this.sessionId = UUID.randomUUID().toString();
this.config = Objects.requireNonNull(endpointConfig);
this.availableDecoders = new AvailableDecoders(this.config);
this.availableEncoders = new AvailableEncoders(this.config);
@ -315,7 +317,7 @@ public class JavaxWebSocketSession implements javax.websocket.Session
@Override
public String getId()
{
return this.frameHandler.getUpgradeRequest().toString();
return sessionId;
}
/**