JBossWeb SVN: r2299 - in branches/7.4.x/src/main/java/org: jboss/web and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2013-10-30 12:09:23 -0400 (Wed, 30 Oct 2013)
New Revision: 2299
Modified:
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/Constants.java
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsContextListener.java
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/WsRemoteEndpointImplServer.java
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsServerContainer.java
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsWriteTimeout.java
branches/7.4.x/src/main/java/org/jboss/web/WebsocketsMessages.java
Log:
- Port patch.
- Redo some threading, a number of operations need to be dispatched to other threads.
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/Constants.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/Constants.java 2013-10-29 18:33:11 UTC (rev 2298)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/Constants.java 2013-10-30 16:09:23 UTC (rev 2299)
@@ -31,6 +31,14 @@
public static final String ENFORCE_NO_ADD_AFTER_HANDSHAKE_CONTEXT_INIT_PARAM =
"org.apache.tomcat.websocket.noAddAfterHandshake";
+ // Executor configuration
+ public static final String EXECUTOR_CORE_SIZE_INIT_PARAM =
+ "org.apache.tomcat.websocket.executorCoreSize";
+ public static final String EXECUTOR_MAX_SIZE_INIT_PARAM =
+ "org.apache.tomcat.websocket.executorMaxSize";
+ public static final String EXECUTOR_KEEPALIVETIME_SECONDS_INIT_PARAM =
+ "org.apache.tomcat.websocket.executorKeepAliveTimeSeconds";
+
public static final String SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE =
"javax.websocket.server.ServerContainer";
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsContextListener.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsContextListener.java 2013-10-29 18:33:11 UTC (rev 2298)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsContextListener.java 2013-10-30 16:09:23 UTC (rev 2299)
@@ -45,6 +45,7 @@
ServletContext sc = sce.getServletContext();
Object obj = sc.getAttribute(Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);
if (obj instanceof WsServerContainer) {
+ ((WsServerContainer) obj).shutdownExecutor();
((WsServerContainer) obj).destroy();
}
}
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 2013-10-29 18:33:11 UTC (rev 2298)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsHttpUpgradeHandler.java 2013-10-30 16:09:23 UTC (rev 2299)
@@ -227,7 +227,9 @@
@Override
public void onWritePossible() {
- wsRemoteEndpointServer.onWritePossible();
+ // Triggered by the poller so this isn't the same thread that
+ // triggered the write so no need for a dispatch
+ wsRemoteEndpointServer.onWritePossible(false);
}
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java 2013-10-29 18:33:11 UTC (rev 2298)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsRemoteEndpointImplServer.java 2013-10-30 16:09:23 UTC (rev 2299)
@@ -20,6 +20,9 @@
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.nio.ByteBuffer;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ExecutorService;
import javax.websocket.SendHandler;
import javax.websocket.SendResult;
@@ -35,8 +38,12 @@
*/
public class WsRemoteEndpointImplServer extends WsRemoteEndpointImplBase {
+ private static final Queue<OnResultRunnable> onResultRunnables =
+ new ConcurrentLinkedQueue<OnResultRunnable>();
+
private final AbstractServletOutputStream sos;
private final WsWriteTimeout wsWriteTimeout;
+ private final ExecutorService executorService;
private volatile SendHandler handler = null;
private volatile ByteBuffer[] buffers = null;
@@ -48,6 +55,7 @@
WsServerContainer serverContainer) {
this.sos = sos;
this.wsWriteTimeout = serverContainer.getTimeout();
+ this.executorService = serverContainer.getExecutorService();
}
@@ -61,7 +69,9 @@
protected void doWrite(SendHandler handler, ByteBuffer... buffers) {
this.handler = handler;
this.buffers = buffers;
- onWritePossible();
+ // This is definitely the same thread that triggered the write so a
+ // dispatch will be required.
+ onWritePossible(true);
}
@@ -73,7 +83,7 @@
}
- public void onWritePossible() {
+ public void onWritePossible(boolean useDispatch) {
boolean complete = true;
try {
// If this is false there will be a call back when it is true
@@ -91,7 +101,7 @@
if (complete) {
timeoutExpiry = -1;
wsWriteTimeout.unregister(this);
- clearHandler(null);
+ clearHandler(null, useDispatch);
// Explicit flush for compatibility with buffered streams
sos.flush();
if (close) {
@@ -103,7 +113,7 @@
} catch (IOException ioe) {
wsWriteTimeout.unregister(this);
- clearHandler(ioe);
+ clearHandler(ioe, useDispatch);
close();
}
if (!complete) {
@@ -122,7 +132,11 @@
@Override
protected void doClose() {
if (handler != null) {
- clearHandler(new EOFException());
+ // close() can be triggered by a wide range of scenarios. It is far
+ // simpler just to always use a dispatch that it is to try and track
+ // whether or not this method was called by the same thread that
+ // triggered the write
+ clearHandler(new EOFException(), true);
}
try {
sos.close();
@@ -138,15 +152,31 @@
}
- protected void onTimeout() {
+ /*
+ * Currently this is only called from the background thread so we could just
+ * call clearHandler() with useDispatch == false but the method parameter
+ * was added in case other callers started to use this method to make sure
+ * that those callers think through what the correct value of useDispatch is
+ * for them.
+ */
+ protected void onTimeout(boolean useDispatch) {
if (handler != null) {
- clearHandler(new SocketTimeoutException());
+ clearHandler(new SocketTimeoutException(), useDispatch);
}
close();
}
- private void clearHandler(Throwable t) {
+ /**
+ *
+ * @param t The throwable associated with any error that
+ * occurred
+ * @param useDispatch Should {@link SendHandler#onResult(SendResult)} be
+ * called from a new thread, keeping in mind the
+ * requirements of
+ * {@link javax.websocket.RemoteEndpoint.Async}
+ */
+ private void clearHandler(Throwable t, boolean useDispatch) {
// Setting the result marks this (partial) message as
// complete which means the next one may be sent which
// could update the value of the handler. Therefore, keep a
@@ -155,11 +185,64 @@
SendHandler sh = handler;
handler = null;
if (sh != null) {
+ if (useDispatch) {
+ OnResultRunnable r = onResultRunnables.poll();
+ if (r == null) {
+ r = new OnResultRunnable(onResultRunnables);
+ }
+ r.init(sh, t);
+ if (executorService == null || executorService.isShutdown()) {
+ // Can't use the executor so call the runnable directly.
+ // This may not be strictly specification compliant in all
+ // cases but during shutdown only close messages are going
+ // to be sent so there should not be the issue of nested
+ // calls leading to stack overflow as described in bug
+ // 55715. The issues with nested calls was the reason for
+ // the separate thread requirement in the specification.
+ r.run();
+ } else {
+ executorService.execute(r);
+ }
+ } else {
+ if (t == null) {
+ sh.onResult(new SendResult());
+ } else {
+ sh.onResult(new SendResult(t));
+ }
+ }
+ }
+ }
+
+
+ private static class OnResultRunnable implements Runnable {
+
+ private final Queue<OnResultRunnable> queue;
+
+ private volatile SendHandler sh;
+ private volatile Throwable t;
+
+ private OnResultRunnable(Queue<OnResultRunnable> queue) {
+ this.queue = queue;
+ }
+
+ private void init(SendHandler sh, Throwable t) {
+ this.sh = sh;
+ this.t = t;
+ }
+
+ @Override
+ public void run() {
if (t == null) {
sh.onResult(new SendResult());
} else {
sh.onResult(new SendResult(t));
}
+ t = null;
+ sh = null;
+ // Return the Runnable to the queue when it has been finished with
+ // Note if this method takes an age to finish there shouldn't be any
+ // thread safety issues as the fields are cleared above.
+ queue.add(this);
}
}
}
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsServerContainer.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsServerContainer.java 2013-10-29 18:33:11 UTC (rev 2298)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsServerContainer.java 2013-10-30 16:09:23 UTC (rev 2299)
@@ -28,6 +28,12 @@
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
import javax.servlet.DispatcherType;
import javax.servlet.FilterRegistration;
@@ -64,9 +70,7 @@
implements ServerContainer {
private static final CloseReason AUTHENTICATED_HTTP_SESSION_CLOSED =
- new CloseReason(CloseCodes.VIOLATED_POLICY,
- "This connection was established under an authenticated " +
- "HTTP session that has ended.");
+ new CloseReason(CloseCodes.VIOLATED_POLICY, MESSAGES.expiredHttpSession());
private final WsWriteTimeout wsWriteTimeout = new WsWriteTimeout();
@@ -80,6 +84,7 @@
private volatile boolean addAllowed = true;
private final ConcurrentHashMap<String,Set<WsSession>> authenticatedSessions =
new ConcurrentHashMap<String, Set<WsSession>>();
+ private final ExecutorService executorService;
WsServerContainer(ServletContext servletContext) {
@@ -103,6 +108,25 @@
if (value != null) {
setEnforceNoAddAfterHandshake(Boolean.parseBoolean(value));
}
+ // Executor config
+ int executorCoreSize = 0;
+ int executorMaxSize = 10;
+ long executorKeepAliveTimeSeconds = 60;
+ value = servletContext.getInitParameter(
+ Constants.EXECUTOR_CORE_SIZE_INIT_PARAM);
+ if (value != null) {
+ executorCoreSize = Integer.parseInt(value);
+ }
+ value = servletContext.getInitParameter(
+ Constants.EXECUTOR_MAX_SIZE_INIT_PARAM);
+ if (value != null) {
+ executorMaxSize = Integer.parseInt(value);
+ }
+ value = servletContext.getInitParameter(
+ Constants.EXECUTOR_KEEPALIVETIME_SECONDS_INIT_PARAM);
+ if (value != null) {
+ executorKeepAliveTimeSeconds = Long.parseLong(value);
+ }
FilterRegistration.Dynamic fr = servletContext.addFilter(
WsFilter.class.getName(), new WsFilter());
@@ -112,6 +136,22 @@
DispatcherType.FORWARD);
fr.addMappingForUrlPatterns(types, true, "/*");
+
+ // Use a per web application executor for any threads the the WebSocket
+ // server code needs to create. Group all of the threads under a single
+ // ThreadGroup.
+ StringBuffer threadGroupName = new StringBuffer("WebSocketServer-");
+ if ("".equals(servletContext.getContextPath())) {
+ threadGroupName.append("ROOT");
+ } else {
+ threadGroupName.append(servletContext.getContextPath());
+ }
+ ThreadGroup threadGroup = new ThreadGroup(threadGroupName.toString());
+ WsThreadFactory wsThreadFactory = new WsThreadFactory(threadGroup);
+
+ executorService = new ThreadPoolExecutor(executorCoreSize,
+ executorMaxSize, executorKeepAliveTimeSeconds, TimeUnit.SECONDS,
+ new LinkedBlockingQueue<Runnable>(), wsThreadFactory);
}
@@ -372,6 +412,21 @@
}
}
+
+ ExecutorService getExecutorService() {
+ return executorService;
+ }
+
+
+ void shutdownExecutor() {
+ executorService.shutdown();
+ try {
+ executorService.awaitTermination(10, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ // Ignore the interruption and carry on
+ }
+ }
+
private static void validateEncoders(Class<? extends Encoder>[] encoders)
throws DeploymentException {
@@ -436,4 +491,21 @@
tpm2.getUriTemplate().getNormalizedPath());
}
}
+
+ private static class WsThreadFactory implements ThreadFactory {
+
+ private final ThreadGroup tg;
+ private final AtomicLong count = new AtomicLong(0);
+
+ private WsThreadFactory(ThreadGroup tg) {
+ this.tg = tg;
+ }
+
+ @Override
+ public Thread newThread(Runnable r) {
+ Thread t = new Thread(tg, r);
+ t.setName(tg.getName() + "-" + count.incrementAndGet());
+ return t;
+ }
+ }
}
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsWriteTimeout.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsWriteTimeout.java 2013-10-29 18:33:11 UTC (rev 2298)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsWriteTimeout.java 2013-10-30 16:09:23 UTC (rev 2299)
@@ -52,7 +52,9 @@
while (iter.hasNext()) {
WsRemoteEndpointImplServer endpoint = iter.next();
if (endpoint.getTimeoutExpiry() < now) {
- endpoint.onTimeout();
+ // Background thread, not the thread that triggered the
+ // write so no need to use a dispatch
+ endpoint.onTimeout(false);
} else {
// Endpoints are ordered by timeout expiry so if this point
// is reached there is no need to check the remaining
Modified: branches/7.4.x/src/main/java/org/jboss/web/WebsocketsMessages.java
===================================================================
--- branches/7.4.x/src/main/java/org/jboss/web/WebsocketsMessages.java 2013-10-29 18:33:11 UTC (rev 2298)
+++ branches/7.4.x/src/main/java/org/jboss/web/WebsocketsMessages.java 2013-10-30 16:09:23 UTC (rev 2299)
@@ -296,4 +296,7 @@
@Message(id = 8586, value = "Upgrade failed")
String upgradeFailed();
+ @Message(id = 8587, value = "This connection was established under an authenticated HTTP session that has ended")
+ String expiredHttpSession();
+
}
11 years, 1 month
JBossWeb SVN: r2298 - branches/7.4.x/src/main/java/org/apache/tomcat/util/net/jsse.
by jbossweb-commits@lists.jboss.org
Author: dehort
Date: 2013-10-29 14:33:11 -0400 (Tue, 29 Oct 2013)
New Revision: 2298
Modified:
branches/7.4.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESupport.java
Log:
bz-1024481 - JBossWeb memory leak when using SSL + Java security manager
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESupport.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESupport.java 2013-10-29 18:28:00 UTC (rev 2297)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESupport.java 2013-10-29 18:33:11 UTC (rev 2298)
@@ -25,6 +25,8 @@
import java.net.SocketException;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
+import java.util.Map;
+import java.util.WeakHashMap;
import javax.net.ssl.HandshakeCompletedEvent;
import javax.net.ssl.HandshakeCompletedListener;
@@ -57,6 +59,9 @@
protected SSLSocket ssl;
protected SSLSession session;
+ private static final Map<SSLSession, Integer> keySizeCache =
+ new WeakHashMap<SSLSession, Integer>(10);
+
Listener listener = new Listener();
JSSESupport(SSLSocket sock){
@@ -200,7 +205,7 @@
SSLSupport.CipherData c_aux[]=ciphers;
if (session == null)
return null;
- Integer keySize = (Integer) session.getValue(Constants.KEY_SIZE_KEY);
+ Integer keySize = (Integer) keySizeCache.get(session);
if (keySize == null) {
int size = 0;
String cipherSuite = session.getCipherSuite();
@@ -211,7 +216,7 @@
}
}
keySize = new Integer(size);
- session.putValue(Constants.KEY_SIZE_KEY, keySize);
+ keySizeCache.put(session, keySize);
}
return keySize;
}
11 years, 1 month
JBossWeb SVN: r2297 - branches/7.3.x/src/main/java/org/apache/tomcat/util/net/jsse.
by jbossweb-commits@lists.jboss.org
Author: dehort
Date: 2013-10-29 14:28:00 -0400 (Tue, 29 Oct 2013)
New Revision: 2297
Modified:
branches/7.3.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESupport.java
Log:
bz-1024481 - JBossWeb memory leak when using SSL + Java security manager
Modified: branches/7.3.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESupport.java
===================================================================
--- branches/7.3.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESupport.java 2013-10-29 18:06:11 UTC (rev 2296)
+++ branches/7.3.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESupport.java 2013-10-29 18:28:00 UTC (rev 2297)
@@ -25,6 +25,8 @@
import java.net.SocketException;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
+import java.util.Map;
+import java.util.WeakHashMap;
import javax.net.ssl.HandshakeCompletedEvent;
import javax.net.ssl.HandshakeCompletedListener;
@@ -57,6 +59,9 @@
protected SSLSocket ssl;
protected SSLSession session;
+ private static final Map<SSLSession, Integer> keySizeCache =
+ new WeakHashMap<SSLSession, Integer>(10);
+
Listener listener = new Listener();
JSSESupport(SSLSocket sock){
@@ -200,7 +205,7 @@
SSLSupport.CipherData c_aux[]=ciphers;
if (session == null)
return null;
- Integer keySize = (Integer) session.getValue(Constants.KEY_SIZE_KEY);
+ Integer keySize = (Integer) keySizeCache.get(session);
if (keySize == null) {
int size = 0;
String cipherSuite = session.getCipherSuite();
@@ -211,7 +216,7 @@
}
}
keySize = new Integer(size);
- session.putValue(Constants.KEY_SIZE_KEY, keySize);
+ keySizeCache.put(session, keySize);
}
return keySize;
}
11 years, 1 month
JBossWeb SVN: r2296 - branches/2.1.x/java/org/apache/tomcat/util/net/jsse.
by jbossweb-commits@lists.jboss.org
Author: dehort
Date: 2013-10-29 14:06:11 -0400 (Tue, 29 Oct 2013)
New Revision: 2296
Modified:
branches/2.1.x/java/org/apache/tomcat/util/net/jsse/JSSESupport.java
Log:
JBPAPP-10895 - JBossWeb memory leak with using SSL + Java security manager
Modified: branches/2.1.x/java/org/apache/tomcat/util/net/jsse/JSSESupport.java
===================================================================
--- branches/2.1.x/java/org/apache/tomcat/util/net/jsse/JSSESupport.java 2013-10-28 13:12:01 UTC (rev 2295)
+++ branches/2.1.x/java/org/apache/tomcat/util/net/jsse/JSSESupport.java 2013-10-29 18:06:11 UTC (rev 2296)
@@ -23,6 +23,8 @@
import java.net.SocketException;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
+import java.util.Map;
+import java.util.WeakHashMap;
import javax.net.ssl.HandshakeCompletedEvent;
import javax.net.ssl.HandshakeCompletedListener;
@@ -52,6 +54,8 @@
private static org.jboss.logging.Logger log =
org.jboss.logging.Logger.getLogger(JSSESupport.class);
+ private static final Map<SSLSession, Integer> keySizeCache =
+ new WeakHashMap<SSLSession, Integer>(10);
protected SSLSocket ssl;
protected SSLSession session;
@@ -195,7 +199,7 @@
SSLSupport.CipherData c_aux[]=ciphers;
if (session == null)
return null;
- Integer keySize = (Integer) session.getValue(KEY_SIZE_KEY);
+ Integer keySize = (Integer) keySizeCache.get(session);
if (keySize == null) {
int size = 0;
String cipherSuite = session.getCipherSuite();
@@ -206,7 +210,7 @@
}
}
keySize = new Integer(size);
- session.putValue(KEY_SIZE_KEY, keySize);
+ keySizeCache.put(session, keySize);
}
return keySize;
}
11 years, 1 month
JBossWeb SVN: r2295 - branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2013-10-28 09:12:01 -0400 (Mon, 28 Oct 2013)
New Revision: 2295
Added:
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsPerSessionServerEndpointConfig.java
Modified:
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/UpgradeUtil.java
Log:
Port patch adding per session view of user properties.
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/UpgradeUtil.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/UpgradeUtil.java 2013-10-25 20:46:37 UTC (rev 2294)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/UpgradeUtil.java 2013-10-28 13:12:01 UTC (rev 2295)
@@ -164,7 +164,10 @@
WsHandshakeRequest wsRequest = new WsHandshakeRequest(req);
WsHandshakeResponse wsResponse = new WsHandshakeResponse();
- sec.getConfigurator().modifyHandshake(sec, wsRequest, wsResponse);
+ WsPerSessionServerEndpointConfig perSessionServerEndpointConfig =
+ new WsPerSessionServerEndpointConfig(sec);
+ sec.getConfigurator().modifyHandshake(perSessionServerEndpointConfig,
+ wsRequest, wsResponse);
wsRequest.finished();
// Add any additional headers
@@ -184,8 +187,8 @@
if (inner instanceof RequestFacade) {
WsHttpUpgradeHandler wsHandler =
((RequestFacade) inner).upgrade(WsHttpUpgradeHandler.class);
- wsHandler.preInit(ep, sec, sc, wsRequest, subProtocol,
- pathParams, req.isSecure());
+ wsHandler.preInit(ep, perSessionServerEndpointConfig, sc, wsRequest,
+ subProtocol, pathParams, req.isSecure());
} else {
throw new ServletException(MESSAGES.upgradeFailed());
}
Added: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsPerSessionServerEndpointConfig.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsPerSessionServerEndpointConfig.java (rev 0)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsPerSessionServerEndpointConfig.java 2013-10-28 13:12:01 UTC (rev 2295)
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.websocket.server;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.websocket.Decoder;
+import javax.websocket.Encoder;
+import javax.websocket.Extension;
+import javax.websocket.server.ServerEndpointConfig;
+
+/**
+ * Wraps the provided {@link ServerEndpointConfig} and provides a per session
+ * view - the difference being that the map returned by {@link
+ * #getUserProperties()} is unique to this instance rather than shared with the
+ * wrapped {@link ServerEndpointConfig}.
+ */
+class WsPerSessionServerEndpointConfig implements ServerEndpointConfig {
+
+ private final ServerEndpointConfig perEndpointConfig;
+ private final Map<String,Object> perSessionUserProperties =
+ new ConcurrentHashMap<String,Object>();
+
+ WsPerSessionServerEndpointConfig(ServerEndpointConfig perEndpointConfig) {
+ this.perEndpointConfig = perEndpointConfig;
+ perSessionUserProperties.putAll(perEndpointConfig.getUserProperties());
+ }
+
+ @Override
+ public List<Class<? extends Encoder>> getEncoders() {
+ return perEndpointConfig.getEncoders();
+ }
+
+ @Override
+ public List<Class<? extends Decoder>> getDecoders() {
+ return perEndpointConfig.getDecoders();
+ }
+
+ @Override
+ public Map<String,Object> getUserProperties() {
+ return perSessionUserProperties;
+ }
+
+ @Override
+ public Class<?> getEndpointClass() {
+ return perEndpointConfig.getEndpointClass();
+ }
+
+ @Override
+ public String getPath() {
+ return perEndpointConfig.getPath();
+ }
+
+ @Override
+ public List<String> getSubprotocols() {
+ return perEndpointConfig.getSubprotocols();
+ }
+
+ @Override
+ public List<Extension> getExtensions() {
+ return perEndpointConfig.getExtensions();
+ }
+
+ @Override
+ public Configurator getConfigurator() {
+ return perEndpointConfig.getConfigurator();
+ }
+}
11 years, 1 month
JBossWeb SVN: r2294 - in branches/JBOSSWEB_2_1_12_GA_patch03_JBPAPP-10891: java/org/apache/jasper/runtime and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: aogburn
Date: 2013-10-25 16:46:37 -0400 (Fri, 25 Oct 2013)
New Revision: 2294
Modified:
branches/JBOSSWEB_2_1_12_GA_patch03_JBPAPP-10891/build.xml
branches/JBOSSWEB_2_1_12_GA_patch03_JBPAPP-10891/java/org/apache/jasper/runtime/PageContextImpl.java
Log:
[JBPAPP-10891] commit JBWEB-284 one-off fix
Modified: branches/JBOSSWEB_2_1_12_GA_patch03_JBPAPP-10891/build.xml
===================================================================
--- branches/JBOSSWEB_2_1_12_GA_patch03_JBPAPP-10891/build.xml 2013-10-25 19:55:25 UTC (rev 2293)
+++ branches/JBOSSWEB_2_1_12_GA_patch03_JBPAPP-10891/build.xml 2013-10-25 20:46:37 UTC (rev 2294)
@@ -843,7 +843,7 @@
<target name="build-jasper-jdt-src">
<jar destfile="${jasper-jdt-src.jar}" index="true">
- <fileset dir="${jasper-jdt-src.home}/src/plugins/org.eclipse.jdt.core/model">
+<fileset dir="${jasper-jdt-src.home}/plugins/org.eclipse.jdt.core/model">
<include name="org/eclipse/jdt/core/compiler/**"/>
<include name="org/eclipse/jdt/internal/compiler/**"/>
<include name="org/eclipse/jdt/internal/core/util/CommentRecorder*"/>
Modified: branches/JBOSSWEB_2_1_12_GA_patch03_JBPAPP-10891/java/org/apache/jasper/runtime/PageContextImpl.java
===================================================================
--- branches/JBOSSWEB_2_1_12_GA_patch03_JBPAPP-10891/java/org/apache/jasper/runtime/PageContextImpl.java 2013-10-25 19:55:25 UTC (rev 2293)
+++ branches/JBOSSWEB_2_1_12_GA_patch03_JBPAPP-10891/java/org/apache/jasper/runtime/PageContextImpl.java 2013-10-25 20:46:37 UTC (rev 2294)
@@ -421,8 +421,13 @@
return REQUEST_SCOPE;
if (session != null) {
- if (session.getAttribute(name) != null)
- return SESSION_SCOPE;
+ try {
+ if (session.getAttribute(name) != null)
+ return SESSION_SCOPE;
+ } catch(IllegalStateException ise) {
+ // Session has been invalidated.
+ // Ignore and fall through to application scope.
+ }
}
if (context.getAttribute(name) != null)
@@ -464,7 +469,12 @@
return o;
if (session != null) {
- o = session.getAttribute(name);
+ try {
+ o = session.getAttribute(name);
+ } catch(IllegalStateException ise) {
+ // Session has been invalidated.
+ // Ignore and fall through to application scope.
+ }
if (o != null)
return o;
}
@@ -528,17 +538,17 @@
}
private void doRemoveAttribute(String name) {
- try {
- removeAttribute(name, PAGE_SCOPE);
- removeAttribute(name, REQUEST_SCOPE);
- if (session != null) {
- removeAttribute(name, SESSION_SCOPE);
- }
- removeAttribute(name, APPLICATION_SCOPE);
- } catch (Exception ex) {
- // we remove as much as we can, and
- // simply ignore possible exceptions
- }
+ removeAttribute(name, PAGE_SCOPE);
+ removeAttribute(name, REQUEST_SCOPE);
+ if( session != null ) {
+ try {
+ removeAttribute(name, SESSION_SCOPE);
+ } catch(IllegalStateException ise) {
+ // Session has been invalidated.
+ // Ignore and fall throw to application scope.
+ }
+ }
+ removeAttribute(name, APPLICATION_SCOPE);
}
public JspWriter getOut() {
Property changes on: branches/JBOSSWEB_2_1_12_GA_patch03_JBPAPP-10891/java/org/apache/jasper/runtime/PageContextImpl.java
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/2.1.x/java/org/apache/jasper/runtime/PageContextImpl.java:2292
/trunk/java/org/apache/jasper/runtime/PageContextImpl.java:1009
11 years, 1 month
JBossWeb SVN: r2293 - branches.
by jbossweb-commits@lists.jboss.org
Author: aogburn
Date: 2013-10-25 15:55:25 -0400 (Fri, 25 Oct 2013)
New Revision: 2293
Added:
branches/JBOSSWEB_2_1_12_GA_patch03_JBPAPP-10891/
Log:
[JBPAPP-10891] create one-off branch
11 years, 1 month
JBossWeb SVN: r2292 - branches/2.1.x/java/org/apache/jasper/runtime.
by jbossweb-commits@lists.jboss.org
Author: aogburn
Date: 2013-10-25 15:40:22 -0400 (Fri, 25 Oct 2013)
New Revision: 2292
Modified:
branches/2.1.x/java/org/apache/jasper/runtime/PageContextImpl.java
Log:
[JBWEB-284] backport fix for PageContextImpl IllegalStateException
Modified: branches/2.1.x/java/org/apache/jasper/runtime/PageContextImpl.java
===================================================================
--- branches/2.1.x/java/org/apache/jasper/runtime/PageContextImpl.java 2013-10-24 04:02:52 UTC (rev 2291)
+++ branches/2.1.x/java/org/apache/jasper/runtime/PageContextImpl.java 2013-10-25 19:40:22 UTC (rev 2292)
@@ -421,8 +421,13 @@
return REQUEST_SCOPE;
if (session != null) {
- if (session.getAttribute(name) != null)
- return SESSION_SCOPE;
+ try {
+ if (session.getAttribute(name) != null)
+ return SESSION_SCOPE;
+ } catch(IllegalStateException ise) {
+ // Session has been invalidated.
+ // Ignore and fall through to application scope.
+ }
}
if (context.getAttribute(name) != null)
@@ -464,7 +469,12 @@
return o;
if (session != null) {
- o = session.getAttribute(name);
+ try {
+ o = session.getAttribute(name);
+ } catch(IllegalStateException ise) {
+ // Session has been invalidated.
+ // Ignore and fall through to application scope.
+ }
if (o != null)
return o;
}
@@ -528,17 +538,17 @@
}
private void doRemoveAttribute(String name) {
- try {
- removeAttribute(name, PAGE_SCOPE);
- removeAttribute(name, REQUEST_SCOPE);
- if (session != null) {
- removeAttribute(name, SESSION_SCOPE);
- }
- removeAttribute(name, APPLICATION_SCOPE);
- } catch (Exception ex) {
- // we remove as much as we can, and
- // simply ignore possible exceptions
- }
+ removeAttribute(name, PAGE_SCOPE);
+ removeAttribute(name, REQUEST_SCOPE);
+ if( session != null ) {
+ try {
+ removeAttribute(name, SESSION_SCOPE);
+ } catch(IllegalStateException ise) {
+ // Session has been invalidated.
+ // Ignore and fall throw to application scope.
+ }
+ }
+ removeAttribute(name, APPLICATION_SCOPE);
}
public JspWriter getOut() {
Property changes on: branches/2.1.x/java/org/apache/jasper/runtime/PageContextImpl.java
___________________________________________________________________
Added: svn:mergeinfo
+ /trunk/java/org/apache/jasper/runtime/PageContextImpl.java:1009
11 years, 1 month
JBossWeb SVN: r2291 - branches/JBOSSWEB_7_0_17_FINAL_BZ-1022777/java/org/apache/catalina/security.
by jbossweb-commits@lists.jboss.org
Author: aogburn
Date: 2013-10-24 00:02:52 -0400 (Thu, 24 Oct 2013)
New Revision: 2291
Modified:
branches/JBOSSWEB_7_0_17_FINAL_BZ-1022777/java/org/apache/catalina/security/SecurityUtil.java
Log:
[BZ-1022777] commit back-port fix
Modified: branches/JBOSSWEB_7_0_17_FINAL_BZ-1022777/java/org/apache/catalina/security/SecurityUtil.java
===================================================================
--- branches/JBOSSWEB_7_0_17_FINAL_BZ-1022777/java/org/apache/catalina/security/SecurityUtil.java 2013-10-24 03:14:36 UTC (rev 2290)
+++ branches/JBOSSWEB_7_0_17_FINAL_BZ-1022777/java/org/apache/catalina/security/SecurityUtil.java 2013-10-24 04:02:52 UTC (rev 2291)
@@ -23,7 +23,8 @@
import java.security.Principal;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
-import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import javax.security.auth.Subject;
import javax.servlet.Filter;
@@ -66,8 +67,8 @@
/**
* Cache every object for which we are creating method on it.
*/
- private static HashMap<Object,Method[]> objectCache =
- new HashMap<Object,Method[]>();
+ private static Map<Object,Method[]> objectCache =
+ new ConcurrentHashMap<Object,Method[]>();
private static org.jboss.logging.Logger log=
org.jboss.logging.Logger.getLogger( SecurityUtil.class );
11 years, 2 months
JBossWeb SVN: r2290 - branches.
by jbossweb-commits@lists.jboss.org
Author: aogburn
Date: 2013-10-23 23:14:36 -0400 (Wed, 23 Oct 2013)
New Revision: 2290
Added:
branches/JBOSSWEB_7_0_17_FINAL_BZ-1022777/
Log:
[BZ-1022777] create one-off branch
11 years, 2 months