Index: src/java/org/apache/commons/compress/bzip2/CBZip2InputStream.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons-sandbox/compress/src/java/org/apache/commons/compress/bzip2/CBZip2InputStream.java,v
retrieving revision 1.2
diff -u -r1.2 CBZip2InputStream.java
--- src/java/org/apache/commons/compress/bzip2/CBZip2InputStream.java	27 Feb 2004 03:41:36 -0000	1.2
+++ src/java/org/apache/commons/compress/bzip2/CBZip2InputStream.java	11 Sep 2005 09:06:07 -0000
@@ -177,6 +177,11 @@
         }
     }
 
+    public void close() throws java.io.IOException
+    {
+        bsFinishedWithStream();
+    }
+
     private void setDecompressStructureSizes( int newSize100k )
     {
         if( !( 0 <= newSize100k && newSize100k <= 9 && 0 <= m_blockSize100k
@@ -624,6 +629,16 @@
 
     private void bsFinishedWithStream()
     {
+        if (m_input != null)
+        {
+            try
+            {
+                m_input.close();
+            }
+            catch ( IOException e )
+            {
+            }
+        }
         m_input = null;
     }
 
Index: src/test/org/apache/commons/compress/bzip2/test/BzipTestCase.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons-sandbox/compress/src/test/org/apache/commons/compress/bzip2/test/BzipTestCase.java,v
retrieving revision 1.2
diff -u -r1.2 BzipTestCase.java
--- src/test/org/apache/commons/compress/bzip2/test/BzipTestCase.java	27 Feb 2004 03:41:37 -0000	1.2
+++ src/test/org/apache/commons/compress/bzip2/test/BzipTestCase.java	11 Sep 2005 09:06:07 -0000
@@ -83,6 +83,30 @@
         forceDelete( outputFile );
     }
 
+    public void testCBZip2InputStreamClose()
+        throws Exception
+    {
+        final InputStream input = getInputStream( "asf-logo-huge.tar.bz2" );
+        final File outputFile = getOutputFile( ".tar.bz2" );
+        final OutputStream output = new FileOutputStream( outputFile );
+        copy( input, output );
+        shutdownStream( input );
+        shutdownStream( output );
+        assertTrue( "Check output file exists." , outputFile.exists() );
+        final InputStream input2 = new FileInputStream( outputFile );
+        final InputStream packedInput = getPackedInput( input2 );
+        shutdownStream( packedInput );
+        try
+        {
+            input2.read();
+            assertTrue("Source input stream is still opened.", false);
+        } catch ( Exception e )
+        {
+            // Read closed stream.
+        }
+        forceDelete( outputFile );
+    }
+
     /**
      * Copy bytes from an <code>InputStream</code> to an <code>OutputStream</code>.
      */
