8280010: Remove double buffering of InputStream for Properties.load

Reviewed-by: amenkov, sspitsyn, serb
This commit is contained in:
Andrey Turbanov 2022-01-18 15:49:03 +00:00
parent 64c0c0e109
commit 9eb50a5ee4
8 changed files with 19 additions and 30 deletions

View File

@ -91,8 +91,7 @@ public final class Security {
if (propFile.exists()) {
InputStream is = null;
try {
FileInputStream fis = new FileInputStream(propFile);
is = new BufferedInputStream(fis);
is = new FileInputStream(propFile);
props.load(is);
loadedProps = true;
@ -140,7 +139,7 @@ public final class Security {
// now load the user-specified file so its values
// will win if they conflict with the earlier values
if (extraPropFile != null) {
BufferedInputStream bis = null;
InputStream is = null;
try {
URL propURL;
@ -152,8 +151,8 @@ public final class Security {
} else {
propURL = new URL(extraPropFile);
}
bis = new BufferedInputStream(propURL.openStream());
props.load(bis);
is = propURL.openStream();
props.load(is);
loadedProps = true;
if (sdebug != null) {
@ -172,9 +171,9 @@ public final class Security {
e.printStackTrace();
}
} finally {
if (bis != null) {
if (is != null) {
try {
bis.close();
is.close();
} catch (IOException ioe) {
if (sdebug != null) {
sdebug.println("unable to close input stream");

View File

@ -68,9 +68,8 @@ public class NetProperties {
File f = new File(fname, "conf");
f = new File(f, "net.properties");
fname = f.getCanonicalPath();
try (FileInputStream in = new FileInputStream(fname);
BufferedInputStream bin = new BufferedInputStream(in)) {
props.load(bin);
try (FileInputStream in = new FileInputStream(fname)) {
props.load(in);
}
} catch (Exception e) {
// Do nothing. We couldn't find or access the file

View File

@ -244,8 +244,8 @@ public class MimeTable implements FileNameMap {
throw new InternalError("default mime table not found");
}
try (BufferedInputStream bin = new BufferedInputStream(in)) {
entries.load(bin);
try (in) {
entries.load(in);
} catch (IOException e) {
System.err.println("Warning: " + e.getMessage());
}

View File

@ -394,10 +394,8 @@ public class PSPrinterJob extends RasterPrinterJob {
// Load property file
Properties props = new Properties();
try (FileInputStream is = new FileInputStream(f.getPath());
BufferedInputStream bis = new BufferedInputStream(is))
{
props.load(bis);
try (FileInputStream in = new FileInputStream(f.getPath())) {
props.load(in);
}
return props;
} catch (Exception e){

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -1381,8 +1381,7 @@ public class LogManager {
String fname = getConfigurationFileName();
try (final InputStream in = new FileInputStream(fname)) {
final BufferedInputStream bin = new BufferedInputStream(in);
readConfiguration(bin);
readConfiguration(in);
}
}
@ -1877,8 +1876,7 @@ public class LogManager {
String fname = getConfigurationFileName();
try (final InputStream in = new FileInputStream(fname)) {
final BufferedInputStream bin = new BufferedInputStream(in);
updateConfiguration(bin, mapper);
updateConfiguration(in, mapper);
}
}

View File

@ -164,11 +164,8 @@ public class FuncSystemProperty extends FunctionOneArg
try
{
// Use SecuritySupport class to provide privileged access to property file
InputStream is = SecuritySupport.getResourceAsStream(XSLT_PROPERTIES);
// get a buffered version
try (BufferedInputStream bis = new BufferedInputStream(is)) {
target.load(bis); // and load up the property bag from this
try (InputStream is = SecuritySupport.getResourceAsStream(XSLT_PROPERTIES)) {
target.load(is); // and load up the property bag from this
}
}
catch (Exception ex)

View File

@ -564,8 +564,7 @@ public class Agent {
InputStream in = null;
try {
in = new FileInputStream(configFile);
BufferedInputStream bin = new BufferedInputStream(in);
p.load(bin);
p.load(in);
} catch (FileNotFoundException e) {
error(CONFIG_FILE_OPEN_FAILED, e.getMessage());
} catch (IOException e) {

View File

@ -692,8 +692,7 @@ public final class ConnectorBootstrap {
// Load the SSL keystore properties from the config file
Properties p = new Properties();
try (InputStream in = new FileInputStream(sslConfigFileName)) {
BufferedInputStream bin = new BufferedInputStream(in);
p.load(bin);
p.load(in);
}
String keyStore =
p.getProperty("javax.net.ssl.keyStore");