Skip to content

Commit

Permalink
Disable caching for JarURLConnection to avoid sharing JarFile with ot…
Browse files Browse the repository at this point in the history
…her users when loading resource from URL in Configuration class. Contributed by Zhihai Xu
  • Loading branch information
Zhihai Xu committed Sep 18, 2015
1 parent 288c885 commit e690a32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions hadoop-common-project/hadoop-common/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,10 @@ Release 2.8.0 - UNRELEASED
HADOOP-12413. AccessControlList should avoid calling getGroupNames in
isUserInList with empty groups. (Zhihai Xu via cnauroth)

HADOOP-12404. Disable caching for JarURLConnection to avoid sharing
JarFile with other users when loading resource from URL in Configuration
class. (zxu)

OPTIMIZATIONS

HADOOP-11785. Reduce the number of listStatus operation in distcp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
import java.io.Writer;
import java.lang.ref.WeakReference;
import java.net.InetSocketAddress;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -2531,7 +2533,14 @@ private Document parse(DocumentBuilder builder, URL url)
if (url == null) {
return null;
}
return parse(builder, url.openStream(), url.toString());

URLConnection connection = url.openConnection();
if (connection instanceof JarURLConnection) {
// Disable caching for JarURLConnection to avoid sharing JarFile
// with other users.
connection.setUseCaches(false);
}
return parse(builder, connection.getInputStream(), url.toString());
}

private Document parse(DocumentBuilder builder, InputStream is,
Expand Down

0 comments on commit e690a32

Please sign in to comment.