Browse Source

Consistent volatile access to running flag in Lifecycle implementations

Issue: SPR-16488
pull/1744/head
Juergen Hoeller 7 years ago
parent
commit
d4a8f76bf9
  1. 8
      spring-jms/src/main/java/org/springframework/jms/listener/AbstractJmsListeningContainer.java
  2. 10
      spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java
  3. 14
      spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractBrokerMessageHandler.java
  4. 10
      spring-messaging/src/main/java/org/springframework/messaging/simp/user/UserDestinationMessageHandler.java
  5. 8
      spring-tx/src/main/java/org/springframework/jca/endpoint/GenericMessageEndpointManager.java
  6. 29
      spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/AbstractHttpServer.java
  7. 8
      spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/JettyWebSocketClient.java
  8. 11
      spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketService.java
  9. 11
      spring-websocket/src/main/java/org/springframework/web/socket/client/ConnectionManagerSupport.java
  10. 50
      spring-websocket/src/main/java/org/springframework/web/socket/client/jetty/JettyWebSocketClient.java
  11. 8
      spring-websocket/src/main/java/org/springframework/web/socket/messaging/SubProtocolWebSocketHandler.java
  12. 7
      spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketStompClient.java
  13. 9
      spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java
  14. 14
      spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java
  15. 11
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractXhrTransport.java
  16. 6
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/JettyXhrTransport.java
  17. 2
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java
  18. 17
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/WebSocketTransportHandler.java

