]> source.dussan.org Git - jgit.git/commitdiff
Fix unit tests under windows 85/1185/2
authorChristian Halstrick <christian.halstrick@sap.com>
Wed, 28 Jul 2010 11:29:18 +0000 (13:29 +0200)
committerShawn O. Pearce <spearce@spearce.org>
Wed, 28 Jul 2010 18:55:11 +0000 (11:55 -0700)
the following tests fail under windows because certain inputstreams
are not closed and files cannot be deleted because of that.  The
main problem I found is UnpackedObject.InflaterInputStream.close().
This method may throw exceptions found by checkValidEndOfStream()
but doesn't call super.close() before leaving. It is not clear to me
which resources a close() method should release before it throws an
exception. But those reseources which are not published to the
outside and which therefore cannot be closed by other means have to
be closed in all cases.
I changed the close() method to call super.close() under all
circumstances.

failing tests:
  testStandardFormat_LargeObject_TruncatedZLibStream(org.eclipse.jgit.storage.file.UnpackedObjectTest)
  testStandardFormat_LargeObject_TrailingGarbage(org.eclipse.jgit.storage.file.UnpackedObjectTest)
  testPackFormat_SmallObject(org.eclipse.jgit.storage.file.UnpackedObjectTest)

Change-Id: Id2e609a29e725aad953ff9bd88af6381df38399d
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/UnpackedObject.java

index 59f9c826702ffa55e95f17f70dc48b95a7b130fc..78e7b10a7dc0eb440a5a37aff746f4c374dd3507 100644 (file)
@@ -296,9 +296,9 @@ public class UnpackedObject {
                                try {
                                        if (remaining <= 0)
                                                checkValidEndOfStream(in, inf, id, new byte[64]);
-                                       super.close();
                                } finally {
                                        InflaterCache.release(inf);
+                                       super.close();
                                }
                        }
                };