Skip to content

Commit aa3a78a

Browse files
committed
SockJsTransportFailureException provides constructor variant without session id
(cherry picked from commit e0a11f2)
1 parent 6cdc208 commit aa3a78a

File tree

5 files changed

+83
-51
lines changed

5 files changed

+83
-51
lines changed

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/SockJsException.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,15 +30,30 @@ public class SockJsException extends NestedRuntimeException {
3030
private final String sessionId;
3131

3232

33+
/**
34+
* Constructor for SockJsException.
35+
* @param message the exception message
36+
* @param cause the root cause
37+
*/
3338
public SockJsException(String message, Throwable cause) {
3439
this(message, null, cause);
3540
}
3641

42+
/**
43+
* Constructor for SockJsException.
44+
* @param message the exception message
45+
* @param sessionId the SockJS session id
46+
* @param cause the root cause
47+
*/
3748
public SockJsException(String message, String sessionId, Throwable cause) {
3849
super(message, cause);
3950
this.sessionId = sessionId;
4051
}
4152

53+
54+
/**
55+
* Return the SockJS session id.
56+
*/
4257
public String getSockJsSessionId() {
4358
return this.sessionId;
4459
}

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/SockJsTransportFailureException.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,16 +17,32 @@
1717
package org.springframework.web.socket.sockjs;
1818

1919
/**
20-
* Indicates a serious failure that occurred in the SockJS implementation as opposed to in
21-
* user code (e.g. IOException while writing to the response). When this exception is
22-
* raised, the SockJS session is typically closed.
20+
* Indicates a serious failure that occurred in the SockJS implementation as opposed to
21+
* in user code (e.g. IOException while writing to the response). When this exception
22+
* is raised, the SockJS session is typically closed.
2323
*
2424
* @author Rossen Stoyanchev
2525
* @since 4.0
2626
*/
2727
@SuppressWarnings("serial")
2828
public class SockJsTransportFailureException extends SockJsException {
2929

30+
/**
31+
* Constructor for SockJsTransportFailureException.
32+
* @param message the exception message
33+
* @param cause the root cause
34+
* @since 4.1.7
35+
*/
36+
public SockJsTransportFailureException(String message, Throwable cause) {
37+
super(message, cause);
38+
}
39+
40+
/**
41+
* Constructor for SockJsTransportFailureException.
42+
* @param message the exception message
43+
* @param sessionId the SockJS session id
44+
* @param cause the root cause
45+
*/
3046
public SockJsTransportFailureException(String message, String sessionId, Throwable cause) {
3147
super(message, sessionId, cause);
3248
}

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/DefaultTransportRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -205,7 +205,7 @@ private void handleFailure(Throwable ex, boolean isTimeoutFailure) {
205205
if (isTimeoutFailure) {
206206
String message = "Connect timed out for " + DefaultTransportRequest.this;
207207
logger.error(message);
208-
ex = new SockJsTransportFailureException(message, getSockJsUrlInfo().getSessionId(), null);
208+
ex = new SockJsTransportFailureException(message, getSockJsUrlInfo().getSessionId(), ex);
209209
}
210210
if (fallbackRequest != null) {
211211
logger.error(DefaultTransportRequest.this + " failed. Falling back on next transport.", ex);

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/JettyXhrTransport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -126,7 +126,7 @@ protected ResponseEntity<String> executeRequest(URI url, HttpMethod method, Http
126126
response = httpRequest.send();
127127
}
128128
catch (Exception ex) {
129-
throw new SockJsTransportFailureException("Failed to execute request to " + url, null, ex);
129+
throw new SockJsTransportFailureException("Failed to execute request to " + url, ex);
130130
}
131131
HttpStatus status = HttpStatus.valueOf(response.getStatus());
132132
HttpHeaders responseHeaders = toHttpHeaders(response.getHeaders());

0 commit comments

Comments
 (0)