8
spring-jms/src/main/java/org/springframework/jms/listener/AbstractJmsListeningContainer.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -80,7 +80,7 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess @@ -80,7 +80,7 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess
private boolean active = false;
private boolean running = false;
private volatile boolean running = false;
private final List<Object> pausedTasks = new LinkedList<>();
@ -350,9 +350,7 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess @@ -350,9 +350,7 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess
*/
@Override
public final boolean isRunning() {
synchronized (this.lifecycleMonitor) {
return (this.running && runningAllowed());
}
return (this.running && runningAllowed());
}
/**

10
spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -111,10 +111,10 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan @@ -111,10 +111,10 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
@Nullable
private MessageHeaderInitializer headerInitializer;
private final Object lifecycleMonitor = new Object();
private volatile boolean running = false;
private final Object lifecycleMonitor = new Object();
/**
* Create an instance of SimpAnnotationMethodMessageHandler with the given
@ -299,9 +299,7 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan @@ -299,9 +299,7 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
@Override
public final boolean isRunning() {
synchronized (this.lifecycleMonitor) {
return this.running;
}
return this.running;
}

14
spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractBrokerMessageHandler.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -156,9 +156,7 @@ public abstract class AbstractBrokerMessageHandler @@ -156,9 +156,7 @@ public abstract class AbstractBrokerMessageHandler
@Override
public void start() {
synchronized (this.lifecycleMonitor) {
if (logger.isInfoEnabled()) {
logger.info("Starting...");
}
logger.info("Starting...");
this.clientInboundChannel.subscribe(this);
this.brokerChannel.subscribe(this);
if (this.clientInboundChannel instanceof InterceptableChannel) {
@ -176,9 +174,7 @@ public abstract class AbstractBrokerMessageHandler @@ -176,9 +174,7 @@ public abstract class AbstractBrokerMessageHandler
@Override
public void stop() {
synchronized (this.lifecycleMonitor) {
if (logger.isInfoEnabled()) {
logger.info("Stopping...");
}
logger.info("Stopping...");
stopInternal();
this.clientInboundChannel.unsubscribe(this);
this.brokerChannel.unsubscribe(this);
@ -209,9 +205,7 @@ public abstract class AbstractBrokerMessageHandler @@ -209,9 +205,7 @@ public abstract class AbstractBrokerMessageHandler
*/
@Override
public final boolean isRunning() {
synchronized (this.lifecycleMonitor) {
return this.running;
}
return this.running;
}
/**

10
spring-messaging/src/main/java/org/springframework/messaging/simp/user/UserDestinationMessageHandler.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -67,10 +67,10 @@ public class UserDestinationMessageHandler implements MessageHandler, SmartLifec @@ -67,10 +67,10 @@ public class UserDestinationMessageHandler implements MessageHandler, SmartLifec
@Nullable
private MessageHeaderInitializer headerInitializer;
private final Object lifecycleMonitor = new Object();
private volatile boolean running = false;
private final Object lifecycleMonitor = new Object();
/**
* Create an instance with the given client and broker channels subscribing
@ -185,9 +185,7 @@ public class UserDestinationMessageHandler implements MessageHandler, SmartLifec @@ -185,9 +185,7 @@ public class UserDestinationMessageHandler implements MessageHandler, SmartLifec
@Override
public final boolean isRunning() {
synchronized (this.lifecycleMonitor) {
return this.running;
}
return this.running;
}

8
spring-tx/src/main/java/org/springframework/jca/endpoint/GenericMessageEndpointManager.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -161,7 +161,7 @@ public class GenericMessageEndpointManager implements SmartLifecycle, Initializi @@ -161,7 +161,7 @@ public class GenericMessageEndpointManager implements SmartLifecycle, Initializi
private int phase = Integer.MAX_VALUE;
private boolean running = false;
private volatile boolean running = false;
private final Object lifecycleMonitor = new Object();
@ -330,9 +330,7 @@ public class GenericMessageEndpointManager implements SmartLifecycle, Initializi @@ -330,9 +330,7 @@ public class GenericMessageEndpointManager implements SmartLifecycle, Initializi
*/
@Override
public boolean isRunning() {
synchronized (this.lifecycleMonitor) {
return this.running;
}
return this.running;
}
/**

29
spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/AbstractHttpServer.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -42,7 +42,7 @@ public abstract class AbstractHttpServer implements HttpServer { @@ -42,7 +42,7 @@ public abstract class AbstractHttpServer implements HttpServer {
private Map<String, HttpHandler> handlerMap;
private boolean running;
private volatile boolean running;
private final Object lifecycleMonitor = new Object();
@ -87,8 +87,8 @@ public abstract class AbstractHttpServer implements HttpServer { @@ -87,8 +87,8 @@ public abstract class AbstractHttpServer implements HttpServer {
}
protected HttpHandler resolveHttpHandler() {
return getHttpHandlerMap() != null ?
new ContextPathCompositeHandler(getHttpHandlerMap()) : getHttpHandler();
return (getHttpHandlerMap() != null ?
new ContextPathCompositeHandler(getHttpHandlerMap()) : getHttpHandler());
}
@ -111,26 +111,23 @@ public abstract class AbstractHttpServer implements HttpServer { @@ -111,26 +111,23 @@ public abstract class AbstractHttpServer implements HttpServer {
// Lifecycle
@Override
public boolean isRunning() {
synchronized (this.lifecycleMonitor) {
return this.running;
}
}
@Override
public final void start() {
synchronized (this.lifecycleMonitor) {
if (!isRunning()) {
String serverName = getClass().getSimpleName();
logger.debug("Starting " + serverName + "...");
if (logger.isDebugEnabled()) {
logger.debug("Starting " + serverName + "...");
}
this.running = true;
try {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
startInternal();
long millis = stopWatch.getTotalTimeMillis();
logger.debug("Server started on port " + getPort() + "(" + millis + " millis).");
if (logger.isDebugEnabled()) {
logger.debug("Server started on port " + getPort() + "(" + millis + " millis).");
}
}
catch (Throwable ex) {
throw new IllegalStateException(ex);
@ -167,6 +164,12 @@ public abstract class AbstractHttpServer implements HttpServer { @@ -167,6 +164,12 @@ public abstract class AbstractHttpServer implements HttpServer {
protected abstract void stopInternal() throws Exception;
@Override
public boolean isRunning() {
return this.running;
}
private void reset() {
this.host = "0.0.0.0";
this.port = 0;

8
spring-webflux/src/main/java/org/springframework/web/reactive/socket/client/JettyWebSocketClient.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -54,7 +54,7 @@ public class JettyWebSocketClient extends WebSocketClientSupport implements WebS @@ -54,7 +54,7 @@ public class JettyWebSocketClient extends WebSocketClientSupport implements WebS
private final boolean externallyManaged;
private boolean running = false;
private volatile boolean running = false;
private final Object lifecycleMonitor = new Object();
@ -135,9 +135,7 @@ public class JettyWebSocketClient extends WebSocketClientSupport implements WebS @@ -135,9 +135,7 @@ public class JettyWebSocketClient extends WebSocketClientSupport implements WebS
@Override
public boolean isRunning() {
synchronized (this.lifecycleMonitor) {
return this.running;
}
return this.running;
}

11
spring-webflux/src/main/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketService.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -135,10 +135,6 @@ public class HandshakeWebSocketService implements WebSocketService, Lifecycle { @@ -135,10 +135,6 @@ public class HandshakeWebSocketService implements WebSocketService, Lifecycle {
return this.upgradeStrategy;
}
@Override
public boolean isRunning() {
return this.running;
}
@Override
public void start() {
@ -168,6 +164,11 @@ public class HandshakeWebSocketService implements WebSocketService, Lifecycle { @@ -168,6 +164,11 @@ public class HandshakeWebSocketService implements WebSocketService, Lifecycle {
}
}
@Override
public boolean isRunning() {
return this.running;
}
@Override
public Mono<Void> handleRequest(ServerWebExchange exchange, WebSocketHandler handler) {

11
spring-websocket/src/main/java/org/springframework/web/socket/client/ConnectionManagerSupport.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -38,15 +38,14 @@ public abstract class ConnectionManagerSupport implements SmartLifecycle { @@ -38,15 +38,14 @@ public abstract class ConnectionManagerSupport implements SmartLifecycle {
protected final Log logger = LogFactory.getLog(getClass());
private final URI uri;
private boolean autoStartup = false;
private boolean running = false;
private int phase = Integer.MAX_VALUE;
private volatile boolean running = false;
private final Object lifecycleMonitor = new Object();
@ -161,9 +160,7 @@ public abstract class ConnectionManagerSupport implements SmartLifecycle { @@ -161,9 +160,7 @@ public abstract class ConnectionManagerSupport implements SmartLifecycle {
*/
@Override
public boolean isRunning() {
synchronized (this.lifecycleMonitor) {
return this.running;
}
return this.running;
}

