Skip to content

Commit bb1c101

Browse files
committed
Refactor to avoid reproducibility issues due to zip task ordering
Ant's zip task orders the entires based OS file names. '/' and '\' have very different ordering so reafctor to directory names that are not affected by this so zip files are consistent across Linux and Windows.
1 parent 6619854 commit bb1c101

30 files changed

+26
-21
lines changed

test/org/apache/catalina/core/TestStandardWrapper.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public void testSecurityAnnotationsNoWebXmlConstraints() throws Exception {
191191
// Setup Tomcat instance
192192
Tomcat tomcat = getTomcatInstance();
193193

194-
File appDir = new File("test/webapp-servletsecurity");
194+
File appDir = new File("test/webapp-servletsecurity-a");
195195
tomcat.addWebapp(null, "", appDir.getAbsolutePath());
196196

197197
tomcat.start();
@@ -210,7 +210,7 @@ public void testSecurityAnnotationsNoWebXmlLoginConfig() throws Exception {
210210
// Setup Tomcat instance
211211
Tomcat tomcat = getTomcatInstance();
212212

213-
File appDir = new File("test/webapp-servletsecurity2");
213+
File appDir = new File("test/webapp-servletsecurity-b");
214214
tomcat.addWebapp(null, "", appDir.getAbsolutePath());
215215

216216
tomcat.start();

test/org/apache/catalina/loader/TestVirtualContext.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void testVirtualClassLoader() throws Exception {
5858

5959
Tomcat tomcat = getTomcatInstance();
6060

61-
File appDir = new File("test/webapp-virtual-webapp/src/main/webapp");
61+
File appDir = new File("test/webapp-virtual-webapp/src/main/webapp-a");
6262
// app dir is relative to server home
6363
StandardContext ctx = (StandardContext) tomcat.addWebapp(null, "/test",
6464
appDir.getAbsolutePath());
@@ -67,11 +67,11 @@ public void testVirtualClassLoader() throws Exception {
6767
File f1 = new File("test/webapp-virtual-webapp/target/classes");
6868
File f2 = new File("test/webapp-virtual-library/target/WEB-INF");
6969
File f3 = new File(
70-
"test/webapp-virtual-webapp/src/main/webapp/WEB-INF/classes");
70+
"test/webapp-virtual-webapp/src/main/webapp-a/WEB-INF/classes");
7171
File f4 = new File(
72-
"test/webapp-virtual-webapp/src/main/webapp2/WEB-INF/classes");
72+
"test/webapp-virtual-webapp/src/main/webapp-b/WEB-INF/classes");
7373
File f5 = new File("test/webapp-virtual-webapp/src/main/misc");
74-
File f6 = new File("test/webapp-virtual-webapp/src/main/webapp2");
74+
File f6 = new File("test/webapp-virtual-webapp/src/main/webapp-b");
7575
ctx.getResources().createWebResourceSet(
7676
WebResourceRoot.ResourceSetType.POST, "/WEB-INF/classes",
7777
f1.getAbsolutePath(), null, "/");
@@ -143,13 +143,13 @@ public void testVirtualClassLoader() throws Exception {
143143
"/test/classpathGetResources.jsp?path=rsrc/").toString();
144144
Assert.assertTrue(
145145
allUrls,
146-
allUrls.indexOf("/test/webapp-virtual-webapp/src/main/webapp/WEB-INF/classes/rsrc") > 0);
146+
allUrls.indexOf("/test/webapp-virtual-webapp/src/main/webapp-a/WEB-INF/classes/rsrc") > 0);
147147
Assert.assertTrue(
148148
allUrls,
149-
allUrls.indexOf("/test/webapp-virtual-webapp/src/main/webapp2/WEB-INF/classes/rsrc") > 0);
149+
allUrls.indexOf("/test/webapp-virtual-webapp/src/main/webapp-b/WEB-INF/classes/rsrc") > 0);
150150
Assert.assertTrue(
151151
allUrls,
152-
allUrls.indexOf("/test/webapp-virtual-webapp/src/main/webapp/WEB-INF/lib/rsrc.jar!/rsrc") > 0);
152+
allUrls.indexOf("/test/webapp-virtual-webapp/src/main/webapp-a/WEB-INF/lib/rsrc.jar!/rsrc") > 0);
153153
Assert.assertTrue(
154154
allUrls,
155155
allUrls.indexOf("/test/webapp-virtual-webapp/target/classes/rsrc") > 0);
@@ -165,10 +165,10 @@ public void testVirtualClassLoader() throws Exception {
165165
String allRsrsc2ClasspathUrls =
166166
getUrl(
167167
"http://localhost:" + getPort() +
168-
"/test/classpathGetResources.jsp?path=rsrc2/").toString();
168+
"/test/classpathGetResources.jsp?path=rsrc-2/").toString();
169169
Assert.assertTrue(
170170
allRsrsc2ClasspathUrls,
171-
allRsrsc2ClasspathUrls.indexOf("/test/webapp-virtual-webapp/src/main/webapp2/WEB-INF/classes/rsrc2") > 0);
171+
allRsrsc2ClasspathUrls.indexOf("/test/webapp-virtual-webapp/src/main/webapp-b/WEB-INF/classes/rsrc-2") > 0);
172172

