Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for 2895546: WindowsTerminal.loadLibrary patches

Patches from Joris Kuipers
  • Loading branch information...
commit e1613afeeb9082cefbfa8853f7e93525be17e006 1 parent 4fa43f1
@headius headius authored
Showing with 13 additions and 6 deletions.
  1. +13 −6 src/main/java/jline/WindowsTerminal.java
View
19 src/main/java/jline/WindowsTerminal.java
@@ -266,7 +266,7 @@ public void start() {
private void loadLibrary(final String name) throws IOException {
// store the DLL in the temporary directory for the System
- String version = getClass().getPackage().getImplementationVersion();
+ String version = WindowsTerminal.class.getPackage().getImplementationVersion();
if (version == null) {
version = "";
@@ -286,11 +286,11 @@ private void loadLibrary(final String name) throws IOException {
if (System.getProperty("os.arch").indexOf("64") != -1)
bits = 64;
- InputStream in = new BufferedInputStream(getClass()
- .getResourceAsStream(name + bits + ".dll"));
+ InputStream in = new BufferedInputStream(WindowsTerminal.class.getResourceAsStream(name + bits + ".dll"));
+ OutputStream fout = null;
try {
- OutputStream fout = new BufferedOutputStream(
+ fout = new BufferedOutputStream(
new FileOutputStream(f));
byte[] bytes = new byte[1024 * 10];
@@ -298,7 +298,6 @@ private void loadLibrary(final String name) throws IOException {
fout.write(bytes, 0, n);
}
- fout.close();
} catch (IOException ioe) {
// We might get an IOException trying to overwrite an existing
// jline.dll file if there is another process using the DLL.
@@ -306,6 +305,14 @@ private void loadLibrary(final String name) throws IOException {
if (!exists) {
throw ioe;
}
+ } finally {
+ if (fout != null) {
+ try {
+ fout.close();
+ } catch (IOException ioe) {
+ // ignore
+ }
+ }
}
// try to clean up the DLL after the JVM exits
@@ -437,7 +444,7 @@ public synchronized void disableEcho() {
}
public InputStream getDefaultBindings() {
- return getClass().getResourceAsStream("windowsbindings.properties");
+ return WindowsTerminal.class.getResourceAsStream("windowsbindings.properties");
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.