8181105: Nashorn file descriptor leak
Reviewed-by: jlaskey, hannesw, sundar
This commit is contained in:
parent
4771f81a6d
commit
b41bd21eec
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -339,9 +339,11 @@ public final class Source implements Loggable {
|
|||||||
protected void loadMeta() throws IOException {
|
protected void loadMeta() throws IOException {
|
||||||
if (length == 0 && lastModified == 0) {
|
if (length == 0 && lastModified == 0) {
|
||||||
final URLConnection c = url.openConnection();
|
final URLConnection c = url.openConnection();
|
||||||
length = c.getContentLength();
|
try (InputStream in = c.getInputStream()) {
|
||||||
lastModified = c.getLastModified();
|
length = c.getContentLength();
|
||||||
debug("loaded metadata for ", url);
|
lastModified = c.getLastModified();
|
||||||
|
debug("loaded metadata for ", url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -199,7 +199,7 @@ public abstract class AbstractScriptRunnable {
|
|||||||
try {
|
try {
|
||||||
return getEvaluator().run(out, err, args);
|
return getEvaluator().run(out, err, args);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
throw new UnsupportedOperationException("I/O error in initializing shell - cannot redirect output to file");
|
throw new UnsupportedOperationException("I/O error in initializing shell - cannot redirect output to file", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -118,9 +118,10 @@ public final class ScriptRunnable extends AbstractScriptRunnable implements ITes
|
|||||||
|
|
||||||
if (errors != 0 || checkCompilerMsg) {
|
if (errors != 0 || checkCompilerMsg) {
|
||||||
if (expectCompileFailure || checkCompilerMsg) {
|
if (expectCompileFailure || checkCompilerMsg) {
|
||||||
final PrintStream outputDest = new PrintStream(new FileOutputStream(errorFileName));
|
try (PrintStream outputDest = new PrintStream(new FileOutputStream(errorFileName))) {
|
||||||
TestHelper.dumpFile(outputDest, new StringReader(new String(err.toByteArray())));
|
TestHelper.dumpFile(outputDest, new StringReader(new String(err.toByteArray())));
|
||||||
outputDest.println("--");
|
outputDest.println("--");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log(new String(err.toByteArray()));
|
log(new String(err.toByteArray()));
|
||||||
}
|
}
|
||||||
@ -224,7 +225,6 @@ public final class ScriptRunnable extends AbstractScriptRunnable implements ITes
|
|||||||
|
|
||||||
BufferedReader expected;
|
BufferedReader expected;
|
||||||
if (expectedFile.exists()) {
|
if (expectedFile.exists()) {
|
||||||
expected = new BufferedReader(new InputStreamReader(new FileInputStream(expectedFileName0)));
|
|
||||||
// copy expected file overwriting existing file and preserving last
|
// copy expected file overwriting existing file and preserving last
|
||||||
// modified time of source
|
// modified time of source
|
||||||
try {
|
try {
|
||||||
@ -235,11 +235,14 @@ public final class ScriptRunnable extends AbstractScriptRunnable implements ITes
|
|||||||
} catch (final IOException ex) {
|
} catch (final IOException ex) {
|
||||||
fail("failed to copy expected " + expectedFileName + " to " + copyExpectedFileName + ": " + ex.getMessage());
|
fail("failed to copy expected " + expectedFileName + " to " + copyExpectedFileName + ": " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
expected = new BufferedReader(new InputStreamReader(new FileInputStream(expectedFileName0)));
|
||||||
} else {
|
} else {
|
||||||
expected = new BufferedReader(new StringReader(""));
|
expected = new BufferedReader(new StringReader(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
final BufferedReader actual = new BufferedReader(new InputStreamReader(new FileInputStream(outputFileName0)));
|
try (BufferedReader actual = new BufferedReader(new InputStreamReader(new FileInputStream(outputFileName0)));
|
||||||
compare(actual, expected, compareCompilerMsg);
|
BufferedReader expected0 = expected){
|
||||||
|
compare(actual, expected0, compareCompilerMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user