Skip to content

Commit 1520ff4

Browse files
committed
Issue #2: JAR entry not found when JAR is updated inline and cached by
URLConnection
1 parent 448f848 commit 1520ff4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoURLResource.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.IOException;
2121
import java.io.InputStream;
2222
import java.net.URL;
23+
import java.net.URLConnection;
2324

2425
public abstract class PlexusIoURLResource
2526
extends AbstractPlexusIoResource
@@ -37,7 +38,9 @@ public InputStream getContents()
3738
final URL url = getURL();
3839
try
3940
{
40-
return url.openStream();
41+
URLConnection uc = url.openConnection();
42+
uc.setUseCaches( false );
43+
return uc.getInputStream();
4144
}
4245
catch ( IOException e )
4346
{
@@ -53,4 +56,4 @@ public String getDescriptionForError( URL url )
5356
}
5457

5558
public abstract URL getURL() throws IOException;
56-
}
59+
}

src/test/java/org/codehaus/plexus/components/io/filemappers/ResourcesTest.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.FileOutputStream;
2323
import java.io.IOException;
2424
import java.io.InputStream;
25+
import java.net.URLConnection;
2526
import java.util.Iterator;
2627
import java.util.zip.ZipEntry;
2728
import java.util.zip.ZipOutputStream;
@@ -146,7 +147,9 @@ private void compare( PlexusIoResource res, File file )
146147
InputStream in = res.getContents();
147148
compare( in, file );
148149
in.close();
149-
in = res.getURL().openStream();
150+
URLConnection uc = res.getURL().openConnection();
151+
uc.setUseCaches( false );
152+
in = uc.getInputStream();
150153
compare( in, file );
151154
in.close();
152155
}

0 commit comments

Comments
 (0)