Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2012-08-08 15:42:57 -0400
committerJoakim Erdfelt2012-08-08 15:42:57 -0400
commit889d20ba5576977d6f98d6c3b0faf169d340de04 (patch)
tree461525237cd62edf3c865dc7e4621867c03106fd /jetty-websocket
parent0abb7511ffed79299294f6bf7381f5faa64093e3 (diff)
downloadorg.eclipse.jetty.project-889d20ba5576977d6f98d6c3b0faf169d340de04.tar.gz
org.eclipse.jetty.project-889d20ba5576977d6f98d6c3b0faf169d340de04.tar.xz
org.eclipse.jetty.project-889d20ba5576977d6f98d6c3b0faf169d340de04.zip
Removing throws IOException on WSConnection.close()
Diffstat (limited to 'jetty-websocket')
-rw-r--r--jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClientFactory.java34
-rw-r--r--jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/api/BaseConnection.java12
-rw-r--r--jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/driver/WebSocketEventDriver.java22
-rw-r--r--jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/AbstractWebSocketConnection.java4
-rw-r--r--jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/FrameBytes.java10
-rw-r--r--jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/WebSocketSession.java4
-rw-r--r--jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java9
7 files changed, 34 insertions, 61 deletions
diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClientFactory.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClientFactory.java
index 484fc92a82..950f4e37f5 100644
--- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClientFactory.java
+++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClientFactory.java
@@ -15,7 +15,6 @@
//========================================================================
package org.eclipse.jetty.websocket.client;
-import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.Queue;
@@ -56,54 +55,53 @@ public class WebSocketClientFactory extends AggregateLifeCycle
public WebSocketClientFactory(Executor threadPool)
{
- this(threadPool, Executors.newSingleThreadScheduledExecutor());
- }
-
- public WebSocketClientFactory(SslContextFactory sslContextFactory)
- {
- this(new QueuedThreadPool(), Executors.newSingleThreadScheduledExecutor(), sslContextFactory);
+ this(threadPool,Executors.newSingleThreadScheduledExecutor());
}
public WebSocketClientFactory(Executor threadPool, ScheduledExecutorService scheduler)
{
- this(threadPool, scheduler, null);
+ this(threadPool,scheduler,null);
}
public WebSocketClientFactory(Executor executor, ScheduledExecutorService scheduler, SslContextFactory sslContextFactory)
{
if (executor == null)
+ {
throw new IllegalArgumentException("Executor is required");
+ }
this.executor = executor;
addBean(executor);
if (scheduler == null)
+ {
throw new IllegalArgumentException("Scheduler is required");
+ }
this.scheduler = scheduler;
if (sslContextFactory != null)
+ {
addBean(sslContextFactory);
+ }
this.policy = WebSocketPolicy.newClientPolicy();
- selector = new WebSocketClientSelectorManager(bufferPool, executor, scheduler, policy);
+ selector = new WebSocketClientSelectorManager(bufferPool,executor,scheduler,policy);
selector.setSslContextFactory(sslContextFactory);
addBean(selector);
this.methodsCache = new EventMethodsCache();
}
+ public WebSocketClientFactory(SslContextFactory sslContextFactory)
+ {
+ this(new QueuedThreadPool(),Executors.newSingleThreadScheduledExecutor(),sslContextFactory);
+ }
+
private void closeConnections()
{
for (WebSocketConnection connection : connections)
{
- try
- {
- connection.close();
- }
- catch (IOException e)
- {
- LOG.warn(e);
- }
+ connection.close();
}
connections.clear();
}
@@ -152,6 +150,6 @@ public class WebSocketClientFactory extends AggregateLifeCycle
public WebSocketEventDriver newWebSocketDriver(Object websocketPojo)
{
- return new WebSocketEventDriver(websocketPojo, methodsCache, policy, getBufferPool());
+ return new WebSocketEventDriver(websocketPojo,methodsCache,policy,getBufferPool());
}
}
diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/api/BaseConnection.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/api/BaseConnection.java
index d1a08e740f..9eca336221 100644
--- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/api/BaseConnection.java
+++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/api/BaseConnection.java
@@ -1,8 +1,10 @@
package org.eclipse.jetty.websocket.api;
-import java.io.IOException;
import java.net.InetSocketAddress;
+/**
+ * Base Connection concepts
+ */
public interface BaseConnection
{
/**
@@ -21,12 +23,10 @@ public interface BaseConnection
* <p>
* Basic usage: results in an non-blocking async write, then connection close.
*
- * @throws IOException
- * if unable to send the close frame, or close the connection successfully.
* @see StatusCode
* @see #close(int, String)
*/
- void close() throws IOException;
+ void close();
/**
* Terminate connection, with status code.
@@ -37,11 +37,9 @@ public interface BaseConnection
* the status code
* @param reason
* the (optional) reason. (can be null for no reason)
- * @throws IOException
- * if unable to send the close frame, or close the connection successfully.
* @see StatusCode
*/
- void close(int statusCode, String reason) throws IOException;
+ void close(int statusCode, String reason);
/**
* Get the remote Address in use for this connection.
diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/driver/WebSocketEventDriver.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/driver/WebSocketEventDriver.java
index 56bada51b3..b24731729f 100644
--- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/driver/WebSocketEventDriver.java
+++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/driver/WebSocketEventDriver.java
@@ -15,7 +15,6 @@
//========================================================================
package org.eclipse.jetty.websocket.driver;
-import java.io.IOException;
import java.nio.ByteBuffer;
import org.eclipse.jetty.io.ByteBufferPool;
@@ -287,24 +286,17 @@ public class WebSocketEventDriver implements IncomingFrames
private void terminateConnection(int statusCode, String rawreason)
{
- try
+ String reason = rawreason;
+ if (StringUtil.isNotBlank(reason))
{
- String reason = rawreason;
- if (StringUtil.isNotBlank(reason))
+ // Trim big exception messages here.
+ if (reason.length() > (WebSocketFrame.MAX_CONTROL_PAYLOAD - 2))
{
- // Trim big exception messages here.
- if (reason.length() > (WebSocketFrame.MAX_CONTROL_PAYLOAD - 2))
- {
- reason = reason.substring(0,WebSocketFrame.MAX_CONTROL_PAYLOAD - 2);
- }
+ reason = reason.substring(0,WebSocketFrame.MAX_CONTROL_PAYLOAD - 2);
}
- LOG.debug("terminateConnection({},{})",statusCode,rawreason);
- session.close(statusCode,reason);
- }
- catch (IOException e)
- {
- LOG.debug(e);
}
+ LOG.debug("terminateConnection({},{})",statusCode,rawreason);
+ session.close(statusCode,reason);
}
@Override
diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/AbstractWebSocketConnection.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/AbstractWebSocketConnection.java
index 6549c33cf7..5e53e015a4 100644
--- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/AbstractWebSocketConnection.java
+++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/AbstractWebSocketConnection.java
@@ -80,13 +80,13 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
}
@Override
- public void close() throws IOException
+ public void close()
{
terminateConnection(StatusCode.NORMAL,null);
}
@Override
- public void close(int statusCode, String reason) throws IOException
+ public void close(int statusCode, String reason)
{
terminateConnection(statusCode,reason);
}
diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/FrameBytes.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/FrameBytes.java
index 58371b04af..0bd42b033e 100644
--- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/FrameBytes.java
+++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/FrameBytes.java
@@ -15,7 +15,6 @@
//========================================================================
package org.eclipse.jetty.websocket.io;
-import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.InterruptedByTimeoutException;
import java.util.concurrent.ScheduledFuture;
@@ -87,14 +86,7 @@ public abstract class FrameBytes<C> implements Callback<C>, Runnable
public void run()
{
// If this occurs we had a timeout!
- try
- {
- connection.close();
- }
- catch (IOException e)
- {
- LOG.ignore(e);
- }
+ connection.close();
failed(context, new InterruptedByTimeoutException());
}
diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/WebSocketSession.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/WebSocketSession.java
index 7ed264af69..fb9ad4b3db 100644
--- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/WebSocketSession.java
+++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/WebSocketSession.java
@@ -40,13 +40,13 @@ public class WebSocketSession implements WebSocketConnection, IncomingFrames, Ou
}
@Override
- public void close() throws IOException
+ public void close()
{
baseConnection.close();
}
@Override
- public void close(int statusCode, String reason) throws IOException
+ public void close(int statusCode, String reason)
{
baseConnection.close(statusCode,reason);
}
diff --git a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java
index 83653fbce7..40ba095bfc 100644
--- a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java
+++ b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java
@@ -145,14 +145,7 @@ public class WebSocketServerFactory extends AbstractLifeCycle implements WebSock
{
for (WebSocketSession session : sessions)
{
- try
- {
- session.close();
- }
- catch (IOException e)
- {
- LOG.warn("Unable to close session",e);
- }
+ session.close();
}
sessions.clear();
}

Back to the top