173173
// tests context.getRealPath
174174

@@ -180,7 +180,7 @@ public void testVirtualClassLoader() throws Exception {
180180
// Real paths depend on the OS and this test has to work on all
181181
// platforms so use File to convert the path to a platform specific form
182182
File f = new File(
183-
"test/webapp-virtual-webapp/src/main/webapp/rsrc/resourceF.properties");
183+
"test/webapp-virtual-webapp/src/main/webapp-a/rsrc/resourceF.properties");
184184
assertPageContains(
185185
"/test/contextGetRealPath.jsp?path=/rsrc/resourceF.properties",
186186
f.getPath());
@@ -202,7 +202,7 @@ public void testVirtualClassLoader() throws Exception {
202202
"/test/contextGetResource.jsp?path=/other/resourceI.properties",
203203
"resourceIInWebapp=true");
204204
assertPageContains(
205-
"/test/contextGetResource.jsp?path=/rsrc2/resourceJ.properties",
205+
"/test/contextGetResource.jsp?path=/rsrc-2/resourceJ.properties",
206206
"resourceJInWebapp=true");
207207

208208
String allRsrcPaths =
@@ -227,10 +227,10 @@ public void testVirtualClassLoader() throws Exception {
227227
String allRsrc2Paths =
228228
getUrl(
229229
"http://localhost:" + getPort() +
230-
"/test/contextGetResourcePaths.jsp?path=/rsrc2/").toString();
230+
"/test/contextGetResourcePaths.jsp?path=/rsrc-2/").toString();
231231
Assert.assertTrue(
232232
allRsrc2Paths,
233-
allRsrc2Paths.indexOf("/rsrc2/resourceJ.properties") > 0);
233+
allRsrc2Paths.indexOf("/rsrc-2/resourceJ.properties") > 0);
234234

235235
assertPageContains(
236236
"/test/testTlds.jsp",
@@ -250,7 +250,7 @@ public void testVirtualClassLoader() throws Exception {
250250
public void testAdditionalWebInfClassesPaths() throws Exception {
251251
Tomcat tomcat = getTomcatInstance();
252252

253-
File appDir = new File("test/webapp-virtual-webapp/src/main/webapp");
253+
File appDir = new File("test/webapp-virtual-webapp/src/main/webapp-a");
254254
// app dir is relative to server home
255255
StandardContext ctx = (StandardContext) tomcat.addWebapp(null, "/test",
256256
appDir.getAbsolutePath());

test/webapp-virtual-webapp/src/main/webapp2/rsrc/resourceF.properties renamed to test/webapp-virtual-webapp/src/main/webapp-b/rsrc/resourceF.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
# limitations under the License.
1515

1616
This file should not be served, it is masked by
17-
/test/webapp-virtual-webapp/src/main/webapp/rsrc/resourceF.properties
17+
/test/webapp-virtual-webapp/src/main/webapp-a/rsrc/resourceF.properties

webapps/docs/changelog.xml

+5
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@
120120
Remove the applet example from the example web application as applets
121121
are no longer supported in any major browser. (markt)
122122
</fix>
123+
<scode>
124+
Refactor a small number of pages in the examples web application to
125+
avoid an issue with reproducible builds due to differences in file
126+
ordering across different operating systems with Ant's zip task. (markt)
127+
</scode>
123128
</changelog>
124129
</subsection>
125130
</section>

webapps/examples/WEB-INF/web.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
http://tomcat.apache.org/jsp2-example-taglib
212212
</taglib-uri>
213213
<taglib-location>
214-
/WEB-INF/jsp2/jsp2-example-taglib.tld
214+
/WEB-INF/jsp/jsp2-example-taglib.tld
215215
</taglib-location>
216216
</taglib>
217217

webapps/examples/jsp/jsp2/simpletag/book.jsp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
--%>
17-
<%@ taglib prefix="my" uri="/WEB-INF/jsp2/jsp2-example-taglib.tld" %>
17+
<%@ taglib prefix="my" uri="/WEB-INF/jsp/jsp2-example-taglib.tld" %>
1818
<html>
1919
<head>
2020
<title>JSP 2.0 Examples - Book SimpleTag Handler</title>

webapps/examples/jsp/jsp2/simpletag/hello.jsp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
--%>
17-
<%@ taglib prefix="mytag" uri="/WEB-INF/jsp2/jsp2-example-taglib.tld" %>
17+
<%@ taglib prefix="mytag" uri="/WEB-INF/jsp/jsp2-example-taglib.tld" %>
1818
<html>
1919
<head>
2020
<title>JSP 2.0 Examples - Hello World SimpleTag Handler</title>

webapps/examples/jsp/jsp2/simpletag/repeat.jsp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
--%>
17-
<%@ taglib prefix="mytag" uri="/WEB-INF/jsp2/jsp2-example-taglib.tld" %>
17+
<%@ taglib prefix="mytag" uri="/WEB-INF/jsp/jsp2-example-taglib.tld" %>
1818
<html>
1919
<head>
2020
<title>JSP 2.0 Examples - Repeat SimpleTag Handler</title>

0 commit comments

Comments
 (0)