50
spring-websocket/src/main/java/org/springframework/web/socket/client/jetty/JettyWebSocketClient.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -61,8 +61,6 @@ public class JettyWebSocketClient extends AbstractWebSocketClient implements Lif @@ -61,8 +61,6 @@ public class JettyWebSocketClient extends AbstractWebSocketClient implements Lif
private final org.eclipse.jetty.websocket.client.WebSocketClient client;
private final Object lifecycleMonitor = new Object();
@Nullable
private AsyncListenableTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
@ -102,47 +100,33 @@ public class JettyWebSocketClient extends AbstractWebSocketClient implements Lif @@ -102,47 +100,33 @@ public class JettyWebSocketClient extends AbstractWebSocketClient implements Lif
return this.taskExecutor;
}
@Override
public boolean isRunning() {
synchronized (this.lifecycleMonitor) {
return this.client.isStarted();
}
}
@Override
public void start() {
synchronized (this.lifecycleMonitor) {
if (!isRunning()) {
try {
if (logger.isInfoEnabled()) {
logger.info("Starting Jetty WebSocketClient");
}
this.client.start();
}
catch (Exception ex) {
throw new IllegalStateException("Failed to start Jetty client", ex);
}
}
try {
this.client.start();
}
catch (Exception ex) {
throw new IllegalStateException("Failed to start Jetty WebSocketClient", ex);
}
}
@Override
public void stop() {
synchronized (this.lifecycleMonitor) {
if (isRunning()) {
try {
if (logger.isInfoEnabled()) {
logger.info("Stopping Jetty WebSocketClient");
}
this.client.stop();
}
catch (Exception ex) {
logger.error("Error stopping Jetty WebSocketClient", ex);
}
}
try {
this.client.stop();
}
catch (Exception ex) {
logger.error("Failed to stop Jetty WebSocketClient", ex);
}
}
@Override
public boolean isRunning() {
return this.client.isStarted();
}
@Override
public ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler,
String uriTemplate, Object... uriVars) {

8
spring-websocket/src/main/java/org/springframework/web/socket/messaging/SubProtocolWebSocketHandler.java

@ -104,10 +104,10 @@ public class SubProtocolWebSocketHandler @@ -104,10 +104,10 @@ public class SubProtocolWebSocketHandler
private final Stats stats = new Stats();
private final Object lifecycleMonitor = new Object();
private volatile boolean running = false;
private final Object lifecycleMonitor = new Object();
/**
* Create a new {@code SubProtocolWebSocketHandler} for the given inbound and outbound channels.
@ -282,9 +282,7 @@ public class SubProtocolWebSocketHandler @@ -282,9 +282,7 @@ public class SubProtocolWebSocketHandler
@Override
public final boolean isRunning() {
synchronized (this.lifecycleMonitor) {
return this.running;
}
return this.running;
}

7
spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketStompClient.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -73,17 +73,16 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif @@ -73,17 +73,16 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
private static final Log logger = LogFactory.getLog(WebSocketStompClient.class);
private final WebSocketClient webSocketClient;
private int inboundMessageSizeLimit = 64 * 1024;
private boolean autoStartup = true;
private boolean running = false;
private int phase = Integer.MAX_VALUE;
private volatile boolean running = false;
/**
* Class constructor. Sets {@link #setDefaultHeartbeat} to "0,0" but will

9
spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java

@ -185,10 +185,6 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life @@ -185,10 +185,6 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
return StringUtils.toStringArray(this.supportedProtocols);
}
@Override
public boolean isRunning() {
return this.running;
}
@Override
public void start() {
@ -218,6 +214,11 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life @@ -218,6 +214,11 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life
}
}
@Override
public boolean isRunning() {
return this.running;
}
@Override
public final boolean doHandshake(ServerHttpRequest request, ServerHttpResponse response,

14
spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,7 +21,6 @@ import java.util.ArrayList; @@ -21,7 +21,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@ -59,7 +58,7 @@ import org.springframework.web.socket.server.HandshakeInterceptor; @@ -59,7 +58,7 @@ import org.springframework.web.socket.server.HandshakeInterceptor;
*/
public class WebSocketHttpRequestHandler implements HttpRequestHandler, Lifecycle, ServletContextAware {
private final Log logger = LogFactory.getLog(WebSocketHttpRequestHandler.class);
private static final Log logger = LogFactory.getLog(WebSocketHttpRequestHandler.class);
private final WebSocketHandler wsHandler;
@ -120,10 +119,6 @@ public class WebSocketHttpRequestHandler implements HttpRequestHandler, Lifecycl @@ -120,10 +119,6 @@ public class WebSocketHttpRequestHandler implements HttpRequestHandler, Lifecycl
}
}
@Override
public boolean isRunning() {
return this.running;
}
@Override
public void start() {
@ -145,6 +140,11 @@ public class WebSocketHttpRequestHandler implements HttpRequestHandler, Lifecycl @@ -145,6 +140,11 @@ public class WebSocketHttpRequestHandler implements HttpRequestHandler, Lifecycl
}
}
@Override
public boolean isRunning() {
return this.running;
}
@Override
public void handleRequest(HttpServletRequest servletRequest, HttpServletResponse servletResponse)

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -63,8 +63,7 @@ public abstract class AbstractXhrTransport implements XhrTransport { @@ -63,8 +63,7 @@ public abstract class AbstractXhrTransport implements XhrTransport {
@Override
public List<TransportType> getTransportTypes() {
return (isXhrStreamingDisabled() ?
Collections.singletonList(TransportType.XHR) :
return (isXhrStreamingDisabled() ? Collections.singletonList(TransportType.XHR) :
Arrays.asList(TransportType.XHR_STREAMING, TransportType.XHR));
}
@ -166,10 +165,4 @@ public abstract class AbstractXhrTransport implements XhrTransport { @@ -166,10 +165,4 @@ public abstract class AbstractXhrTransport implements XhrTransport {
protected abstract ResponseEntity<String> executeSendRequestInternal(
URI url, HttpHeaders headers, TextMessage message);
@Override
public String toString() {
return getClass().getSimpleName();
}
}

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -86,7 +86,7 @@ public class JettyXhrTransport extends AbstractXhrTransport implements Lifecycle @@ -86,7 +86,7 @@ public class JettyXhrTransport extends AbstractXhrTransport implements Lifecycle
}
}
catch (Exception ex) {
throw new SockJsException("Failed to start " + this, ex);
throw new SockJsException("Failed to start JettyXhrTransport", ex);
}
}
@ -98,7 +98,7 @@ public class JettyXhrTransport extends AbstractXhrTransport implements Lifecycle @@ -98,7 +98,7 @@ public class JettyXhrTransport extends AbstractXhrTransport implements Lifecycle
}
}
catch (Exception ex) {
throw new SockJsException("Failed to stop " + this, ex);
throw new SockJsException("Failed to stop JettyXhrTransport", ex);
}
}

