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());
}