File tree Expand file tree Collapse file tree
commons-vfs2/src/test/java/org/apache/commons/vfs2/impl Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments