Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id ED89C200C2C for ; Fri, 3 Mar 2017 12:54:54 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id EC1BE160B6D; Fri, 3 Mar 2017 11:54:54 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 403F1160B57 for ; Fri, 3 Mar 2017 12:54:54 +0100 (CET) Received: (qmail 84488 invoked by uid 500); 3 Mar 2017 11:54:48 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 84478 invoked by uid 99); 3 Mar 2017 11:54:48 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Mar 2017 11:54:48 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 4A9E33A086E for ; Fri, 3 Mar 2017 11:54:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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 Date: Fri, 03 Mar 2017 11:54:46 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170303115447.4A9E33A086E@svn01-us-west.apache.org> archived-at: Fri, 03 Mar 2017 11:54:55 -0000 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) + + 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. (markt) + --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org