You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2017/03/03 11:54:46 UTC
svn commit: r1785271 - in /tomcat/trunk:
java/org/apache/tomcat/util/scan/AbstractInputStreamJar.java
test/org/apache/tomcat/util/scan/TestAbstractInputStreamJar.java
webapps/docs/changelog.xml
Author: markt
Date: Fri Mar 3 11:54:46 2017
New Revision: 1785271
URL: http://svn.apache.org/viewvc?rev=1785271&view=rev
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=60798
Correct a bug in the handling of JARs in unpacked WARs that meant multiple attempts to read the same entry from a JAR in succession would fail for the second and subsequent attempts.
Added:
tomcat/trunk/test/org/apache/tomcat/util/scan/TestAbstractInputStreamJar.java
Modified:
tomcat/trunk/java/org/apache/tomcat/util/scan/AbstractInputStreamJar.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/tomcat/util/scan/AbstractInputStreamJar.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/scan/AbstractInputStreamJar.java?rev=1785271&r1=1785270&r2=1785271&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/scan/AbstractInputStreamJar.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/scan/AbstractInputStreamJar.java Fri Mar 3 11:54:46 2017
@@ -93,6 +93,10 @@ public abstract class AbstractInputStrea
if (entry == null) {
return null;
} else {
+ // Clear the entry so that multiple calls to this method for the
+ // same entry will result in a new InputStream for each call
+ // (BZ 60798)
+ entry = null;
return jarInputStream;
}
}
Added: tomcat/trunk/test/org/apache/tomcat/util/scan/TestAbstractInputStreamJar.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/scan/TestAbstractInputStreamJar.java?rev=1785271&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/scan/TestAbstractInputStreamJar.java (added)
+++ tomcat/trunk/test/org/apache/tomcat/util/scan/TestAbstractInputStreamJar.java Fri Mar 3 11:54:46 2017
@@ -0,0 +1,59 @@
+/*
+ * 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 org.apache.tomcat.util.scan;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.catalina.util.IOTools;
+import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
+import org.apache.tomcat.Jar;
+
+public class TestAbstractInputStreamJar {
+
+ @Before
+ public void register() {
+ TomcatURLStreamHandlerFactory.register();
+ }
+
+
+ @Test
+ public void testNestedJarGetInputStream() throws Exception {
+ File f = new File("test/webresources/war-url-connection.war");
+ StringBuilder sb = new StringBuilder("war:");
+ sb.append(f.toURI().toURL());
+ sb.append("*/WEB-INF/lib/test.jar");
+
+ Jar jar = JarFactory.newInstance(new URL(sb.toString()));
+
+ InputStream is1 = jar.getInputStream("META-INF/resources/index.html");
+ ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
+ IOTools.flow(is1, baos1);
+
+ InputStream is2 = jar.getInputStream("META-INF/resources/index.html");
+ ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
+ IOTools.flow(is2, baos2);
+
+ Assert.assertArrayEquals(baos1.toByteArray(), baos2.toByteArray());
+ }
+}
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1785271&r1=1785270&r2=1785271&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Mar 3 11:54:46 2017
@@ -136,6 +136,11 @@
application. Note that the Servlet 4.0 API is still a work in progress
and further changes are likely. (markt)
</update>
+ <fix>
+ <bug>60798</bug>: Correct a bug in the handling of JARs in unpacked WARs
+ that meant multiple attempts to read the same entry from a JAR in
+ succession would fail for the second and subsequent attempts. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org