Skip to content

Commit

Permalink
Merge pull request #781 from KyoriPowered/feature/no-securitymanager
Browse files Browse the repository at this point in the history
api: Remove use of terminally deprecated SecurityManager api
  • Loading branch information
zml2008 committed Jun 10, 2022
2 parents dd11802 + 7dd7c74 commit 7adc8e5
Showing 1 changed file with 12 additions and 21 deletions.
Expand Up @@ -29,9 +29,6 @@
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Locale;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
Expand Down Expand Up @@ -62,26 +59,20 @@ public ResourceBundle newBundle(final String baseName, final Locale locale, fina
if (format.equals("java.properties")) {
final String bundle = this.toBundleName(baseName, locale);
final String resource = this.toResourceName(bundle, "properties");
final InputStream is;
try {
is = AccessController.doPrivileged((PrivilegedExceptionAction<InputStream>) () -> {
if (reload) {
final URL url = loader.getResource(resource);
if (url != null) {
final URLConnection connection = url.openConnection();
if (connection != null) {
connection.setUseCaches(false);
return connection.getInputStream();
}
}
return null;
} else {
return loader.getResourceAsStream(resource);
InputStream is = null;
if (reload) {
final URL url = loader.getResource(resource);
if (url != null) {
final URLConnection connection = url.openConnection();
if (connection != null) {
connection.setUseCaches(false);
is = connection.getInputStream();
}
});
} catch (final PrivilegedActionException e) {
throw (IOException) e.getException();
}
} else {
is = loader.getResourceAsStream(resource);
}

if (is != null) {
try(final InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8)) {
return new PropertyResourceBundle(isr);
Expand Down

0 comments on commit 7adc8e5

Please sign in to comment.