Author: remy.maucherat(a)jboss.com
Date: 2014-01-28 12:06:08 -0500 (Tue, 28 Jan 2014)
New Revision: 2357
Modified:
branches/7.4.x/src/main/java/org/apache/catalina/websocket/StreamInbound.java
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsHttpUpgradeHandler.java
Log:
Remove a number of setCCL since in web they are called from the regular servlet stack.
Modified: branches/7.4.x/src/main/java/org/apache/catalina/websocket/StreamInbound.java
===================================================================
---
branches/7.4.x/src/main/java/org/apache/catalina/websocket/StreamInbound.java 2014-01-23
16:06:23 UTC (rev 2356)
+++
branches/7.4.x/src/main/java/org/apache/catalina/websocket/StreamInbound.java 2014-01-28
17:06:08 UTC (rev 2357)
@@ -117,18 +117,18 @@
byte opCode = frame.getOpCode();
if (opCode == Constants.OPCODE_BINARY) {
- doOnBinaryData(wsIs);
+ onBinaryData(wsIs);
} else if (opCode == Constants.OPCODE_TEXT) {
InputStreamReader r =
new InputStreamReader(wsIs, new Utf8Decoder());
- doOnTextData(r);
+ onTextData(r);
} else if (opCode == Constants.OPCODE_CLOSE){
closeOutboundConnection(frame);
event.close();
} else if (opCode == Constants.OPCODE_PING) {
getWsOutbound().pong(frame.getPayLoad());
} else if (opCode == Constants.OPCODE_PONG) {
- doOnPong(frame.getPayLoad());
+ onPong(frame.getPayLoad());
} else {
// Unknown OpCode
closeOutboundConnection(
@@ -153,37 +153,11 @@
}
}
- private void doOnBinaryData(InputStream is) throws IOException {
- // Need to call onBinaryData using the web application's class loader
- Thread t = Thread.currentThread();
- ClassLoader cl = t.getContextClassLoader();
- t.setContextClassLoader(applicationClassLoader);
- try {
- onBinaryData(is);
- } finally {
- t.setContextClassLoader(cl);
- }
- }
-
-
- private void doOnTextData(Reader r) throws IOException {
- // Need to call onTextData using the web application's class loader
- Thread t = Thread.currentThread();
- ClassLoader cl = t.getContextClassLoader();
- t.setContextClassLoader(applicationClassLoader);
- try {
- onTextData(r);
- } finally {
- t.setContextClassLoader(cl);
- }
- }
-
-
private void closeOutboundConnection(int status, ByteBuffer data) throws IOException
{
try {
getWsOutbound().close(status, data);
} finally {
- doOnClose(status);
+ onClose(status);
}
}
@@ -191,7 +165,7 @@
try {
getWsOutbound().close(frame);
} finally {
- doOnClose(Constants.STATUS_CLOSE_NORMAL);
+ onClose(Constants.STATUS_CLOSE_NORMAL);
}
}
@@ -213,30 +187,10 @@
}
}
- private void doOnPong(ByteBuffer payload) {
- // Need to call onPong using the web application's class loader
- Thread t = Thread.currentThread();
- ClassLoader cl = t.getContextClassLoader();
- t.setContextClassLoader(applicationClassLoader);
- try {
- onPong(payload);
- } finally {
- t.setContextClassLoader(cl);
- }
- }
-
public final void onUpgradeComplete() {
outbound = new WsOutbound(event, this, outboundByteBufferSize,
outboundCharBufferSize);
- // Need to call onOpen using the web application's class loader
- Thread t = Thread.currentThread();
- ClassLoader cl = t.getContextClassLoader();
- t.setContextClassLoader(applicationClassLoader);
- try {
- onOpen(outbound);
- } finally {
- t.setContextClassLoader(cl);
- }
+ onOpen(outbound);
}
/**
Modified:
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsHttpUpgradeHandler.java
===================================================================
---
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsHttpUpgradeHandler.java 2014-01-23
16:06:23 UTC (rev 2356)
+++
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsHttpUpgradeHandler.java 2014-01-28
17:06:08 UTC (rev 2357)
@@ -44,8 +44,6 @@
*/
public class WsHttpUpgradeHandler implements HttpUpgradeHandler {
- private final ClassLoader applicationClassLoader;
-
private Endpoint ep;
private EndpointConfig endpointConfig;
private WsServerContainer webSocketContainer;
@@ -59,7 +57,6 @@
public WsHttpUpgradeHandler() {
- applicationClassLoader = Thread.currentThread().getContextClassLoader();
}
@@ -100,12 +97,6 @@
httpSessionId = ((HttpSession) session).getId();
}
- // Need to call onOpen using the web application's class loader
- // Create the frame using the application's class loader so it can pick
- // up application specific config from the ServerContainerImpl
- Thread t = Thread.currentThread();
- ClassLoader cl = t.getContextClassLoader();
- t.setContextClassLoader(applicationClassLoader);
try {
WsRemoteEndpointImplServer wsRemoteEndpointServer =
new WsRemoteEndpointImplServer(sos, webSocketContainer);
@@ -125,8 +116,6 @@
sis.setReadListener(new WsReadListener(this, wsFrame));
} catch (DeploymentException e) {
throw new IllegalArgumentException(e);
- } finally {
- t.setContextClassLoader(cl);
}
}
@@ -144,15 +133,7 @@
private void onError(Throwable throwable) {
- // Need to call onError using the web application's class loader
- Thread t = Thread.currentThread();
- ClassLoader cl = t.getContextClassLoader();
- t.setContextClassLoader(applicationClassLoader);
- try {
- ep.onError(wsSession, throwable);
- } finally {
- t.setContextClassLoader(cl);
- }
+ ep.onError(wsSession, throwable);
}
Show replies by date