|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2017 the original author or authors. |
| 2 | + * Copyright 2002-2018 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -60,8 +60,6 @@ public class JettyWebSocketClient extends AbstractWebSocketClient implements Lif
|
60 | 60 |
|
61 | 61 | private final org.eclipse.jetty.websocket.client.WebSocketClient client;
|
62 | 62 |
|
63 |
| - private final Object lifecycleMonitor = new Object(); |
64 |
| - |
65 | 63 | private AsyncListenableTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
|
66 | 64 |
|
67 | 65 |
|
@@ -99,47 +97,33 @@ public AsyncListenableTaskExecutor getTaskExecutor() {
|
99 | 97 | return this.taskExecutor;
|
100 | 98 | }
|
101 | 99 |
|
102 |
| - @Override |
103 |
| - public boolean isRunning() { |
104 |
| - synchronized (this.lifecycleMonitor) { |
105 |
| - return this.client.isStarted(); |
106 |
| - } |
107 |
| - } |
108 | 100 |
|
109 | 101 | @Override
|
110 | 102 | public void start() {
|
111 |
| - synchronized (this.lifecycleMonitor) { |
112 |
| - if (!isRunning()) { |
113 |
| - try { |
114 |
| - if (logger.isInfoEnabled()) { |
115 |
| - logger.info("Starting Jetty WebSocketClient"); |
116 |
| - } |
117 |
| - this.client.start(); |
118 |
| - } |
119 |
| - catch (Exception ex) { |
120 |
| - throw new IllegalStateException("Failed to start Jetty client", ex); |
121 |
| - } |
122 |
| - } |
| 103 | + try { |
| 104 | + this.client.start(); |
| 105 | + } |
| 106 | + catch (Exception ex) { |
| 107 | + throw new IllegalStateException("Failed to start Jetty WebSocketClient", ex); |
123 | 108 | }
|
124 | 109 | }
|
125 | 110 |
|
126 | 111 | @Override
|
127 | 112 | public void stop() {
|
128 |
| - synchronized (this.lifecycleMonitor) { |
129 |
| - if (isRunning()) { |
130 |
| - try { |
131 |
| - if (logger.isInfoEnabled()) { |
132 |
| - logger.info("Stopping Jetty WebSocketClient"); |
133 |
| - } |
134 |
| - this.client.stop(); |
135 |
| - } |
136 |
| - catch (Exception ex) { |
137 |
| - logger.error("Error stopping Jetty WebSocketClient", ex); |
138 |
| - } |
139 |
| - } |
| 113 | + try { |
| 114 | + this.client.stop(); |
| 115 | + } |
| 116 | + catch (Exception ex) { |
| 117 | + logger.error("Failed to stop Jetty WebSocketClient", ex); |
140 | 118 | }
|
141 | 119 | }
|
142 | 120 |
|
| 121 | + @Override |
| 122 | + public boolean isRunning() { |
| 123 | + return this.client.isStarted(); |
| 124 | + } |
| 125 | + |
| 126 | + |
143 | 127 | @Override
|
144 | 128 | public ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler,
|
145 | 129 | String uriTemplate, Object... uriVars) {
|
|
0 commit comments