JBossWeb SVN: r2540 - branches/7.5.x/src/main/java/org/apache/jasper/compiler.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2014-11-14 06:10:55 -0500 (Fri, 14 Nov 2014)
New Revision: 2540
Modified:
branches/7.5.x/src/main/java/org/apache/jasper/compiler/TagFileProcessor.java
Log:
Port Tomcat BZ55582: Concurrent issue of TagFileProcessor. Just in case.
Modified: branches/7.5.x/src/main/java/org/apache/jasper/compiler/TagFileProcessor.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/jasper/compiler/TagFileProcessor.java 2014-11-14 10:20:21 UTC (rev 2539)
+++ branches/7.5.x/src/main/java/org/apache/jasper/compiler/TagFileProcessor.java 2014-11-14 11:10:55 UTC (rev 2540)
@@ -584,9 +584,9 @@
JspCompilationContext ctxt = compiler.getCompilationContext();
JspRuntimeContext rctxt = ctxt.getRuntimeContext();
- JspServletWrapper wrapper = rctxt.getWrapper(tagFileJarPath + tagFilePath);
synchronized (rctxt) {
+ JspServletWrapper wrapper = rctxt.getWrapper(tagFileJarPath + tagFilePath);
if (wrapper == null) {
wrapper = new JspServletWrapper(ctxt.getServletContext(), ctxt
.getOptions(), tagFilePath, tagInfo, ctxt
10 years, 1 month
JBossWeb SVN: r2539 - branches/7.5.x/src/main/java/org/apache/catalina/connector.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2014-11-14 05:20:21 -0500 (Fri, 14 Nov 2014)
New Revision: 2539
Modified:
branches/7.5.x/src/main/java/org/apache/catalina/connector/CoyoteOutputStream.java
Log:
Same as r2381, avoid NPE after recycle.
Modified: branches/7.5.x/src/main/java/org/apache/catalina/connector/CoyoteOutputStream.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/catalina/connector/CoyoteOutputStream.java 2014-11-13 17:57:45 UTC (rev 2538)
+++ branches/7.5.x/src/main/java/org/apache/catalina/connector/CoyoteOutputStream.java 2014-11-14 10:20:21 UTC (rev 2539)
@@ -102,7 +102,9 @@
public void close()
throws IOException {
- ob.close();
+ if (ob != null) {
+ ob.close();
+ }
}
10 years, 1 month
JBossWeb SVN: r2538 - in branches/7.5.x/src/main/java/org/apache: coyote/http11 and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2014-11-13 12:57:45 -0500 (Thu, 13 Nov 2014)
New Revision: 2538
Modified:
branches/7.5.x/src/main/java/org/apache/catalina/connector/InputBuffer.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/InternalNioInputBuffer.java
Log:
- Harmonize read with write, it's simpler and passes all the tests.
Modified: branches/7.5.x/src/main/java/org/apache/catalina/connector/InputBuffer.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/catalina/connector/InputBuffer.java 2014-11-12 15:43:14 UTC (rev 2537)
+++ branches/7.5.x/src/main/java/org/apache/catalina/connector/InputBuffer.java 2014-11-13 17:57:45 UTC (rev 2538)
@@ -610,7 +610,8 @@
throw MESSAGES.cannotSetListenerWithoutUpgradeOrAsync();
}
this.readListener = readListener;
- coyoteRequest.action(ActionCode.ACTION_EVENT_READ_BEGIN, null);
+ coyoteRequest.action(ActionCode.ACTION_EVENT_READ_BEGIN,
+ (request.getUpgradeHandler() != null) ? readListener : null);
}
}
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-11-12 15:43:14 UTC (rev 2537)
+++ branches/7.5.x/src/main/java/org/apache/coyote/http11/Http11NioProcessor.java 2014-11-13 17:57:45 UTC (rev 2538)
@@ -38,6 +38,7 @@
import org.apache.coyote.http11.filters.SavedRequestInputFilter;
import org.apache.coyote.http11.filters.VoidInputFilter;
import org.apache.coyote.http11.filters.VoidOutputFilter;
+import org.apache.coyote.http11.upgrade.servlet31.ReadListener;
import org.apache.coyote.http11.upgrade.servlet31.WriteListener;
import org.apache.tomcat.util.buf.ByteChunk;
import org.apache.tomcat.util.buf.HexUtils;
@@ -861,6 +862,7 @@
timeoutEvent(param);
} else if (actionCode == ActionCode.ACTION_EVENT_READ_BEGIN) {
inputBuffer.setNonBlocking(true);
+ inputBuffer.setReadListener((ReadListener) param);
readNotifications = true;
} else if (actionCode == ActionCode.ACTION_EVENT_WRITE_BEGIN) {
outputBuffer.setNonBlocking(true);
Modified: branches/7.5.x/src/main/java/org/apache/coyote/http11/InternalNioInputBuffer.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/coyote/http11/InternalNioInputBuffer.java 2014-11-12 15:43:14 UTC (rev 2537)
+++ branches/7.5.x/src/main/java/org/apache/coyote/http11/InternalNioInputBuffer.java 2014-11-13 17:57:45 UTC (rev 2538)
@@ -30,6 +30,7 @@
import org.apache.coyote.InputBuffer;
import org.apache.coyote.Request;
+import org.apache.coyote.http11.upgrade.servlet31.ReadListener;
import org.apache.tomcat.util.buf.ByteChunk;
import org.apache.tomcat.util.net.NioChannel;
import org.apache.tomcat.util.net.NioEndpoint;
@@ -85,6 +86,11 @@
private Semaphore semaphore = new Semaphore(1);
/**
+ * Associated read listener for upgrade mode.
+ */
+ private ReadListener listener = null;
+
+ /**
* Create a new instance of {@code InternalNioInputBuffer}
*
* @param request
@@ -110,33 +116,59 @@
this.completionHandler = new CompletionHandler<Integer, NioChannel>() {
@Override
- public synchronized void completed(Integer nBytes, NioChannel attachment) {
+ public void completed(Integer nBytes, NioChannel attachment) {
if (nBytes < 0) {
failed(new ClosedChannelException(), attachment);
return;
}
+ boolean notify = false;
- if (nBytes > 0) {
- bbuf.flip();
- if (nBytes > (buf.length - end)) {
- // An alternative is to bbuf.limit(buf.length - end) before the read,
- // which may be less efficient
- buf = new byte[buf.length];
- end = 0;
- pos = end;
- lastValid = pos;
- }
- bbuf.get(buf, pos, nBytes);
- lastValid = pos + nBytes;
- semaphore.release();
- if (/*!processor.isProcessing() && */processor.getReadNotifications()
- && available) {
- available = false;
- if (!endpoint.processChannel(attachment, SocketStatus.OPEN_READ)) {
- endpoint.closeChannel(attachment);
+ synchronized (completionHandler) {
+ if (nBytes > 0) {
+ bbuf.flip();
+ if (nBytes > (buf.length - end)) {
+ // An alternative is to bbuf.limit(buf.length - end) before the read,
+ // which may be less efficient
+ buf = new byte[buf.length];
+ end = 0;
+ pos = end;
+ lastValid = pos;
}
+ bbuf.get(buf, pos, nBytes);
+ lastValid = pos + nBytes;
+ semaphore.release();
+ if (/*!processor.isProcessing() && */processor.getReadNotifications()
+ && available) {
+ available = false;
+ notify = true;
+ }
}
}
+
+ if (notify) {
+ if (listener == null) {
+ if (!endpoint.processChannel(attachment, SocketStatus.OPEN_READ)) {
+ endpoint.closeChannel(attachment);
+ }
+ } else {
+ Thread thread = Thread.currentThread();
+ ClassLoader originalClassLoader = thread.getContextClassLoader();
+ try {
+ thread.setContextClassLoader(listener.getClass().getClassLoader());
+ synchronized (channel.getLock()) {
+ listener.onDataAvailable();
+ }
+ } catch (Exception e) {
+ processor.getResponse().setErrorException(e);
+ endpoint.removeEventChannel(attachment);
+ if (!endpoint.processChannel(attachment, SocketStatus.ERROR)) {
+ endpoint.closeChannel(attachment);
+ }
+ } finally {
+ thread.setContextClassLoader(originalClassLoader);
+ }
+ }
+ }
}
@Override
@@ -187,6 +219,13 @@
return nonBlocking;
}
+ /**
+ * Set the associated read listener for upgrade mode.
+ */
+ public void setReadListener(ReadListener listener) {
+ this.listener = listener;
+ }
+
/*
* (non-Javadoc)
*
@@ -195,6 +234,7 @@
public void recycle() {
super.recycle();
bbuf.clear();
+ listener = null;
channel = null;
available = true;
readTimeout = (endpoint.getSoTimeout() > 0 ? endpoint.getSoTimeout()
10 years, 1 month
JBossWeb SVN: r2537 - 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-11-12 10:43:14 -0500 (Wed, 12 Nov 2014)
New Revision: 2537
Modified:
branches/7.5.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java
Log:
BZ1163126: Refactor using a serializable binding listener.
Modified: branches/7.5.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java
===================================================================
--- branches/7.5.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java 2014-10-29 10:04:49 UTC (rev 2536)
+++ branches/7.5.x/src/main/java/org/apache/catalina/valves/CrawlerSessionManagerValve.java 2014-11-12 15:43:14 UTC (rev 2537)
@@ -19,6 +19,7 @@
import static org.jboss.web.CatalinaMessages.MESSAGES;
import java.io.IOException;
+import java.io.Serializable;
import java.util.Enumeration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -45,7 +46,7 @@
* requests.
*/
public class CrawlerSessionManagerValve extends ValveBase
- implements Lifecycle, HttpSessionBindingListener {
+ implements Lifecycle {
/**
* The lifecycle event support for this component.
@@ -219,7 +220,7 @@
clientIpSessionId.put(clientIp, s.getId());
sessionIdClientIp.put(s.getId(), clientIp);
// #valueUnbound() will be called on session expiration
- s.setAttribute(this.getClass().getName(), this);
+ s.setAttribute(this.getClass().getName(), new CrawlerBindingListener());
s.setMaxInactiveInterval(sessionInactiveInterval);
if (CatalinaLogger.VALVES_LOGGER.isDebugEnabled()) {
@@ -236,18 +237,18 @@
}
}
-
- @Override
- public void valueBound(HttpSessionBindingEvent event) {
- // NOOP
- }
-
-
- @Override
- public void valueUnbound(HttpSessionBindingEvent event) {
- String clientIp = sessionIdClientIp.remove(event.getSession().getId());
- if (clientIp != null) {
- clientIpSessionId.remove(clientIp);
+ protected class CrawlerBindingListener implements HttpSessionBindingListener, Serializable {
+ private static final long serialVersionUID = -3775762684177732270L;
+ @Override
+ public void valueBound(HttpSessionBindingEvent event) {
+ // NOOP
}
+ @Override
+ public void valueUnbound(HttpSessionBindingEvent event) {
+ String clientIp = sessionIdClientIp.remove(event.getSession().getId());
+ if (clientIp != null) {
+ clientIpSessionId.remove(clientIp);
+ }
+ }
}
}
10 years, 1 month