Skip to content

Commit

Permalink
Avoid file leak in JavaSPIExtensionLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangHG committed Oct 26, 2024
1 parent a5129ff commit db1d8fb
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collection;
import java.util.Enumeration;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -166,7 +167,10 @@ private <T> Set<Class<? extends T>> load(Class<T> serviceClass, ClassLoader load
Enumeration<URL> enumeration = loader.getResources(serviceFile);
while (enumeration.hasMoreElements()) {
final URL url = enumeration.nextElement();
final InputStream is = url.openStream();
URLConnection jarConnection = url.openConnection();
//Don't cache the file (avoids file leaks on GlassFish).
jarConnection.setUseCaches(false);
final InputStream is = jarConnection.getInputStream();
BufferedReader reader = null;

try {
Expand Down

0 comments on commit db1d8fb

Please sign in to comment.