ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r392045 - in /ant/core/trunk: CONTRIBUTORS contributors.xml src/main/org/apache/tools/tar/TarOutputStream.java src/testcases/org/apache/tools/tar/TarOutputStreamTest.java
Date Thu, 06 Apr 2006 19:25:29 GMT
Author: bodewig
Date: Thu Apr  6 12:25:26 2006
New Revision: 392045

URL: http://svn.apache.org/viewcvs?rev=392045&view=rev
Log:
allow TarOutputStream to be closed more than once, PR 38027

Added:
    ant/core/trunk/src/testcases/org/apache/tools/tar/TarOutputStreamTest.java   (with props)
Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/contributors.xml
    ant/core/trunk/src/main/org/apache/tools/tar/TarOutputStream.java

Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewcvs/ant/core/trunk/CONTRIBUTORS?rev=392045&r1=392044&r2=392045&view=diff
==============================================================================
Binary files - no diff available.

Modified: ant/core/trunk/contributors.xml
URL: http://svn.apache.org/viewcvs/ant/core/trunk/contributors.xml?rev=392045&r1=392044&r2=392045&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Thu Apr  6 12:25:26 2006
@@ -699,6 +699,9 @@
     <last>Rossmueller</last>
   </name>
   <name>
+    <first>&#216;ystein</first>
+    <last>Gisn&#229;s</last>
+  <name>
     <first>Patrick</first>
     <last>C.</last>
   </name>

Modified: ant/core/trunk/src/main/org/apache/tools/tar/TarOutputStream.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/tar/TarOutputStream.java?rev=392045&r1=392044&r2=392045&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/tar/TarOutputStream.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/tar/TarOutputStream.java Thu Apr  6 12:25:26
2006
@@ -1,5 +1,5 @@
 /*
- * Copyright  2000-2002,2004-2005 The Apache Software Foundation
+ * Copyright  2000-2002,2004-2006 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -52,6 +52,8 @@
     protected byte[]    assemBuf;
     protected TarBuffer buffer;
     protected int       longFileMode = LONGFILE_ERROR;
+    
+    private boolean closed = false;
 
     /**
      * Constructor for TarInputStream.
@@ -136,8 +138,12 @@
      * @throws IOException on error
      */
     public void close() throws IOException {
-        this.finish();
-        this.buffer.close();
+        if (!closed) {
+            this.finish();
+            this.buffer.close();
+            out.close();
+            closed = true;
+        }
     }
 
     /**

Added: ant/core/trunk/src/testcases/org/apache/tools/tar/TarOutputStreamTest.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/testcases/org/apache/tools/tar/TarOutputStreamTest.java?rev=392045&view=auto
==============================================================================
--- ant/core/trunk/src/testcases/org/apache/tools/tar/TarOutputStreamTest.java (added)
+++ ant/core/trunk/src/testcases/org/apache/tools/tar/TarOutputStreamTest.java Thu Apr  6
12:25:26 2006
@@ -0,0 +1,33 @@
+/*
+ * Copyright  2006 The Apache Software Foundation
+ *
+ *  Licensed 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.tools.tar;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+public class TarOutputStreamTest extends TestCase {
+
+    public void testClose() throws IOException {
+        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+        TarOutputStream stream = new TarOutputStream(byteStream);
+        stream.close();
+        stream.close();
+    }
+}

Propchange: ant/core/trunk/src/testcases/org/apache/tools/tar/TarOutputStreamTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message