JBossWeb SVN: r2333 - tags/JBOSSWEB_2_1_14_GA.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2013-12-20 08:46:07 -0500 (Fri, 20 Dec 2013)
New Revision: 2333
Modified:
tags/JBOSSWEB_2_1_14_GA/build.properties.default
Log:
Web 2.1.14.
Modified: tags/JBOSSWEB_2_1_14_GA/build.properties.default
===================================================================
--- tags/JBOSSWEB_2_1_14_GA/build.properties.default 2013-12-20 13:40:21 UTC (rev 2332)
+++ tags/JBOSSWEB_2_1_14_GA/build.properties.default 2013-12-20 13:46:07 UTC (rev 2333)
@@ -12,9 +12,9 @@
# ----- Version Control Flags -----
version.major=2
version.minor=1
-version.build=12
+version.build=14
version.patch=0
-version.tag=SNAPSHOT
+version.tag=GA
# ----- Default Base Path for Dependent Packages -----
# Please note this path must be absolute, not relative,
11 years
JBossWeb SVN: r2332 - tags.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2013-12-20 08:40:21 -0500 (Fri, 20 Dec 2013)
New Revision: 2332
Added:
tags/JBOSSWEB_2_1_14_GA/
Log:
Web 2.1.14.
11 years
JBossWeb SVN: r2331 - 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-12-19 08:09:03 -0500 (Thu, 19 Dec 2013)
New Revision: 2331
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/WsFilter.java
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsServerContainer.java
Log:
Drop the broken lazy init in favor of a simple flag to indicate if websockets is used.
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-12-17 14:08:02 UTC (rev 2330)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/UpgradeUtil.java 2013-12-19 13:09:03 UTC (rev 2331)
@@ -69,7 +69,7 @@
* WebSocket spec 1.0, section 8.2 implies such a limitation and RFC
* 6455 section 4.1 requires that a WebSocket Upgrade uses GET.
*/
- public static boolean isWebSocketUpgrageRequest(ServletRequest request,
+ public static boolean isWebSocketUpgradeRequest(ServletRequest request,
ServletResponse response) {
return ((request instanceof HttpServletRequest) &&
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsFilter.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsFilter.java 2013-12-17 14:08:02 UTC (rev 2330)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsFilter.java 2013-12-19 13:09:03 UTC (rev 2331)
@@ -47,7 +47,8 @@
FilterChain chain) throws IOException, ServletException {
// This filter only needs to handle WebSocket upgrade requests
- if (!UpgradeUtil.isWebSocketUpgrageRequest(request, response)) {
+ if (!sc.areEndpointsRegistered() ||
+ !UpgradeUtil.isWebSocketUpgradeRequest(request, response)) {
chain.doFilter(request, response);
return;
}
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-12-17 14:08:02 UTC (rev 2330)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsServerContainer.java 2013-12-19 13:09:03 UTC (rev 2331)
@@ -84,89 +84,74 @@
private volatile boolean addAllowed = true;
private final ConcurrentHashMap<String,Set<WsSession>> authenticatedSessions =
new ConcurrentHashMap<String, Set<WsSession>>();
- private ExecutorService executorService;
- private volatile boolean initialized = false;
+ private final ExecutorService executorService;
+ private volatile boolean endpointsRegistered = false;
WsServerContainer(ServletContext servletContext) {
this.servletContext = servletContext;
- }
- private void init() {
+ // Configure servlet context wide defaults
+ String value = servletContext.getInitParameter(
+ Constants.BINARY_BUFFER_SIZE_SERVLET_CONTEXT_INIT_PARAM);
+ if (value != null) {
+ setDefaultMaxBinaryMessageBufferSize(Integer.parseInt(value));
+ }
- // Double checked locking. This is safe since Java > 1.5 and initialized
- // is volatile
- if (initialized) {
- return;
+ value = servletContext.getInitParameter(
+ Constants.TEXT_BUFFER_SIZE_SERVLET_CONTEXT_INIT_PARAM);
+ if (value != null) {
+ setDefaultMaxTextMessageBufferSize(Integer.parseInt(value));
}
- synchronized (this) {
- if (initialized) {
- return;
- }
- initialized = true;
- // Configure servlet context wide defaults
- String value = servletContext.getInitParameter(
- Constants.BINARY_BUFFER_SIZE_SERVLET_CONTEXT_INIT_PARAM);
- if (value != null) {
- setDefaultMaxBinaryMessageBufferSize(Integer.parseInt(value));
- }
+ value = servletContext.getInitParameter(
+ Constants.ENFORCE_NO_ADD_AFTER_HANDSHAKE_CONTEXT_INIT_PARAM);
+ 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);
+ }
- value = servletContext.getInitParameter(
- Constants.TEXT_BUFFER_SIZE_SERVLET_CONTEXT_INIT_PARAM);
- if (value != null) {
- setDefaultMaxTextMessageBufferSize(Integer.parseInt(value));
- }
+ FilterRegistration.Dynamic fr = servletContext.addFilter(
+ "Tomcat WebSocket (JSR356) Filter", new WsFilter());
+ fr.setAsyncSupported(true);
- value = servletContext.getInitParameter(
- Constants.ENFORCE_NO_ADD_AFTER_HANDSHAKE_CONTEXT_INIT_PARAM);
- 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);
- }
+ EnumSet<DispatcherType> types = EnumSet.of(DispatcherType.REQUEST,
+ DispatcherType.FORWARD);
- FilterRegistration.Dynamic fr = servletContext.addFilter(
- "Tomcat WebSocket (JSR356) Filter", new WsFilter());
- fr.setAsyncSupported(true);
+ fr.addMappingForUrlPatterns(types, true, "/*");
- EnumSet<DispatcherType> types = EnumSet.of(DispatcherType.REQUEST,
- 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);
+ // 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);
}
@@ -182,8 +167,6 @@
public void addEndpoint(ServerEndpointConfig sec)
throws DeploymentException {
- init();
-
if (enforceNoAddAfterHandshake && !addAllowed) {
throw new DeploymentException(MESSAGES.addNotAllowed());
}
@@ -218,6 +201,8 @@
throw new DeploymentException(MESSAGES.duplicatePaths(path));
}
}
+
+ endpointsRegistered = true;
}
@@ -231,8 +216,6 @@
@Override
public void addEndpoint(Class<?> pojo) throws DeploymentException {
- init();
-
ServerEndpoint annotation = pojo.getAnnotation(ServerEndpoint.class);
if (annotation == null) {
throw new DeploymentException(MESSAGES.cannotDeployPojo(pojo.getName()));
@@ -276,6 +259,11 @@
}
+ boolean areEndpointsRegistered() {
+ return endpointsRegistered;
+ }
+
+
public void doUpgrade(HttpServletRequest request,
HttpServletResponse response, ServerEndpointConfig sec,
Map<String,String> pathParams)
11 years
JBossWeb SVN: r2330 - in branches/7.4.x/src/main/java/org: apache/tomcat/websocket/pojo and 2 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2013-12-17 09:08:02 -0500 (Tue, 17 Dec 2013)
New Revision: 2330
Modified:
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsFrameBase.java
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java
branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsServerContainer.java
branches/7.4.x/src/main/java/org/jboss/web/WebsocketsMessages.java
Log:
Port websockets patches.
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsFrameBase.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsFrameBase.java 2013-12-16 17:06:36 UTC (rev 2329)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/WsFrameBase.java 2013-12-17 14:08:02 UTC (rev 2330)
@@ -265,9 +265,17 @@
if (Util.isControl(opCode)) {
result = processDataControl();
} else if (textMessage) {
- result = processDataText();
+ if (textMsgHandler == null) {
+ result = swallowInput();
+ } else {
+ result = processDataText();
+ }
} else {
- result = processDataBinary();
+ if (binaryMsgHandler == null) {
+ result = swallowInput();
+ } else {
+ result = processDataBinary();
+ }
}
checkRoomPayload();
return result;
@@ -342,33 +350,31 @@
@SuppressWarnings("unchecked")
private void sendMessageText(boolean last) throws WsIOException {
- if (textMsgHandler != null) {
- if (textMsgHandler instanceof WrappedMessageHandler) {
- long maxMessageSize =
- ((WrappedMessageHandler) textMsgHandler).getMaxMessageSize();
- if (maxMessageSize > -1 &&
- messageBufferText.remaining() > maxMessageSize) {
- throw new WsIOException(new CloseReason(CloseCodes.TOO_BIG,
- MESSAGES.messageTooLarge(Long.valueOf(messageBufferText.remaining()),
- Long.valueOf(maxMessageSize))));
- }
+ if (textMsgHandler instanceof WrappedMessageHandler) {
+ long maxMessageSize =
+ ((WrappedMessageHandler) textMsgHandler).getMaxMessageSize();
+ if (maxMessageSize > -1 &&
+ messageBufferText.remaining() > maxMessageSize) {
+ throw new WsIOException(new CloseReason(CloseCodes.TOO_BIG,
+ MESSAGES.messageTooLarge(Long.valueOf(messageBufferText.remaining()),
+ Long.valueOf(maxMessageSize))));
}
+ }
- try {
- if (textMsgHandler instanceof MessageHandler.Partial<?>) {
- ((MessageHandler.Partial<String>) textMsgHandler).onMessage(
- messageBufferText.toString(), last);
- } else {
- // Caller ensures last == true if this branch is used
- ((MessageHandler.Whole<String>) textMsgHandler).onMessage(
- messageBufferText.toString());
- }
- } catch (Throwable t) {
- ExceptionUtils.handleThrowable(t);
- wsSession.getLocal().onError(wsSession, t);
- } finally {
- messageBufferText.clear();
+ try {
+ if (textMsgHandler instanceof MessageHandler.Partial<?>) {
+ ((MessageHandler.Partial<String>) textMsgHandler).onMessage(
+ messageBufferText.toString(), last);
+ } else {
+ // Caller ensures last == true if this branch is used
+ ((MessageHandler.Whole<String>) textMsgHandler).onMessage(
+ messageBufferText.toString());
}
+ } catch (Throwable t) {
+ ExceptionUtils.handleThrowable(t);
+ wsSession.getLocal().onError(wsSession, t);
+ } finally {
+ messageBufferText.clear();
}
}
@@ -522,28 +528,26 @@
@SuppressWarnings("unchecked")
private void sendMessageBinary(ByteBuffer msg, boolean last)
throws WsIOException {
- if (binaryMsgHandler != null) {
- if (binaryMsgHandler instanceof WrappedMessageHandler) {
- long maxMessageSize =
- ((WrappedMessageHandler) binaryMsgHandler).getMaxMessageSize();
- if (maxMessageSize > -1 && msg.remaining() > maxMessageSize) {
- throw new WsIOException(new CloseReason(CloseCodes.TOO_BIG,
- MESSAGES.messageTooLarge(
- Long.valueOf(msg.remaining()),
- Long.valueOf(maxMessageSize))));
- }
+ if (binaryMsgHandler instanceof WrappedMessageHandler) {
+ long maxMessageSize =
+ ((WrappedMessageHandler) binaryMsgHandler).getMaxMessageSize();
+ if (maxMessageSize > -1 && msg.remaining() > maxMessageSize) {
+ throw new WsIOException(new CloseReason(CloseCodes.TOO_BIG,
+ MESSAGES.messageTooLarge(
+ Long.valueOf(msg.remaining()),
+ Long.valueOf(maxMessageSize))));
}
- try {
- if (binaryMsgHandler instanceof MessageHandler.Partial<?>) {
- ((MessageHandler.Partial<ByteBuffer>) binaryMsgHandler).onMessage(msg, last);
- } else {
- // Caller ensures last == true if this branch is used
- ((MessageHandler.Whole<ByteBuffer>) binaryMsgHandler).onMessage(msg);
- }
- } catch(Throwable t) {
- ExceptionUtils.handleThrowable(t);
- wsSession.getLocal().onError(wsSession, t);
+ }
+ try {
+ if (binaryMsgHandler instanceof MessageHandler.Partial<?>) {
+ ((MessageHandler.Partial<ByteBuffer>) binaryMsgHandler).onMessage(msg, last);
+ } else {
+ // Caller ensures last == true if this branch is used
+ ((MessageHandler.Whole<ByteBuffer>) binaryMsgHandler).onMessage(msg);
}
+ } catch(Throwable t) {
+ ExceptionUtils.handleThrowable(t);
+ wsSession.getLocal().onError(wsSession, t);
}
}
@@ -603,16 +607,10 @@
if (Util.isControl(opCode)) {
return false;
} else if (textMessage) {
- if (textMsgHandler != null) {
- return textMsgHandler instanceof MessageHandler.Partial<?>;
- }
- return false;
+ return textMsgHandler instanceof MessageHandler.Partial<?>;
} else {
// Must be binary
- if (binaryMsgHandler != null) {
- return binaryMsgHandler instanceof MessageHandler.Partial<?>;
- }
- return false;
+ return binaryMsgHandler instanceof MessageHandler.Partial<?>;
}
}
@@ -645,6 +643,23 @@
}
+ private boolean swallowInput() {
+ long toSkip = Math.min(payloadLength - payloadWritten, writePos - readPos);
+ readPos += toSkip;
+ payloadWritten += toSkip;
+ if (payloadWritten == payloadLength) {
+ if (continuationExpected) {
+ newFrame();
+ } else {
+ newMessage();
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
protected static long byteArrayToLong(byte[] b, int start, int len)
throws IOException {
if (len > 8) {
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java 2013-12-16 17:06:36 UTC (rev 2329)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeBinary.java 2013-12-17 14:08:02 UTC (rev 2330)
@@ -49,6 +49,15 @@
boolean isForInputStream, long maxMessageSize) {
super(pojo, method, session, params, indexPayload, convert,
indexSession, maxMessageSize);
+
+ // Update binary text size handled by session
+ if (maxMessageSize > -1 && maxMessageSize > session.getMaxBinaryMessageBufferSize()) {
+ if (maxMessageSize > Integer.MAX_VALUE) {
+ throw MESSAGES.messageTooLarge();
+ }
+ session.setMaxBinaryMessageBufferSize((int) maxMessageSize);
+ }
+
try {
if (decoderClazzes != null) {
for (Class<? extends Decoder> decoderClazz : decoderClazzes) {
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java 2013-12-16 17:06:36 UTC (rev 2329)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/pojo/PojoMessageHandlerWholeText.java 2013-12-17 14:08:02 UTC (rev 2330)
@@ -51,6 +51,14 @@
super(pojo, method, session, params, indexPayload, convert,
indexSession, maxMessageSize);
+ // Update max text size handled by session
+ if (maxMessageSize > -1 && maxMessageSize > session.getMaxTextMessageBufferSize()) {
+ if (maxMessageSize > Integer.MAX_VALUE) {
+ throw MESSAGES.messageTooLarge();
+ }
+ session.setMaxTextMessageBufferSize((int) maxMessageSize);
+ }
+
// Check for primitives
Class<?> type = method.getParameterTypes()[indexPayload];
if (Util.isPrimitive(type)) {
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-12-16 17:06:36 UTC (rev 2329)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsServerContainer.java 2013-12-17 14:08:02 UTC (rev 2330)
@@ -84,74 +84,89 @@
private volatile boolean addAllowed = true;
private final ConcurrentHashMap<String,Set<WsSession>> authenticatedSessions =
new ConcurrentHashMap<String, Set<WsSession>>();
- private final ExecutorService executorService;
+ private ExecutorService executorService;
+ private volatile boolean initialized = false;
WsServerContainer(ServletContext servletContext) {
-
this.servletContext = servletContext;
+ }
- // Configure servlet context wide defaults
- String value = servletContext.getInitParameter(
- Constants.BINARY_BUFFER_SIZE_SERVLET_CONTEXT_INIT_PARAM);
- if (value != null) {
- setDefaultMaxBinaryMessageBufferSize(Integer.parseInt(value));
- }
+ private void init() {
- value = servletContext.getInitParameter(
- Constants.TEXT_BUFFER_SIZE_SERVLET_CONTEXT_INIT_PARAM);
- if (value != null) {
- setDefaultMaxTextMessageBufferSize(Integer.parseInt(value));
+ // Double checked locking. This is safe since Java > 1.5 and initialized
+ // is volatile
+ if (initialized) {
+ return;
}
+ synchronized (this) {
+ if (initialized) {
+ return;
+ }
+ initialized = true;
- value = servletContext.getInitParameter(
- Constants.ENFORCE_NO_ADD_AFTER_HANDSHAKE_CONTEXT_INIT_PARAM);
- 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);
- }
+ // Configure servlet context wide defaults
+ String value = servletContext.getInitParameter(
+ Constants.BINARY_BUFFER_SIZE_SERVLET_CONTEXT_INIT_PARAM);
+ if (value != null) {
+ setDefaultMaxBinaryMessageBufferSize(Integer.parseInt(value));
+ }
- FilterRegistration.Dynamic fr = servletContext.addFilter(
- "Tomcat WebSocket (JSR356) Filter", new WsFilter());
- fr.setAsyncSupported(true);
+ value = servletContext.getInitParameter(
+ Constants.TEXT_BUFFER_SIZE_SERVLET_CONTEXT_INIT_PARAM);
+ if (value != null) {
+ setDefaultMaxTextMessageBufferSize(Integer.parseInt(value));
+ }
- EnumSet<DispatcherType> types = EnumSet.of(DispatcherType.REQUEST,
- DispatcherType.FORWARD);
+ value = servletContext.getInitParameter(
+ Constants.ENFORCE_NO_ADD_AFTER_HANDSHAKE_CONTEXT_INIT_PARAM);
+ 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);
+ }
- fr.addMappingForUrlPatterns(types, true, "/*");
+ FilterRegistration.Dynamic fr = servletContext.addFilter(
+ "Tomcat WebSocket (JSR356) Filter", new WsFilter());
+ fr.setAsyncSupported(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());
+ EnumSet<DispatcherType> types = EnumSet.of(DispatcherType.REQUEST,
+ 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);
}
- ThreadGroup threadGroup = new ThreadGroup(threadGroupName.toString());
- WsThreadFactory wsThreadFactory = new WsThreadFactory(threadGroup);
-
- executorService = new ThreadPoolExecutor(executorCoreSize,
- executorMaxSize, executorKeepAliveTimeSeconds, TimeUnit.SECONDS,
- new LinkedBlockingQueue<Runnable>(), wsThreadFactory);
}
@@ -167,6 +182,8 @@
public void addEndpoint(ServerEndpointConfig sec)
throws DeploymentException {
+ init();
+
if (enforceNoAddAfterHandshake && !addAllowed) {
throw new DeploymentException(MESSAGES.addNotAllowed());
}
@@ -214,6 +231,8 @@
@Override
public void addEndpoint(Class<?> pojo) throws DeploymentException {
+ init();
+
ServerEndpoint annotation = pojo.getAnnotation(ServerEndpoint.class);
if (annotation == null) {
throw new DeploymentException(MESSAGES.cannotDeployPojo(pojo.getName()));
@@ -422,6 +441,9 @@
void shutdownExecutor() {
+ if (executorService == null) {
+ return;
+ }
executorService.shutdown();
try {
executorService.awaitTermination(10, TimeUnit.SECONDS);
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-12-16 17:06:36 UTC (rev 2329)
+++ branches/7.4.x/src/main/java/org/jboss/web/WebsocketsMessages.java 2013-12-17 14:08:02 UTC (rev 2330)
@@ -302,4 +302,7 @@
@Message(id = 8588, value = "The remainder of the message will not be sent because the WebSocket session has been closed")
String messageRemainderSessionClosed();
+ @Message(id = 8589, value = "The maximum supported message size for this implementation is Integer.MAX_VALUE")
+ IllegalArgumentException messageTooLarge();
+
}
11 years
JBossWeb SVN: r2329 - in branches: 7.2.x/src/main/java/org/apache/catalina/connector and 2 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2013-12-16 12:06:36 -0500 (Mon, 16 Dec 2013)
New Revision: 2329
Modified:
branches/7.2.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java
branches/7.2.x/src/main/java/org/apache/catalina/connector/InputBuffer.java
branches/7.2.x/src/main/java/org/apache/catalina/connector/Request.java
branches/7.3.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java
branches/7.3.x/src/main/java/org/apache/catalina/connector/InputBuffer.java
branches/7.3.x/src/main/java/org/apache/catalina/connector/Request.java
Log:
BZ 1030050: Sync FORM fixes with 7.4 for saving request body when using FORM.
Modified: branches/7.2.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java 2013-12-12 14:22:33 UTC (rev 2328)
+++ branches/7.2.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java 2013-12-16 17:06:36 UTC (rev 2329)
@@ -300,6 +300,7 @@
// the landing page
String uri = request.getContextPath() + landingPage;
SavedRequest saved = new SavedRequest();
+ saved.setMethod("GET");
saved.setRequestURI(uri);
saved.setDecodedRequestURI(uri);
request.getSessionInternal(true).setNote(
@@ -330,6 +331,7 @@
// the landing page
String uri = request.getContextPath() + landingPage;
SavedRequest saved = new SavedRequest();
+ saved.setMethod("GET");
saved.setRequestURI(uri);
saved.setDecodedRequestURI(uri);
session.setNote(Constants.FORM_REQUEST_NOTE, saved);
@@ -366,6 +368,10 @@
request.changeSessionId(session.getId());
}
}
+ // Always use GET for the login page, regardless of the method used
+ String oldMethod = request.getMethod();
+ request.getCoyoteRequest().method().setString("GET");
+
RequestDispatcher disp =
context.getServletContext().getRequestDispatcher(config.getLoginPage());
try {
@@ -376,6 +382,9 @@
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
msg);
+ } finally {
+ // Restore original method so that it is written into access log
+ request.getCoyoteRequest().method().setString(oldMethod);
}
}
@@ -459,6 +468,16 @@
if (saved == null)
return (false);
+ // Swallow any request body since we will be replacing it
+ // Need to do this before headers are restored as AJP connector uses
+ // content length header to determine how much data needs to be read for
+ // request body
+ byte[] buffer = new byte[4096];
+ InputStream is = request.createInputStream();
+ while (is.read(buffer) >= 0) {
+ // Ignore request body
+ }
+
// Modify our current request to reflect the original one
request.clearCookies();
Iterator cookies = saved.getCookies();
@@ -466,10 +485,11 @@
request.addCookie((Cookie) cookies.next());
}
+ String method = saved.getMethod();
MimeHeaders rmh = request.getCoyoteRequest().getMimeHeaders();
rmh.recycle();
- boolean cachable = "GET".equalsIgnoreCase(saved.getMethod()) ||
- "HEAD".equalsIgnoreCase(saved.getMethod());
+ boolean cachable = "GET".equalsIgnoreCase(method) ||
+ "HEAD".equalsIgnoreCase(method);
Iterator names = saved.getHeaderNames();
while (names.hasNext()) {
String name = (String) names.next();
@@ -495,45 +515,31 @@
request.getCoyoteRequest().getParameters().setQueryStringEncoding(request.getConnector().getURIEncoding());
- // Swallow any request body since we will be replacing it
- byte[] buffer = new byte[4096];
- InputStream is = request.getInputStream();
- while (is.read(buffer) >= 0) {
- // Ignore request body
- }
+ ByteChunk body = saved.getBody();
- if ("POST".equalsIgnoreCase(saved.getMethod())) {
- ByteChunk body = saved.getBody();
-
- if (body != null && body.getLength() > 0) {
- request.clearParameters();
- request.getCoyoteRequest().action
- (ActionCode.ACTION_REQ_SET_BODY_REPLAY, body);
-
- // Set content type
- MessageBytes contentType = MessageBytes.newInstance();
-
- //If no content type specified, use default for POST
- String savedContentType = saved.getContentType();
- if (savedContentType == null) {
- savedContentType = "application/x-www-form-urlencoded";
- }
+ if (body != null) {
+ request.resetBody();
+ request.getCoyoteRequest().action(ActionCode.ACTION_REQ_SET_BODY_REPLAY, body);
+ // Set content type
+ MessageBytes contentType = MessageBytes.newInstance();
+ //If no content type specified, use default for POST
+ String savedContentType = saved.getContentType();
+ if (savedContentType == null && "POST".equalsIgnoreCase(method)) {
+ savedContentType = "application/x-www-form-urlencoded";
+ }
+ contentType.setString(savedContentType);
+ request.getCoyoteRequest().setContentType(contentType);
+ } else {
+ // Restore the parameters.
+ Iterator params = saved.getParameterNames();
+ while (params.hasNext()) {
+ String name = (String) params.next();
+ request.addParameter(name,
+ saved.getParameterValues(name));
+ }
- contentType.setString(savedContentType);
- request.getCoyoteRequest().setContentType(contentType);
-
- } else {
- // Restore the parameters.
- Iterator params = saved.getParameterNames();
- while (params.hasNext()) {
- String name = (String) params.next();
- request.addParameter(name,
- saved.getParameterValues(name));
- }
-
- }
}
- request.getCoyoteRequest().method().setString(saved.getMethod());
+ request.getCoyoteRequest().method().setString(method);
request.getCoyoteRequest().queryString().setString
(saved.getQueryString());
@@ -577,30 +583,29 @@
saved.addLocale(locale);
}
- if ("POST".equalsIgnoreCase(request.getMethod())) {
- // May need to acknowledge a 100-continue expectation
- request.getResponse().sendAcknowledgement();
- ByteChunk body = new ByteChunk();
- body.setLimit(request.getConnector().getMaxSavePostSize());
+ // May need to acknowledge a 100-continue expectation
+ request.getResponse().sendAcknowledgement();
+ ByteChunk body = new ByteChunk();
+ body.setLimit(request.getConnector().getMaxSavePostSize());
- byte[] buffer = new byte[4096];
- int bytesRead;
- InputStream is = request.getInputStream();
-
- while ( (bytesRead = is.read(buffer) ) >= 0) {
- body.append(buffer, 0, bytesRead);
- }
+ byte[] buffer = new byte[4096];
+ int bytesRead;
+ InputStream is = request.getInputStream();
+
+ while ( (bytesRead = is.read(buffer) ) >= 0) {
+ body.append(buffer, 0, bytesRead);
+ }
+ if (body.getLength() > 0) {
saved.setContentType(request.getContentType());
saved.setBody(body);
-
- if (body.getLength() == 0) {
- // It means that parameters have already been parsed.
- Enumeration e = request.getParameterNames();
- for ( ; e.hasMoreElements() ;) {
- String name = (String) e.nextElement();
- String[] val = request.getParameterValues(name);
- saved.addParameter(name, val);
- }
+ }
+ if (body.getLength() == 0) {
+ // It means that parameters have already been parsed.
+ Enumeration e = request.getParameterNames();
+ for ( ; e.hasMoreElements() ;) {
+ String name = (String) e.nextElement();
+ String[] val = request.getParameterValues(name);
+ saved.addParameter(name, val);
}
}
Modified: branches/7.2.x/src/main/java/org/apache/catalina/connector/InputBuffer.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/connector/InputBuffer.java 2013-12-12 14:22:33 UTC (rev 2328)
+++ branches/7.2.x/src/main/java/org/apache/catalina/connector/InputBuffer.java 2013-12-16 17:06:36 UTC (rev 2329)
@@ -268,6 +268,14 @@
}
+ /**
+ * Reset the eof state.
+ */
+ public void resetEof() {
+ eof= false;
+ }
+
+
public int available() {
if (eof || closed) {
return -1;
Modified: branches/7.2.x/src/main/java/org/apache/catalina/connector/Request.java
===================================================================
--- branches/7.2.x/src/main/java/org/apache/catalina/connector/Request.java 2013-12-12 14:22:33 UTC (rev 2328)
+++ branches/7.2.x/src/main/java/org/apache/catalina/connector/Request.java 2013-12-16 17:06:36 UTC (rev 2329)
@@ -607,8 +607,7 @@
/**
* Return true if the EOF has been reached.
*/
- public boolean isEof()
- throws IOException {
+ public boolean isEof() {
return (inputBuffer.isEof());
}
@@ -1856,8 +1855,9 @@
/**
* Clear the collection of parameters associated with this Request.
*/
- public void clearParameters() {
+ public void resetBody() {
parametersParsed = false;
+ inputBuffer.resetEof();
}
Modified: branches/7.3.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java
===================================================================
--- branches/7.3.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java 2013-12-12 14:22:33 UTC (rev 2328)
+++ branches/7.3.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java 2013-12-16 17:06:36 UTC (rev 2329)
@@ -300,6 +300,7 @@
// the landing page
String uri = request.getContextPath() + landingPage;
SavedRequest saved = new SavedRequest();
+ saved.setMethod("GET");
saved.setRequestURI(uri);
saved.setDecodedRequestURI(uri);
request.getSessionInternal(true).setNote(
@@ -330,6 +331,7 @@
// the landing page
String uri = request.getContextPath() + landingPage;
SavedRequest saved = new SavedRequest();
+ saved.setMethod("GET");
saved.setRequestURI(uri);
saved.setDecodedRequestURI(uri);
session.setNote(Constants.FORM_REQUEST_NOTE, saved);
@@ -366,6 +368,10 @@
request.changeSessionId(session.getId());
}
}
+ // Always use GET for the login page, regardless of the method used
+ String oldMethod = request.getMethod();
+ request.getCoyoteRequest().method().setString("GET");
+
RequestDispatcher disp =
context.getServletContext().getRequestDispatcher(config.getLoginPage());
try {
@@ -376,6 +382,9 @@
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
msg);
+ } finally {
+ // Restore original method so that it is written into access log
+ request.getCoyoteRequest().method().setString(oldMethod);
}
}
@@ -459,6 +468,16 @@
if (saved == null)
return (false);
+ // Swallow any request body since we will be replacing it
+ // Need to do this before headers are restored as AJP connector uses
+ // content length header to determine how much data needs to be read for
+ // request body
+ byte[] buffer = new byte[4096];
+ InputStream is = request.createInputStream();
+ while (is.read(buffer) >= 0) {
+ // Ignore request body
+ }
+
// Modify our current request to reflect the original one
request.clearCookies();
Iterator cookies = saved.getCookies();
@@ -466,10 +485,11 @@
request.addCookie((Cookie) cookies.next());
}
+ String method = saved.getMethod();
MimeHeaders rmh = request.getCoyoteRequest().getMimeHeaders();
rmh.recycle();
- boolean cachable = "GET".equalsIgnoreCase(saved.getMethod()) ||
- "HEAD".equalsIgnoreCase(saved.getMethod());
+ boolean cachable = "GET".equalsIgnoreCase(method) ||
+ "HEAD".equalsIgnoreCase(method);
Iterator names = saved.getHeaderNames();
while (names.hasNext()) {
String name = (String) names.next();
@@ -495,45 +515,31 @@
request.getCoyoteRequest().getParameters().setQueryStringEncoding(request.getConnector().getURIEncoding());
- // Swallow any request body since we will be replacing it
- byte[] buffer = new byte[4096];
- InputStream is = request.getInputStream();
- while (is.read(buffer) >= 0) {
- // Ignore request body
- }
+ ByteChunk body = saved.getBody();
- if ("POST".equalsIgnoreCase(saved.getMethod())) {
- ByteChunk body = saved.getBody();
-
- if (body != null && body.getLength() > 0) {
- request.clearParameters();
- request.getCoyoteRequest().action
- (ActionCode.ACTION_REQ_SET_BODY_REPLAY, body);
-
- // Set content type
- MessageBytes contentType = MessageBytes.newInstance();
-
- //If no content type specified, use default for POST
- String savedContentType = saved.getContentType();
- if (savedContentType == null) {
- savedContentType = "application/x-www-form-urlencoded";
- }
+ if (body != null) {
+ request.resetBody();
+ request.getCoyoteRequest().action(ActionCode.ACTION_REQ_SET_BODY_REPLAY, body);
+ // Set content type
+ MessageBytes contentType = MessageBytes.newInstance();
+ //If no content type specified, use default for POST
+ String savedContentType = saved.getContentType();
+ if (savedContentType == null && "POST".equalsIgnoreCase(method)) {
+ savedContentType = "application/x-www-form-urlencoded";
+ }
+ contentType.setString(savedContentType);
+ request.getCoyoteRequest().setContentType(contentType);
+ } else {
+ // Restore the parameters.
+ Iterator params = saved.getParameterNames();
+ while (params.hasNext()) {
+ String name = (String) params.next();
+ request.addParameter(name,
+ saved.getParameterValues(name));
+ }
- contentType.setString(savedContentType);
- request.getCoyoteRequest().setContentType(contentType);
-
- } else {
- // Restore the parameters.
- Iterator params = saved.getParameterNames();
- while (params.hasNext()) {
- String name = (String) params.next();
- request.addParameter(name,
- saved.getParameterValues(name));
- }
-
- }
}
- request.getCoyoteRequest().method().setString(saved.getMethod());
+ request.getCoyoteRequest().method().setString(method);
request.getCoyoteRequest().queryString().setString
(saved.getQueryString());
@@ -577,30 +583,29 @@
saved.addLocale(locale);
}
- if ("POST".equalsIgnoreCase(request.getMethod())) {
- // May need to acknowledge a 100-continue expectation
- request.getResponse().sendAcknowledgement();
- ByteChunk body = new ByteChunk();
- body.setLimit(request.getConnector().getMaxSavePostSize());
+ // May need to acknowledge a 100-continue expectation
+ request.getResponse().sendAcknowledgement();
+ ByteChunk body = new ByteChunk();
+ body.setLimit(request.getConnector().getMaxSavePostSize());
- byte[] buffer = new byte[4096];
- int bytesRead;
- InputStream is = request.getInputStream();
-
- while ( (bytesRead = is.read(buffer) ) >= 0) {
- body.append(buffer, 0, bytesRead);
- }
+ byte[] buffer = new byte[4096];
+ int bytesRead;
+ InputStream is = request.getInputStream();
+
+ while ( (bytesRead = is.read(buffer) ) >= 0) {
+ body.append(buffer, 0, bytesRead);
+ }
+ if (body.getLength() > 0) {
saved.setContentType(request.getContentType());
saved.setBody(body);
-
- if (body.getLength() == 0) {
- // It means that parameters have already been parsed.
- Enumeration e = request.getParameterNames();
- for ( ; e.hasMoreElements() ;) {
- String name = (String) e.nextElement();
- String[] val = request.getParameterValues(name);
- saved.addParameter(name, val);
- }
+ }
+ if (body.getLength() == 0) {
+ // It means that parameters have already been parsed.
+ Enumeration e = request.getParameterNames();
+ for ( ; e.hasMoreElements() ;) {
+ String name = (String) e.nextElement();
+ String[] val = request.getParameterValues(name);
+ saved.addParameter(name, val);
}
}
Modified: branches/7.3.x/src/main/java/org/apache/catalina/connector/InputBuffer.java
===================================================================
--- branches/7.3.x/src/main/java/org/apache/catalina/connector/InputBuffer.java 2013-12-12 14:22:33 UTC (rev 2328)
+++ branches/7.3.x/src/main/java/org/apache/catalina/connector/InputBuffer.java 2013-12-16 17:06:36 UTC (rev 2329)
@@ -268,6 +268,14 @@
}
+ /**
+ * Reset the eof state.
+ */
+ public void resetEof() {
+ eof= false;
+ }
+
+
public int available() {
if (eof || closed) {
return -1;
Modified: branches/7.3.x/src/main/java/org/apache/catalina/connector/Request.java
===================================================================
--- branches/7.3.x/src/main/java/org/apache/catalina/connector/Request.java 2013-12-12 14:22:33 UTC (rev 2328)
+++ branches/7.3.x/src/main/java/org/apache/catalina/connector/Request.java 2013-12-16 17:06:36 UTC (rev 2329)
@@ -607,8 +607,7 @@
/**
* Return true if the EOF has been reached.
*/
- public boolean isEof()
- throws IOException {
+ public boolean isEof() {
return (inputBuffer.isEof());
}
@@ -1856,8 +1855,9 @@
/**
* Clear the collection of parameters associated with this Request.
*/
- public void clearParameters() {
+ public void resetBody() {
parametersParsed = false;
+ inputBuffer.resetEof();
}
11 years
JBossWeb SVN: r2328 - 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-12-12 09:22:33 -0500 (Thu, 12 Dec 2013)
New Revision: 2328
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/WsServerContainer.java
Log:
Port patches: Fix possible NPE on destroy. Update filter name.
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-12-12 14:14:59 UTC (rev 2327)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsHttpUpgradeHandler.java 2013-12-12 14:22:33 UTC (rev 2328)
@@ -133,10 +133,12 @@
@Override
public void destroy() {
- try {
- connection.close();
- } catch (Exception e) {
- WebsocketsLogger.ROOT_LOGGER.destroyFailed(e);
+ if (connection != null) {
+ try {
+ connection.close();
+ } catch (Exception e) {
+ WebsocketsLogger.ROOT_LOGGER.destroyFailed(e);
+ }
}
}
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-12-12 14:14:59 UTC (rev 2327)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/websocket/server/WsServerContainer.java 2013-12-12 14:22:33 UTC (rev 2328)
@@ -129,7 +129,7 @@
}
FilterRegistration.Dynamic fr = servletContext.addFilter(
- WsFilter.class.getName(), new WsFilter());
+ "Tomcat WebSocket (JSR356) Filter", new WsFilter());
fr.setAsyncSupported(true);
EnumSet<DispatcherType> types = EnumSet.of(DispatcherType.REQUEST,
11 years
JBossWeb SVN: r2327 - in branches/7.4.x/src/main/java/org/apache/catalina: connector and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2013-12-12 09:14:59 -0500 (Thu, 12 Dec 2013)
New Revision: 2327
Modified:
branches/7.4.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java
branches/7.4.x/src/main/java/org/apache/catalina/connector/InputBuffer.java
branches/7.4.x/src/main/java/org/apache/catalina/connector/Request.java
Log:
Reset the (kinda new) EOF flag when restoring the request body.
Modified: branches/7.4.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java 2013-12-10 17:43:48 UTC (rev 2326)
+++ branches/7.4.x/src/main/java/org/apache/catalina/authenticator/FormAuthenticator.java 2013-12-12 14:14:59 UTC (rev 2327)
@@ -518,22 +518,17 @@
ByteChunk body = saved.getBody();
if (body != null) {
- request.clearParameters();
- request.getCoyoteRequest().action
- (ActionCode.ACTION_REQ_SET_BODY_REPLAY, body);
-
+ request.resetBody();
+ request.getCoyoteRequest().action(ActionCode.ACTION_REQ_SET_BODY_REPLAY, body);
// Set content type
MessageBytes contentType = MessageBytes.newInstance();
-
//If no content type specified, use default for POST
String savedContentType = saved.getContentType();
if (savedContentType == null && "POST".equalsIgnoreCase(method)) {
savedContentType = "application/x-www-form-urlencoded";
}
-
contentType.setString(savedContentType);
request.getCoyoteRequest().setContentType(contentType);
-
} else {
// Restore the parameters.
Iterator params = saved.getParameterNames();
Modified: branches/7.4.x/src/main/java/org/apache/catalina/connector/InputBuffer.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/catalina/connector/InputBuffer.java 2013-12-10 17:43:48 UTC (rev 2326)
+++ branches/7.4.x/src/main/java/org/apache/catalina/connector/InputBuffer.java 2013-12-12 14:14:59 UTC (rev 2327)
@@ -276,6 +276,14 @@
}
+ /**
+ * Reset the eof state.
+ */
+ public void resetEof() {
+ eof = false;
+ }
+
+
public int available() {
if (eof || closed) {
return -1;
Modified: branches/7.4.x/src/main/java/org/apache/catalina/connector/Request.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/catalina/connector/Request.java 2013-12-10 17:43:48 UTC (rev 2326)
+++ branches/7.4.x/src/main/java/org/apache/catalina/connector/Request.java 2013-12-12 14:14:59 UTC (rev 2327)
@@ -627,8 +627,7 @@
/**
* Return true if the EOF has been reached.
*/
- public boolean isEof()
- throws IOException {
+ public boolean isEof() {
return (inputBuffer.isEof());
}
@@ -1876,8 +1875,9 @@
/**
* Clear the collection of parameters associated with this Request.
*/
- public void clearParameters() {
+ public void resetBody() {
parametersParsed = false;
+ inputBuffer.resetEof();
}
11 years
JBossWeb SVN: r2326 - branches/7.4.x/src/main/java/org/apache/coyote/http11.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2013-12-10 12:43:48 -0500 (Tue, 10 Dec 2013)
New Revision: 2326
Modified:
branches/7.4.x/src/main/java/org/apache/coyote/http11/AbstractInternalInputBuffer.java
branches/7.4.x/src/main/java/org/apache/coyote/http11/Constants.java
branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalInputBuffer.java
branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalOutputBuffer.java
Log:
Some (basic) constant cleanups and removal of old unused code.
Modified: branches/7.4.x/src/main/java/org/apache/coyote/http11/AbstractInternalInputBuffer.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/coyote/http11/AbstractInternalInputBuffer.java 2013-12-10 17:41:35 UTC (rev 2325)
+++ branches/7.4.x/src/main/java/org/apache/coyote/http11/AbstractInternalInputBuffer.java 2013-12-10 17:43:48 UTC (rev 2326)
@@ -119,15 +119,6 @@
* Create a new instance of {@code AbstractInternalInputBuffer}
*
* @param request
- */
- public AbstractInternalInputBuffer(Request request) {
- this(request, Constants.DEFAULT_HTTP_HEADER_BUFFER_SIZE);
- }
-
- /**
- * Create a new instance of {@code AbstractInternalInputBuffer}
- *
- * @param request
* @param headerBufferSize
*/
public AbstractInternalInputBuffer(Request request, int headerBufferSize) {
Modified: branches/7.4.x/src/main/java/org/apache/coyote/http11/Constants.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/coyote/http11/Constants.java 2013-12-10 17:41:35 UTC (rev 2325)
+++ branches/7.4.x/src/main/java/org/apache/coyote/http11/Constants.java 2013-12-10 17:43:48 UTC (rev 2326)
@@ -126,13 +126,6 @@
/**
- * Default HTTP header buffer size.
- */
- public static final int DEFAULT_HTTP_HEADER_BUFFER_SIZE =
- Integer.valueOf(System.getProperty("org.apache.coyote.http11.DEFAULT_HTTP_HEADER_BUFFER_SIZE", "8192")).intValue();
-
-
- /**
* Async buffer size.
*/
public static final int ASYNC_BUFFER_SIZE =
Modified: branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalInputBuffer.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalInputBuffer.java 2013-12-10 17:41:35 UTC (rev 2325)
+++ branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalInputBuffer.java 2013-12-10 17:43:48 UTC (rev 2326)
@@ -47,14 +47,6 @@
/**
- * Default constructor.
- */
- public InternalInputBuffer(Request request) {
- this(request, Constants.DEFAULT_HTTP_HEADER_BUFFER_SIZE);
- }
-
-
- /**
* Alternate constructor.
*/
public InternalInputBuffer(Request request, int headerBufferSize) {
Modified: branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalNioOutputBuffer.java 2013-12-10 17:41:35 UTC (rev 2325)
+++ branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalNioOutputBuffer.java 2013-12-10 17:43:48 UTC (rev 2326)
@@ -155,11 +155,7 @@
this.response = response;
this.headers = response.getMimeHeaders();
buf = new byte[headerBufferSize];
- if (headerBufferSize < Constants.DEFAULT_HTTP_HEADER_BUFFER_SIZE) {
- bbuf = ByteBuffer.allocateDirect(6 * 1500);
- } else {
- bbuf = ByteBuffer.allocateDirect((headerBufferSize / 1500 + 1) * 1500);
- }
+ bbuf = ByteBuffer.allocateDirect(headerBufferSize);
outputBuffer = new OutputBufferImpl();
filterLibrary = new OutputFilter[0];
Modified: branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalOutputBuffer.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalOutputBuffer.java 2013-12-10 17:41:35 UTC (rev 2325)
+++ branches/7.4.x/src/main/java/org/apache/coyote/http11/InternalOutputBuffer.java 2013-12-10 17:43:48 UTC (rev 2326)
@@ -47,14 +47,6 @@
/**
- * Default constructor.
- */
- public InternalOutputBuffer(Response response) {
- this(response, Constants.DEFAULT_HTTP_HEADER_BUFFER_SIZE);
- }
-
-
- /**
* Alternate constructor.
*/
public InternalOutputBuffer(Response response, int headerBufferSize) {
11 years
JBossWeb SVN: r2325 - branches/7.4.x/src/main/java/org/apache/coyote/http11.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2013-12-10 12:41:35 -0500 (Tue, 10 Dec 2013)
New Revision: 2325
Modified:
branches/7.4.x/src/main/java/org/apache/coyote/http11/Http11AbstractProtocol.java
Log:
Add the configuration system properties used in the other HTTP connectors.
Modified: branches/7.4.x/src/main/java/org/apache/coyote/http11/Http11AbstractProtocol.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/coyote/http11/Http11AbstractProtocol.java 2013-12-09 16:20:20 UTC (rev 2324)
+++ branches/7.4.x/src/main/java/org/apache/coyote/http11/Http11AbstractProtocol.java 2013-12-10 17:41:35 UTC (rev 2325)
@@ -72,7 +72,7 @@
/**
* Maximum size of the HTTP message header.
*/
- protected int maxHttpHeaderSize = 8 * 1024;
+ protected int maxHttpHeaderSize = Integer.valueOf(System.getProperty("org.apache.coyote.http11.Http11Protocol.MAX_HEADER_SIZE", "8192")).intValue();
/**
* If true, the regular socket timeout will be used for the full duration of
* the connection.
@@ -81,10 +81,10 @@
/**
* Integrated compression support.
*/
- protected String compression = "off";
- protected String noCompressionUserAgents = null;
- protected String compressableMimeTypes = "text/html,text/xml,text/plain";
- protected int compressionMinSize = 2048;
+ protected String compression = System.getProperty("org.apache.coyote.http11.Http11Protocol.COMPRESSION", "off");
+ protected String noCompressionUserAgents = System.getProperty("org.apache.coyote.http11.Http11Protocol.COMPRESSION_RESTRICTED_UA");
+ protected String compressableMimeTypes = System.getProperty("org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIME_TYPES", "text/html,text/xml,text/plain");
+ protected int compressionMinSize = Integer.valueOf(System.getProperty("org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIN_SIZE", "2048")).intValue();
protected String protocol = null;
/**
* User agents regular expressions which should be restricted to HTTP/1.0
@@ -95,9 +95,7 @@
* Maximum number of requests which can be performed over a keepalive
* connection. The default is the same as for Apache HTTP Server.
*/
- protected int maxKeepAliveRequests = Integer.valueOf(
- System.getProperty("org.apache.coyote.http11.Http11Protocol.MAX_KEEP_ALIVE_REQUESTS",
- "100")).intValue();
+ protected int maxKeepAliveRequests = Integer.valueOf(System.getProperty("org.apache.coyote.http11.Http11Protocol.MAX_KEEP_ALIVE_REQUESTS", "-1")).intValue();
protected String domain;
protected ObjectName oname;
@@ -106,7 +104,7 @@
/**
* Server header.
*/
- protected String server;
+ protected String server = System.getProperty("org.apache.coyote.http11.Http11Protocol.SERVER");
/**
* This timeout represents the socket timeout which will be used while the
* adapter execution is in progress, unless disableUploadTimeout is set to
11 years
JBossWeb SVN: r2324 - 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-12-09 11:20:20 -0500 (Mon, 09 Dec 2013)
New Revision: 2324
Modified:
branches/7.4.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
branches/7.4.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSESocketChannelFactory.java
branches/7.4.x/src/main/java/org/jboss/web/CoyoteMessages.java
Log:
Andiamo.
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java 2013-12-09 16:18:00 UTC (rev 2323)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java 2013-12-09 16:20:20 UTC (rev 2324)
@@ -258,7 +258,7 @@
enabledCiphers = new String[vec.size()];
vec.copyInto(enabledCiphers);
} else {
- throw new IOException("no cipher match"); // Like openssl.
+ throw new IOException(MESSAGES.noCipherMatch()); // Like openssl.
}
} else {
enabledCiphers = sslProxy.getDefaultCipherSuites();
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSESocketChannelFactory.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSESocketChannelFactory.java 2013-12-09 16:18:00 UTC (rev 2323)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/util/net/jsse/NioJSSESocketChannelFactory.java 2013-12-09 16:20:20 UTC (rev 2324)
@@ -396,8 +396,8 @@
enabledCiphers = new String[vec.size()];
vec.copyInto(enabledCiphers);
} else {
- throw new IOException("no cipher match"); // Like openssl.
- }
+ throw new IOException(MESSAGES.noCipherMatch()); // Like openssl.
+ }
} else {
enabledCiphers = sslProxy.getDefaultCipherSuites();
}
Modified: branches/7.4.x/src/main/java/org/jboss/web/CoyoteMessages.java
===================================================================
--- branches/7.4.x/src/main/java/org/jboss/web/CoyoteMessages.java 2013-12-09 16:18:00 UTC (rev 2323)
+++ branches/7.4.x/src/main/java/org/jboss/web/CoyoteMessages.java 2013-12-09 16:20:20 UTC (rev 2324)
@@ -280,4 +280,7 @@
@Message(id = 2080, value = "Thread [%s] stoppe to avoid potential leak")
String threadStopped(String threadName);
+ @Message(id = 2081, value = "No cipher match")
+ String noCipherMatch();
+
}
11 years