You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by up...@apache.org on 2016/08/05 18:07:11 UTC
[2/2] incubator-geode git commit: GEODE-1728: Removing the dispatcher
elements from the session filter
GEODE-1728: Removing the dispatcher elements from the session filter
The geode session filter is being applied to all requests. Because of
that, all request objects should already be wrapped in a RequestWrapper.
By adding these dispatcher elements to the filter, the filter was being
applied multiple times to the request when a request is forwarded or
included using the RequestDipatcher. That is unnecessary, and
problematic if we can't determine that the request has already been
wrapped.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/bc6f5da3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/bc6f5da3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/bc6f5da3
Branch: refs/heads/develop
Commit: bc6f5da31e8ca5ff3e1a3ecc637a09b2132e2be4
Parents: 45299f3
Author: Dan Smith <up...@apache.org>
Authored: Wed Aug 3 17:21:07 2016 -0700
Committer: Dan Smith <up...@apache.org>
Committed: Fri Aug 5 10:59:49 2016 -0700
----------------------------------------------------------------------
extensions/geode-modules-session/build.gradle | 1 +
.../modules/session/installer/Installer.java | 6 +-
.../session/installer/InstallerJUnitTest.java | 62 ++++++++++++++++++++
.../installer/InstallerJUnitTest.web.xml | 41 +++++++++++++
.../InstallerJUnitTest.web.xml.expected | 52 ++++++++++++++++
5 files changed, 157 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bc6f5da3/extensions/geode-modules-session/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/build.gradle b/extensions/geode-modules-session/build.gradle
index 4045a69..191b251 100644
--- a/extensions/geode-modules-session/build.gradle
+++ b/extensions/geode-modules-session/build.gradle
@@ -23,6 +23,7 @@ dependencies {
testCompile 'org.slf4j:slf4j-api:' + project.'slf4j-api.version'
testCompile('com.mockrunner:mockrunner-servlet:' + project.'mockrunner.version') {
exclude group: 'jboss'
+ exclude group: 'xerces'
}
testCompile(group: 'org.eclipse.jetty', name: 'jetty-http', version: project.'jetty.version', classifier: 'tests')
testCompile(group: 'org.eclipse.jetty', name: 'jetty-servlet', version: project.'jetty.version', classifier: 'tests')
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bc6f5da3/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/installer/Installer.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/installer/Installer.java b/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/installer/Installer.java
index 7ba5b34..1d16494 100644
--- a/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/installer/Installer.java
+++ b/extensions/geode-modules-session/src/main/java/com/gemstone/gemfire/modules/session/installer/Installer.java
@@ -151,7 +151,7 @@ public class Installer {
}
- private void processWebXml(final InputStream webXml,
+ public void processWebXml(final InputStream webXml,
final OutputStream out) throws Exception {
Document doc = createWebXmlDoc(webXml);
@@ -232,10 +232,6 @@ public class Installer {
final Element filterMapping = doc.createElement("filter-mapping");
append(doc, filterMapping, "filter-name", "gemfire-session-filter");
append(doc, filterMapping, "url-pattern", "/*");
- append(doc, filterMapping, "dispatcher", "FORWARD");
- append(doc, filterMapping, "dispatcher", "INCLUDE");
- append(doc, filterMapping, "dispatcher", "REQUEST");
- append(doc, filterMapping, "dispatcher", "ERROR");
final Element contextListener = doc.createElement("listener");
append(doc, contextListener, "listener-class", GEMFIRE_LISTENER_CLASS);
docElement.insertBefore(filterMapping, after(docElement, "filter"));
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bc6f5da3/extensions/geode-modules-session/src/test/java/com/gemstone/gemfire/modules/session/installer/InstallerJUnitTest.java
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/test/java/com/gemstone/gemfire/modules/session/installer/InstallerJUnitTest.java b/extensions/geode-modules-session/src/test/java/com/gemstone/gemfire/modules/session/installer/InstallerJUnitTest.java
new file mode 100644
index 0000000..98e5aac
--- /dev/null
+++ b/extensions/geode-modules-session/src/test/java/com/gemstone/gemfire/modules/session/installer/InstallerJUnitTest.java
@@ -0,0 +1,62 @@
+/*
+* 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 com.gemstone.gemfire.modules.session.installer;
+
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import com.gemstone.gemfire.internal.FileUtil;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+
+@Category(UnitTest.class)
+public class InstallerJUnitTest {
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Test
+ public void installIntoWebXML() throws Exception {
+ testTransformation("InstallerJUnitTest.web.xml");
+ }
+
+ private void testTransformation(final String name) throws Exception {
+ File webXmlFile = temporaryFolder.newFile();
+ FileUtil.copy(getClass().getResource(name), webXmlFile);
+ final String[] args = {
+ "-t", "peer-to-peer",
+ "-w", webXmlFile.getAbsolutePath()
+ };
+
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ try(InputStream input = new FileInputStream(webXmlFile)){
+ new Installer(args).processWebXml(input, output);
+ }
+
+ String expected = IOUtils.toString(getClass().getResource(name + ".expected"));
+ assertEquals(expected, output.toString());
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bc6f5da3/extensions/geode-modules-session/src/test/resources/com/gemstone/gemfire/modules/session/installer/InstallerJUnitTest.web.xml
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/test/resources/com/gemstone/gemfire/modules/session/installer/InstallerJUnitTest.web.xml b/extensions/geode-modules-session/src/test/resources/com/gemstone/gemfire/modules/session/installer/InstallerJUnitTest.web.xml
new file mode 100644
index 0000000..7d9a362
--- /dev/null
+++ b/extensions/geode-modules-session/src/test/resources/com/gemstone/gemfire/modules/session/installer/InstallerJUnitTest.web.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+ <filter>
+ <filter-name>existingFilter</filter-name>
+ <filter-class>some.Class</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>existingFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <servlet>
+ <servlet-name>existingServlet</servlet-name>
+ <servlet-class>some.Class</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>existingServlet</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bc6f5da3/extensions/geode-modules-session/src/test/resources/com/gemstone/gemfire/modules/session/installer/InstallerJUnitTest.web.xml.expected
----------------------------------------------------------------------
diff --git a/extensions/geode-modules-session/src/test/resources/com/gemstone/gemfire/modules/session/installer/InstallerJUnitTest.web.xml.expected b/extensions/geode-modules-session/src/test/resources/com/gemstone/gemfire/modules/session/installer/InstallerJUnitTest.web.xml.expected
new file mode 100644
index 0000000..d28adb3
--- /dev/null
+++ b/extensions/geode-modules-session/src/test/resources/com/gemstone/gemfire/modules/session/installer/InstallerJUnitTest.web.xml.expected
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+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.
+--><web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+ <filter>
+ <filter-name>gemfire-session-filter</filter-name>
+ <filter-class>com.gemstone.gemfire.modules.session.filter.SessionCachingFilter</filter-class>
+ <init-param>
+ <param-name>cache-type</param-name>
+ <param-value>peer-to-peer</param-value>
+ </init-param>
+ </filter>
+ <filter>
+ <filter-name>existingFilter</filter-name>
+ <filter-class>some.Class</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>gemfire-session-filter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>existingFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <listener>
+ <listener-class>com.gemstone.gemfire.modules.session.filter.SessionListener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>existingServlet</servlet-name>
+ <servlet-class>some.Class</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>existingServlet</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>