Browse Source

Fix potential stream leak

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274921 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
c961790179
1 changed files with 11 additions and 4 deletions
  1. +11
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java

+ 11
- 4
src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
* Copyright (c) 2000,2002 The Apache Software Foundation. All rights
* Copyright (c) 2000,2002-2003 The Apache Software Foundation. All rights
* reserved. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -302,19 +302,26 @@ public class jlink extends Object {


if (!name.endsWith(".class")) { if (!name.endsWith(".class")) {
// see if the file is in fact a .class file, and determine its actual name. // see if the file is in fact a .class file, and determine its actual name.
InputStream input = null;
try { try {
InputStream input = new FileInputStream(file);
input = new FileInputStream(file);
String className = ClassNameReader.getClassName(input); String className = ClassNameReader.getClassName(input);


input.close();
if (className != null) { if (className != null) {
return className.replace('.', '/') + ".class"; return className.replace('.', '/') + ".class";
} }
} catch (IOException ioe) { } catch (IOException ioe) {
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
}
}
} }
} }
System.out.println("From " + file.getPath() + " and prefix " + prefix System.out.println("From " + file.getPath() + " and prefix " + prefix
+ ", creating entry " + prefix + name);
+ ", creating entry " + prefix + name);
return (prefix + name); return (prefix + name);
} }




Loading…
Cancel
Save