Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuan G2016-01-11 10:53:09 +0000
committerRaymond Auge2016-01-15 09:11:10 +0000
commit77016725790d3758c99727a64db5676a35ced29d (patch)
tree68dc2871a3bec473b21955f672290beed644e1cb /bundles
parentd697189047e4dde27d001ae177b78a663fd9d9f0 (diff)
downloadrt.equinox.bundles-77016725790d3758c99727a64db5676a35ced29d.tar.gz
rt.equinox.bundles-77016725790d3758c99727a64db5676a35ced29d.tar.xz
rt.equinox.bundles-77016725790d3758c99727a64db5676a35ced29d.zip
Bug 485532 - [http whiteboard] Only invoke requestInitialized when dispatcher type is REQUEST
Signed-off-by: Juan Gonzalez <juan.gonzalez@liferay.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java57
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletRequestListener.java5
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResponseStateHandler.java12
3 files changed, 68 insertions, 6 deletions
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java
index a292261f..c02966de 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java
@@ -2637,6 +2637,63 @@ public class ServletTest extends TestCase {
}
}
+ public void test_Listener9() throws Exception {
+ Servlet sA = new HttpServlet() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(
+ HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+
+ RequestDispatcher requestDispatcher = req.getRequestDispatcher("/s9B");
+
+ requestDispatcher.include(req, resp);
+ }
+ };
+ Servlet sB = new HttpServlet() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void doGet(
+ HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+
+ PrintWriter writer = resp.getWriter();
+ writer.write("S9 included");
+ }
+ };
+
+ BaseServletRequestListener srl1 = new BaseServletRequestListener();
+
+ Collection<ServiceRegistration<?>> registrations = new ArrayList<ServiceRegistration<?>>();
+ try {
+ Dictionary<String, String> listenerProps = new Hashtable<String, String>();
+ listenerProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_LISTENER, "true");
+ registrations.add(getBundleContext().registerService(ServletRequestListener.class, srl1, listenerProps));
+
+ Dictionary<String, String> servletProps1 = new Hashtable<String, String>();
+ servletProps1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S9A");
+ servletProps1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s9A");
+ registrations.add(getBundleContext().registerService(Servlet.class, sA, servletProps1));
+
+ servletProps1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S9B");
+ servletProps1.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/s9B");
+ registrations.add(getBundleContext().registerService(Servlet.class, sB, servletProps1));
+
+ String result = requestAdvisor.request("s9A");
+ Assert.assertEquals("S9 included", result);
+
+ Assert.assertEquals(0, srl1.number.get());
+
+ }
+ finally {
+ for (ServiceRegistration<?> registration : registrations) {
+ registration.unregister();
+ }
+ }
+ }
+
public void test_Async1() throws Exception {
Servlet s1 = new BaseAsyncServlet("test_Listener8");
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletRequestListener.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletRequestListener.java
index c61b366b..26ceb0db 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletRequestListener.java
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/util/BaseServletRequestListener.java
@@ -12,6 +12,7 @@
package org.eclipse.equinox.http.servlet.tests.util;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
@@ -24,14 +25,18 @@ public class BaseServletRequestListener implements ServletRequestListener {
public AtomicBoolean initialized = new AtomicBoolean(false);
public AtomicBoolean destroyed = new AtomicBoolean(false);
+ public AtomicInteger number = new AtomicInteger();
+
@Override
public void requestDestroyed(ServletRequestEvent arg0) {
destroyed.set(true);
+ number.decrementAndGet();
}
@Override
public void requestInitialized(ServletRequestEvent arg0) {
initialized.set(true);
+ number.incrementAndGet();
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResponseStateHandler.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResponseStateHandler.java
index 01fa54bf..7b3b4761 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResponseStateHandler.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ResponseStateHandler.java
@@ -49,13 +49,13 @@ public class ResponseStateHandler {
ServletRequestEvent servletRequestEvent = null;
- if ((dispatcherType == DispatcherType.REQUEST) && !servletRequestListeners.isEmpty()) {
- servletRequestEvent = new ServletRequestEvent(endpoint.getServletContext(), request);
- }
-
try {
- for (ServletRequestListener servletRequestListener : servletRequestListeners) {
- servletRequestListener.requestInitialized(servletRequestEvent);
+
+ if ((dispatcherType == DispatcherType.REQUEST) && !servletRequestListeners.isEmpty()) {
+ servletRequestEvent = new ServletRequestEvent(endpoint.getServletContext(), request);
+ for (ServletRequestListener servletRequestListener : servletRequestListeners) {
+ servletRequestListener.requestInitialized(servletRequestEvent);
+ }
}
if (endpoint.getServletContextHelper().handleSecurity(request, response)) {

Back to the top