2
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java

@ -81,7 +81,7 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem @@ -81,7 +81,7 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem
@Nullable
private ScheduledFuture<?> sessionCleanupTask;
private boolean running;
private volatile boolean running;
/**

17
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/WebSocketTransportHandler.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
package org.springframework.web.socket.sockjs.transport.handler;
import java.util.Map;
import javax.servlet.ServletContext;
import org.springframework.context.Lifecycle;
@ -53,11 +52,11 @@ public class WebSocketTransportHandler extends AbstractTransportHandler @@ -53,11 +52,11 @@ public class WebSocketTransportHandler extends AbstractTransportHandler
private final HandshakeHandler handshakeHandler;
private boolean running;
private volatile boolean running;
public WebSocketTransportHandler(HandshakeHandler handshakeHandler) {
Assert.notNull(handshakeHandler, "handshakeHandler must not be null");
Assert.notNull(handshakeHandler, "HandshakeHandler must not be null");
this.handshakeHandler = handshakeHandler;
}
@ -78,10 +77,6 @@ public class WebSocketTransportHandler extends AbstractTransportHandler @@ -78,10 +77,6 @@ public class WebSocketTransportHandler extends AbstractTransportHandler
}
}
@Override
public boolean isRunning() {
return this.running;
}
@Override
public void start() {
@ -103,6 +98,12 @@ public class WebSocketTransportHandler extends AbstractTransportHandler @@ -103,6 +98,12 @@ public class WebSocketTransportHandler extends AbstractTransportHandler
}
}
@Override
public boolean isRunning() {
return this.running;
}
@Override
public boolean checkSessionType(SockJsSession session) {
return session instanceof WebSocketServerSockJsSession;

Loading…
Cancel
Save