From b2fb778909e05379e25fd174e7b9e3619add9712 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 29 Nov 2020 17:01:46 +0100 Subject: [PATCH] WW-5078 Drops unneeded DTDs --- .../providers/XmlConfigurationProvider.java | 12 +- .../StrutsXmlConfigurationProvider.java | 3 +- .../apache/struts2/dispatcher/Dispatcher.java | 2 +- core/src/main/resources/struts-default.xml | 8 +- core/src/main/resources/xwork-1.0.dtd | 106 ------------ core/src/main/resources/xwork-1.1.1.dtd | 123 -------------- core/src/main/resources/xwork-1.1.2.dtd | 131 --------------- core/src/main/resources/xwork-1.1.dtd | 115 ------------- core/src/main/resources/xwork-2.0.dtd | 137 --------------- core/src/main/resources/xwork-2.1.3.dtd | 146 ---------------- core/src/main/resources/xwork-2.1.dtd | 143 ---------------- core/src/main/resources/xwork-2.3.dtd | 149 ----------------- core/src/main/resources/xwork-2.5.dtd | 151 ----------------- core/src/main/resources/xwork-2.6.dtd | 157 ------------------ .../xwork2/util/ClassLoaderUtilTest.java | 12 +- .../FetchMetadataInterceptorTest.java | 4 +- .../struts2/dispatcher/ng/struts-no-op.xml | 4 +- .../struts2/views/jsp/WW3090-struts.xml | 4 +- .../{xwork-1.0.dtd => struts-2.0.dtd} | 0 core/src/test/resources/struts.xml | 4 +- 20 files changed, 26 insertions(+), 1385 deletions(-) delete mode 100644 core/src/main/resources/xwork-1.0.dtd delete mode 100644 core/src/main/resources/xwork-1.1.1.dtd delete mode 100644 core/src/main/resources/xwork-1.1.2.dtd delete mode 100644 core/src/main/resources/xwork-1.1.dtd delete mode 100644 core/src/main/resources/xwork-2.0.dtd delete mode 100644 core/src/main/resources/xwork-2.1.3.dtd delete mode 100644 core/src/main/resources/xwork-2.1.dtd delete mode 100644 core/src/main/resources/xwork-2.3.dtd delete mode 100644 core/src/main/resources/xwork-2.5.dtd delete mode 100644 core/src/main/resources/xwork-2.6.dtd rename core/src/test/resources/{xwork-1.0.dtd => struts-2.0.dtd} (100%) diff --git a/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java b/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java index d2da19768..e02338f9a 100644 --- a/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java +++ b/core/src/main/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProvider.java @@ -72,6 +72,7 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.Vector; @@ -106,7 +107,7 @@ public abstract class XmlConfigurationProvider implements ConfigurationProvider private ValueSubstitutor valueSubstitutor; public XmlConfigurationProvider() { - this("xwork.xml", true); + this("struts.xml", true); } public XmlConfigurationProvider(String filename) { @@ -170,11 +171,7 @@ public abstract class XmlConfigurationProvider implements ConfigurationProvider final XmlConfigurationProvider xmlConfigurationProvider = (XmlConfigurationProvider) o; - if ((configFileName != null) ? (!configFileName.equals(xmlConfigurationProvider.configFileName)) : (xmlConfigurationProvider.configFileName != null)) { - return false; - } - - return true; + return Objects.equals(configFileName, xmlConfigurationProvider.configFileName); } @Override @@ -1066,7 +1063,8 @@ public abstract class XmlConfigurationProvider implements ConfigurationProvider } if (urls == null || !urls.hasNext()) { - throw new ConfigurationException("Could not open file: " + fileName, ioException); + LOG.debug("Ignoring file that does not exist: " + fileName, ioException); + return docs; } URL url = null; diff --git a/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java b/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java index 3461c7545..f876d0632 100644 --- a/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java +++ b/core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java @@ -51,6 +51,7 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider { * * @param errorIfMissing If we should throw an exception if the file can't be found */ + @Deprecated public StrutsXmlConfigurationProvider(boolean errorIfMissing) { this("struts.xml", errorIfMissing, null); } @@ -75,7 +76,7 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider { super(filename, errorIfMissing); this.servletContext = ctx; this.filename = filename; - reloadKey = "configurationReload-"+filename; + reloadKey = "configurationReload-" + filename; Map dtdMappings = new HashMap(getDtdMappings()); dtdMappings.put("-//Apache Software Foundation//DTD Struts Configuration 2.0//EN", "struts-2.0.dtd"); dtdMappings.put("-//Apache Software Foundation//DTD Struts Configuration 2.1//EN", "struts-2.1.dtd"); diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java index eeb813f9f..8d7b5fbed 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java @@ -446,7 +446,7 @@ public class Dispatcher { String[] classes = configClasses.split("\\s*[,]\\s*"); for (String cname : classes) { try { - Class cls = ClassLoaderUtil.loadClass(cname, this.getClass()); + Class cls = ClassLoaderUtil.loadClass(cname, this.getClass()); StrutsJavaConfiguration config = (StrutsJavaConfiguration) cls.newInstance(); configurationManager.addContainerProvider(createJavaConfigurationProvider(config)); } catch (InstantiationException e) { diff --git a/core/src/main/resources/struts-default.xml b/core/src/main/resources/struts-default.xml index 8d30cf4d3..045d453c9 100644 --- a/core/src/main/resources/struts-default.xml +++ b/core/src/main/resources/struts-default.xml @@ -31,8 +31,8 @@ and {@link com.opensymphony.xwork2.inject.Inject} --> + "-//Apache Software Foundation//DTD Struts Configuration 2.6//EN" + "http://struts.apache.org/dtds/struts-2.6.dtd"> @@ -401,10 +401,10 @@ false false - + - + same-origin diff --git a/core/src/main/resources/xwork-1.0.dtd b/core/src/main/resources/xwork-1.0.dtd deleted file mode 100644 index 23661a186..000000000 --- a/core/src/main/resources/xwork-1.0.dtd +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-1.1.1.dtd b/core/src/main/resources/xwork-1.1.1.dtd deleted file mode 100644 index c8b01b4b1..000000000 --- a/core/src/main/resources/xwork-1.1.1.dtd +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-1.1.2.dtd b/core/src/main/resources/xwork-1.1.2.dtd deleted file mode 100644 index 296c8a5b3..000000000 --- a/core/src/main/resources/xwork-1.1.2.dtd +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-1.1.dtd b/core/src/main/resources/xwork-1.1.dtd deleted file mode 100644 index f1fbfd7b0..000000000 --- a/core/src/main/resources/xwork-1.1.dtd +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-2.0.dtd b/core/src/main/resources/xwork-2.0.dtd deleted file mode 100644 index c9c3b3bfa..000000000 --- a/core/src/main/resources/xwork-2.0.dtd +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-2.1.3.dtd b/core/src/main/resources/xwork-2.1.3.dtd deleted file mode 100644 index bce8e2315..000000000 --- a/core/src/main/resources/xwork-2.1.3.dtd +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-2.1.dtd b/core/src/main/resources/xwork-2.1.dtd deleted file mode 100644 index 40db431ca..000000000 --- a/core/src/main/resources/xwork-2.1.dtd +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-2.3.dtd b/core/src/main/resources/xwork-2.3.dtd deleted file mode 100644 index 2a81073d2..000000000 --- a/core/src/main/resources/xwork-2.3.dtd +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-2.5.dtd b/core/src/main/resources/xwork-2.5.dtd deleted file mode 100644 index 4d61e8a4f..000000000 --- a/core/src/main/resources/xwork-2.5.dtd +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/xwork-2.6.dtd b/core/src/main/resources/xwork-2.6.dtd deleted file mode 100644 index ba6dddf67..000000000 --- a/core/src/main/resources/xwork-2.6.dtd +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/src/test/java/com/opensymphony/xwork2/util/ClassLoaderUtilTest.java b/core/src/test/java/com/opensymphony/xwork2/util/ClassLoaderUtilTest.java index b3ef289a6..90cc5f1bf 100644 --- a/core/src/test/java/com/opensymphony/xwork2/util/ClassLoaderUtilTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/util/ClassLoaderUtilTest.java @@ -39,26 +39,26 @@ public class ClassLoaderUtilTest extends TestCase { } public void testGetResources_Multiple() throws IOException { - Iterator i = ClassLoaderUtil.getResources("xwork-1.0.dtd", ClassLoaderUtilTest.class, false); + Iterator i = ClassLoaderUtil.getResources("struts-2.0.dtd", ClassLoaderUtilTest.class, false); assertNotNull(i); assertTrue(i.hasNext()); URL url = i.next(); - assertTrue(url.toString().endsWith("xwork-1.0.dtd")); + assertTrue(url.toString().endsWith("struts-2.0.dtd")); url = i.next(); - assertTrue(url.toString().endsWith("xwork-1.0.dtd")); + assertTrue(url.toString().endsWith("struts-2.0.dtd")); assertTrue(!i.hasNext()); } public void testGetResources_Aggregate() throws IOException { - Iterator i = ClassLoaderUtil.getResources("xwork-1.0.dtd", ClassLoaderUtilTest.class, true); + Iterator i = ClassLoaderUtil.getResources("struts-2.0.dtd", ClassLoaderUtilTest.class, true); assertNotNull(i); assertTrue(i.hasNext()); URL url = i.next(); - assertTrue(url.toString().endsWith("xwork-1.0.dtd")); + assertTrue(url.toString().endsWith("struts-2.0.dtd")); url = i.next(); - assertTrue(url.toString().endsWith("xwork-1.0.dtd")); + assertTrue(url.toString().endsWith("struts-2.0.dtd")); assertTrue(!i.hasNext()); } diff --git a/core/src/test/java/org/apache/struts2/interceptor/FetchMetadataInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/FetchMetadataInterceptorTest.java index 2249077c5..7d7c4bd21 100644 --- a/core/src/test/java/org/apache/struts2/interceptor/FetchMetadataInterceptorTest.java +++ b/core/src/test/java/org/apache/struts2/interceptor/FetchMetadataInterceptorTest.java @@ -18,7 +18,6 @@ */ package org.apache.struts2.interceptor; - import static org.apache.struts2.interceptor.ResourceIsolationPolicy.DEST_EMBED; import static org.apache.struts2.interceptor.ResourceIsolationPolicy.DEST_OBJECT; import static org.apache.struts2.interceptor.ResourceIsolationPolicy.DEST_SCRIPT; @@ -43,6 +42,7 @@ import com.opensymphony.xwork2.config.entities.PackageConfig; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import com.opensymphony.xwork2.mock.MockActionInvocation; import org.apache.struts2.ServletActionContext; +import org.apache.struts2.config.StrutsXmlConfigurationProvider; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; @@ -155,7 +155,7 @@ public class FetchMetadataInterceptorTest extends XWorkTestCase { // Perform a multi-step test to confirm (indirectly) that the method parameter injection of setExemptedPaths() for // the FetchMetadataInterceptor is functioning as expected, when configured appropriately. // Ensure we're using the specific test configuration, not the default simple configuration. - XmlConfigurationProvider configurationProvider = new XmlConfigurationProvider("struts-testing.xml"); + XmlConfigurationProvider configurationProvider = new StrutsXmlConfigurationProvider("struts-testing.xml"); container.inject(configurationProvider); loadConfigurationProviders(configurationProvider); diff --git a/core/src/test/resources/org/apache/struts2/dispatcher/ng/struts-no-op.xml b/core/src/test/resources/org/apache/struts2/dispatcher/ng/struts-no-op.xml index 28c0d656a..55a8f3206 100644 --- a/core/src/test/resources/org/apache/struts2/dispatcher/ng/struts-no-op.xml +++ b/core/src/test/resources/org/apache/struts2/dispatcher/ng/struts-no-op.xml @@ -20,6 +20,6 @@ */ --> + "-//Apache Software Foundation//DTD Struts Configuration 2.6//EN" + "http://struts.apache.org/dtds/struts-2.6.dtd"> \ No newline at end of file diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/WW3090-struts.xml b/core/src/test/resources/org/apache/struts2/views/jsp/WW3090-struts.xml index c6e256f82..8e23a208f 100644 --- a/core/src/test/resources/org/apache/struts2/views/jsp/WW3090-struts.xml +++ b/core/src/test/resources/org/apache/struts2/views/jsp/WW3090-struts.xml @@ -21,8 +21,8 @@ --> + "-//Apache Software Foundation//DTD Struts Configuration 2.6//EN" + "http://struts.apache.org/dtds/struts-2.6.dtd"> diff --git a/core/src/test/resources/xwork-1.0.dtd b/core/src/test/resources/struts-2.0.dtd similarity index 100% rename from core/src/test/resources/xwork-1.0.dtd rename to core/src/test/resources/struts-2.0.dtd diff --git a/core/src/test/resources/struts.xml b/core/src/test/resources/struts.xml index cae2eb88b..ca6609e75 100644 --- a/core/src/test/resources/struts.xml +++ b/core/src/test/resources/struts.xml @@ -20,8 +20,8 @@ */ --> + "-//Apache Software Foundation//DTD Struts Configuration 2.6//EN" + "http://struts.apache.org/dtds/struts-2.6.dtd">