JBossWeb SVN: r2501 - branches/7.5.x/src/main/java/org/apache/catalina/valves.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2014-09-04 09:08:00 -0400 (Thu, 04 Sep 2014)
New Revision: 2501
Modified:
branches/7.5.x/src/main/java/org/apache/catalina/valves/AccessLogValve.java
Log:
BZ1029491: resolveHosts should have been removed, but since it is in the domain model, it should be used.
Modified: branches/7.5.x/src/main/java/org/apache/catalina/valves/AccessLogValve.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/catalina/valves/AccessLogValve.java 2014-09-03 15:52:30 UTC (rev 2500)
+++ branches/7.5.x/src/main/java/org/apache/catalina/valves/AccessLogValve.java 2014-09-04 13:08:00 UTC (rev 2501)
@@ -949,7 +949,11 @@
protected class HostElement implements AccessLogElement {
public void addElement(StringBuilder buf, Date date, Request request,
Response response, long time) {
- buf.append(request.getRemoteHost());
+ if (resolveHosts) {
+ buf.append(request.getRemoteHost());
+ } else {
+ buf.append(request.getRemoteAddr());
+ }
}
}
10 years, 4 months
JBossWeb SVN: r2500 - in branches/7.5.x/src/main/java/org: apache/tomcat/websocket/server and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2014-09-03 11:52:30 -0400 (Wed, 03 Sep 2014)
New Revision: 2500
Modified:
branches/7.5.x/src/main/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
branches/7.5.x/src/main/java/org/apache/tomcat/websocket/server/WsServerContainer.java
branches/7.5.x/src/main/java/org/jboss/web/WebsocketsLogger.java
Log:
Port websockets thread handling robustness fixes, that could have caused some issues on shutdown.
Modified: branches/7.5.x/src/main/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/tomcat/websocket/WsWebSocketContainer.java 2014-09-03 08:05:20 UTC (rev 2499)
+++ branches/7.5.x/src/main/java/org/apache/tomcat/websocket/WsWebSocketContainer.java 2014-09-03 15:52:30 UTC (rev 2500)
@@ -271,6 +271,7 @@
ByteBuffer response;
String subProtocol;
+ boolean success = false;
try {
fConnect.get(timeout, TimeUnit.MILLISECONDS);
@@ -307,6 +308,7 @@
} else {
throw new DeploymentException(MESSAGES.invalidProtocolHeader());
}
+ success = true;
} catch (ExecutionException e) {
throw new DeploymentException(MESSAGES.httpRequestFailed(), e);
} catch (InterruptedException e) {
@@ -317,6 +319,10 @@
throw new DeploymentException(MESSAGES.httpRequestFailed(), e);
} catch (TimeoutException e) {
throw new DeploymentException(MESSAGES.httpRequestFailed(), e);
+ } finally {
+ if (!success) {
+ channel.close();
+ }
}
// Switch to WebSocket
Modified: branches/7.5.x/src/main/java/org/apache/tomcat/websocket/server/WsServerContainer.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/tomcat/websocket/server/WsServerContainer.java 2014-09-03 08:05:20 UTC (rev 2499)
+++ branches/7.5.x/src/main/java/org/apache/tomcat/websocket/server/WsServerContainer.java 2014-09-03 15:52:30 UTC (rev 2500)
@@ -290,13 +290,42 @@
public void destroy() {
shutdownExecutor();
super.destroy();
+ // If the executor hasn't fully shutdown it won't be possible to
+ // destroy this thread group as there will still be threads running.
+ // Mark the thread group as daemon one, so that it destroys itself
+ // when thread count reaches zero.
+ // Synchronization on threadGroup is needed, as there is a race between
+ // destroy() call from termination of the last thread in thread group
+ // marked as daemon versus the explicit destroy() call.
+ int threadCount = threadGroup.activeCount();
+ boolean success = false;
try {
- threadGroup.destroy();
- } catch (IllegalThreadStateException itse) {
- // If the executor hasn't fully shutdown it won't be possible to
- // destroy this thread group as there will still be threads running
- WebsocketsLogger.ROOT_LOGGER.threadGroupNotDestryed(threadGroup.getName());
+ while (true) {
+ int oldThreadCount = threadCount;
+ synchronized (threadGroup) {
+ if (threadCount > 0) {
+ Thread.yield();
+ threadCount = threadGroup.activeCount();
+ }
+ if (threadCount > 0 && threadCount != oldThreadCount) {
+ // Value not stabilized. Retry.
+ continue;
+ }
+ if (threadCount > 0) {
+ threadGroup.setDaemon(true);
+ } else {
+ threadGroup.destroy();
+ success = true;
+ }
+ break;
+ }
+ }
+ } catch (IllegalThreadStateException exception) {
+ // Fall-through
}
+ if (!success) {
+ WebsocketsLogger.ROOT_LOGGER.threadGroupNotDestryed(threadGroup.getName(), Integer.valueOf(threadCount));
+ }
}
Modified: branches/7.5.x/src/main/java/org/jboss/web/WebsocketsLogger.java
===================================================================
--- branches/7.5.x/src/main/java/org/jboss/web/WebsocketsLogger.java 2014-09-03 08:05:20 UTC (rev 2499)
+++ branches/7.5.x/src/main/java/org/jboss/web/WebsocketsLogger.java 2014-09-03 15:52:30 UTC (rev 2500)
@@ -99,7 +99,7 @@
void noWebsocketsSupport();
@LogMessage(level = WARN)
- @Message(id = 8814, value = "Thread group %s not destroyed")
- void threadGroupNotDestryed(String name);
+ @Message(id = 8814, value = "Thread group %s not destroyed, %s threads left")
+ void threadGroupNotDestryed(String name, int threadCount);
}
10 years, 4 months
JBossWeb SVN: r2499 - branches/7.5.x/src/main/java/org/apache/tomcat/websocket/server.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2014-09-03 04:05:20 -0400 (Wed, 03 Sep 2014)
New Revision: 2499
Modified:
branches/7.5.x/src/main/java/org/apache/tomcat/websocket/server/WsSci.java
Log:
JBWEB-298: Should address NPE and problems on multiple inits of websockets.
Modified: branches/7.5.x/src/main/java/org/apache/tomcat/websocket/server/WsSci.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/tomcat/websocket/server/WsSci.java 2014-09-01 14:18:30 UTC (rev 2498)
+++ branches/7.5.x/src/main/java/org/apache/tomcat/websocket/server/WsSci.java 2014-09-03 08:05:20 UTC (rev 2499)
@@ -57,6 +57,10 @@
}
return;
}
+ if (ctx.getAttribute(Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE) != null) {
+ // Websockets already initialized
+ return;
+ }
WsServerContainer sc = init(ctx, true);
10 years, 4 months
JBossWeb SVN: r2498 - in branches/7.5.x/src/main/java/org: apache/coyote/http11/filters and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2014-09-01 10:18:30 -0400 (Mon, 01 Sep 2014)
New Revision: 2498
Modified:
branches/7.5.x/src/main/java/org/apache/coyote/http11/Constants.java
branches/7.5.x/src/main/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
branches/7.5.x/src/main/java/org/jboss/web/CoyoteMessages.java
Log:
BZ1075028: Limit size of chunk extensions per request [which have no use in Servlets].
Modified: branches/7.5.x/src/main/java/org/apache/coyote/http11/Constants.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/coyote/http11/Constants.java 2014-09-01 13:35:02 UTC (rev 2497)
+++ branches/7.5.x/src/main/java/org/apache/coyote/http11/Constants.java 2014-09-01 14:18:30 UTC (rev 2498)
@@ -49,6 +49,8 @@
.booleanValue();
public static final boolean DISABLE_KEEPALIVE_ON_CONCLOSE =
Boolean.valueOf(System.getProperty("org.apache.coyote.http11.DISABLE_KEEPALIVE_ON_CONCLOSE", "false")).booleanValue();
+ public static final int MAX_CHUNK_EXTENSION_SIZE =
+ Integer.valueOf(System.getProperty("org.apache.coyote.http11.MAX_CHUNK_EXTENSION_SIZE", "8192")).intValue();
/**
Modified: branches/7.5.x/src/main/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 2014-09-01 13:35:02 UTC (rev 2497)
+++ branches/7.5.x/src/main/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 2014-09-01 14:18:30 UTC (rev 2498)
@@ -108,7 +108,10 @@
*/
private boolean error;
- // ------------------------------------------------------------- Properties
+ /**
+ * Size of extensions processed for this request.
+ */
+ private long extensionSize;
// ---------------------------------------------------- InputBuffer Methods
@@ -231,6 +234,7 @@
endChunk = false;
needCRLFParse = false;
error = false;
+ extensionSize = 0;
}
@@ -301,6 +305,7 @@
eol = true;
} else if (buf[pos] == Constants.SEMI_COLON) {
trailer = true;
+ extensionSize++;
} else if (buf[pos] < 0) {
error = true;
throw MESSAGES.invalidChunkHeader();
@@ -316,6 +321,12 @@
error = true;
throw MESSAGES.invalidChunkHeader();
}
+ } else {
+ // Skipping the extension
+ extensionSize++;
+ if (Constants.MAX_CHUNK_EXTENSION_SIZE > -1 && extensionSize > Constants.MAX_CHUNK_EXTENSION_SIZE) {
+ throw MESSAGES.maxExtensionSizeExceeded(Constants.MAX_CHUNK_EXTENSION_SIZE);
+ }
}
pos++;
Modified: branches/7.5.x/src/main/java/org/jboss/web/CoyoteMessages.java
===================================================================
--- branches/7.5.x/src/main/java/org/jboss/web/CoyoteMessages.java 2014-09-01 13:35:02 UTC (rev 2497)
+++ branches/7.5.x/src/main/java/org/jboss/web/CoyoteMessages.java 2014-09-01 14:18:30 UTC (rev 2498)
@@ -277,7 +277,7 @@
@Message(id = 2079, value = "Unexpected data read during handshake")
String sslHandshakeData();
- @Message(id = 2080, value = "Thread [%s] stoppe to avoid potential leak")
+ @Message(id = 2080, value = "Thread [%s] stopped to avoid potential leak")
String threadStopped(String threadName);
@Message(id = 2081, value = "No cipher match")
@@ -286,4 +286,7 @@
@Message(id = 2082, value = "Chunked input filter error")
String chunkedFilterError();
+ @Message(id = 2083, value = "Maximum extension size [%s] exceeded for this request")
+ IOException maxExtensionSizeExceeded(int size);
+
}
10 years, 4 months
JBossWeb SVN: r2497 - in branches/7.5.x: webapps/docs and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2014-09-01 09:35:02 -0400 (Mon, 01 Sep 2014)
New Revision: 2497
Modified:
branches/7.5.x/src/main/java/org/apache/coyote/http11/Constants.java
branches/7.5.x/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java
branches/7.5.x/src/main/java/org/apache/coyote/http11/Http11NioProcessor.java
branches/7.5.x/src/main/java/org/apache/coyote/http11/Http11Processor.java
branches/7.5.x/webapps/docs/sysprops.xml
Log:
BZ1058424: Add support to check for connection: close as included by the web application. Submitted by Masafumi Miura (ported from Tomcat apparently).
Disabled by default so I am including it, the application should have no business trying to hack things in the protocol in the first place.
Modified: branches/7.5.x/src/main/java/org/apache/coyote/http11/Constants.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/coyote/http11/Constants.java 2014-08-26 14:30:34 UTC (rev 2496)
+++ branches/7.5.x/src/main/java/org/apache/coyote/http11/Constants.java 2014-09-01 13:35:02 UTC (rev 2497)
@@ -47,6 +47,8 @@
public static final boolean DEFAULT_DISABLE_UPLOAD_TIMEOUT = Boolean.valueOf(
System.getProperty("org.apache.coyote.http11.DEFAULT_DISABLE_UPLOAD_TIMEOUT", "false"))
.booleanValue();
+ public static final boolean DISABLE_KEEPALIVE_ON_CONCLOSE =
+ Boolean.valueOf(System.getProperty("org.apache.coyote.http11.DISABLE_KEEPALIVE_ON_CONCLOSE", "false")).booleanValue();
/**
Modified: branches/7.5.x/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java 2014-08-26 14:30:34 UTC (rev 2496)
+++ branches/7.5.x/src/main/java/org/apache/coyote/http11/Http11AprProcessor.java 2014-09-01 13:35:02 UTC (rev 2497)
@@ -70,7 +70,6 @@
protected static final boolean CHUNK_ON_CLOSE =
Boolean.valueOf(System.getProperty("org.apache.coyote.http11.Http11Processor.CHUNK_ON_CLOSE", "false")).booleanValue();
-
// ----------------------------------------------------------- Constructors
@@ -1724,6 +1723,12 @@
}
long contentLength = response.getContentLengthLong();
+ boolean connectionClosePresent = false;
+ if (Constants.DISABLE_KEEPALIVE_ON_CONCLOSE) {
+ connectionClosePresent = isConnectionClose(headers);
+ keepAlive = keepAlive && !connectionClosePresent;
+ }
+
if (contentLength != -1) {
headers.setValue("Content-Length").setLong(contentLength);
outputBuffer.addActiveFilter
@@ -1763,7 +1768,9 @@
// Connection: close header.
keepAlive = keepAlive && !statusDropsConnection(statusCode);
if (!keepAlive) {
- headers.addValue(Constants.CONNECTION).setString(Constants.CLOSE);
+ if (!connectionClosePresent) {
+ headers.addValue(Constants.CONNECTION).setString(Constants.CLOSE);
+ }
} else if (!http11 && !error) {
headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE);
}
@@ -1786,6 +1793,13 @@
}
+ private boolean isConnectionClose(MimeHeaders headers) {
+ MessageBytes connection = headers.getValue(Constants.CONNECTION);
+ if (connection == null) {
+ return false;
+ }
+ return connection.equals(Constants.CLOSE);
+ }
/**
* Initialize standard input and output filters.
Modified: branches/7.5.x/src/main/java/org/apache/coyote/http11/Http11NioProcessor.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/coyote/http11/Http11NioProcessor.java 2014-08-26 14:30:34 UTC (rev 2496)
+++ branches/7.5.x/src/main/java/org/apache/coyote/http11/Http11NioProcessor.java 2014-09-01 13:35:02 UTC (rev 2497)
@@ -1198,6 +1198,12 @@
}
long contentLength = response.getContentLengthLong();
+ boolean connectionClosePresent = false;
+ if (Constants.DISABLE_KEEPALIVE_ON_CONCLOSE) {
+ connectionClosePresent = isConnectionClose(headers);
+ keepAlive = keepAlive && !connectionClosePresent;
+ }
+
if (contentLength != -1) {
headers.setValue("Content-Length").setLong(contentLength);
outputBuffer.addActiveFilter(outputFilters[Constants.IDENTITY_FILTER]);
@@ -1234,7 +1240,9 @@
// Connection: close header.
keepAlive = keepAlive && !statusDropsConnection(statusCode);
if (!keepAlive) {
- headers.addValue(Constants.CONNECTION).setString(Constants.CLOSE);
+ if (!connectionClosePresent) {
+ headers.addValue(Constants.CONNECTION).setString(Constants.CLOSE);
+ }
} else if (!http11 && !error) {
headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE);
}
@@ -1257,6 +1265,14 @@
}
+ private boolean isConnectionClose(MimeHeaders headers) {
+ MessageBytes connection = headers.getValue(Constants.CONNECTION);
+ if (connection == null) {
+ return false;
+ }
+ return connection.equals(Constants.CLOSE);
+ }
+
/*
* (non-Javadoc)
*
Modified: branches/7.5.x/src/main/java/org/apache/coyote/http11/Http11Processor.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/coyote/http11/Http11Processor.java 2014-08-26 14:30:34 UTC (rev 2496)
+++ branches/7.5.x/src/main/java/org/apache/coyote/http11/Http11Processor.java 2014-09-01 13:35:02 UTC (rev 2497)
@@ -66,7 +66,6 @@
protected static final boolean CHUNK_ON_CLOSE =
Boolean.valueOf(System.getProperty("org.apache.coyote.http11.Http11Processor.CHUNK_ON_CLOSE", "false")).booleanValue();
-
// ------------------------------------------------------------ Constructor
@@ -1565,6 +1564,12 @@
}
long contentLength = response.getContentLengthLong();
+ boolean connectionClosePresent = false;
+ if (Constants.DISABLE_KEEPALIVE_ON_CONCLOSE) {
+ connectionClosePresent = isConnectionClose(headers);
+ keepAlive = keepAlive && !connectionClosePresent;
+ }
+
if (contentLength != -1) {
headers.setValue("Content-Length").setLong(contentLength);
outputBuffer.addActiveFilter
@@ -1604,7 +1609,9 @@
// Connection: close header.
keepAlive = keepAlive && !statusDropsConnection(statusCode);
if (!keepAlive) {
- headers.addValue(Constants.CONNECTION).setString(Constants.CLOSE);
+ if (!connectionClosePresent) {
+ headers.addValue(Constants.CONNECTION).setString(Constants.CLOSE);
+ }
} else if (!http11 && !error) {
headers.addValue(Constants.CONNECTION).setString(Constants.KEEPALIVE);
}
@@ -1627,6 +1634,13 @@
}
+ private boolean isConnectionClose(MimeHeaders headers) {
+ MessageBytes connection = headers.getValue(Constants.CONNECTION);
+ if (connection == null) {
+ return false;
+ }
+ return connection.equals(Constants.CLOSE);
+ }
/**
* Initialize standard input and output filters.
Modified: branches/7.5.x/webapps/docs/sysprops.xml
===================================================================
--- branches/7.5.x/webapps/docs/sysprops.xml 2014-08-26 14:30:34 UTC (rev 2496)
+++ branches/7.5.x/webapps/docs/sysprops.xml 2014-09-01 13:35:02 UTC (rev 2497)
@@ -189,6 +189,11 @@
which means it will use the default socket timeout.</p>
</property>
+ <property name="org.apache.coyote.http11.DISABLE_KEEPALIVE_ON_CONCLOSE">
+ <p>If a <code>connection:close header</code> is included in the response by the
+ application, disable keep alive. The default value is <code>false</code>.</p>
+ </property>
+
</properties>
</section>
10 years, 4 months