Skip to content

Commit b2f9b50

Browse files
committed
re #VFS-834: pushed the test case as far as I could and denoted the
reason why additional step could not be taken
1 parent ca1728c commit b2f9b50

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

commons-vfs2/src/test/java/org/apache/commons/vfs2/impl/VfsClassLoaderTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,14 @@ public void testLoadResource() throws Exception {
204204

205205
// VFS-834: testing that getting the resource again does not close out the previous input stream.
206206
final URL resource2 = loader.getResource("read-tests/file1.txt");
207+
assertNotNull(resource2);
208+
final URLConnection urlCon2 = resource2.openConnection();
207209

208210
assertSameURLContent(FILE1_CONTENT, instr1, urlCon1);
209211

210-
assertNotNull(resource2);
211-
final URLConnection urlCon2 = resource2.openConnection();
212-
final InputStream instr2 = urlCon1.getInputStream();
212+
// For tar files, getting the second input stream will reset the input (see TarFileSystem.resetTarFile())
213+
// hence we need to actually get the input stream after asserting the contents of the first one.
214+
final InputStream instr2 = urlCon2.getInputStream();
213215

214216
assertSameURLContent(FILE1_CONTENT, instr2, urlCon2);
215217
}

0 commit comments

Comments
 (0)