Skip to content

Commit

Permalink
Load timezone resources in doPrivileged block
Browse files Browse the repository at this point in the history
Fix test to compile
Ensure system classpath also wrapped
  • Loading branch information
jodastephen committed May 22, 2016
1 parent b286423 commit 2acaddc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 2 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Changes in 2.9.4
----------------
- DateTimeZone data updated to version 2016d

- Loading time-zone provider now occurs in a priveleged block [#327, #375]


Changes in 2.9.3
----------------
Expand Down
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@
<name>Grzegorz Swierczynski</name>
<url>https://github.com/gswierczynski</url>
</contributor>
<contributor>
<name>Jason Tedor</name>
<url>https://github.com/jasontedor</url>
</contributor>
<contributor>
<name>Ricardo Trindade</name>
</contributor>
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/joda/time/tz/ZoneInfoProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ private InputStream openResource(String name) throws IOException {
in = new FileInputStream(new File(iFileDir, name));
} else {
final String path = iResourcePath.concat(name);
if (iLoader != null) {
in = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
public InputStream run() {
in = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
public InputStream run() {
if (iLoader != null) {
return iLoader.getResourceAsStream(path);
} else {
return ClassLoader.getSystemResourceAsStream(path);
}
});
} else {
in = ClassLoader.getSystemResourceAsStream(path);
}
}
});
if (in == null) {
StringBuilder buf = new StringBuilder(40)
.append("Resource not found: \"")
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/org/joda/time/TestDateTimeZone.java
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,15 @@ public void testZoneInfoProviderResourceLoading() {
final String id = ids.toArray(new String[ids.size()])[new Random().nextInt(ids.size())];
try {
Policy.setPolicy(new Policy() {
@Override
public PermissionCollection getPermissions(CodeSource codesource) {
Permissions p = new Permissions();
p.add(new AllPermission()); // enable everything
return p;
}
@Override
public void refresh() {
}
@Override
public boolean implies(ProtectionDomain domain, Permission permission) {
return !(permission instanceof FilePermission) && !permission.getName().contains(id);
Expand Down

0 comments on commit 2acaddc

Please sign in to comment.