Browse Source

Closing some streams in Manifest, patch kindly provided by John Sisson.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@414940 13f79535-47bb-0310-9956-ffa450edef68
master
Jacobus Martinus Kruithof 19 years ago
parent
commit
cf36820272
3 changed files with 14 additions and 4 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +2
    -0
      WHATSNEW
  3. +11
    -4
      src/main/org/apache/tools/ant/taskdefs/Manifest.java

+ 1
- 0
CONTRIBUTORS View File

@@ -113,6 +113,7 @@ Jesse Glick
Jesse Stockall
Jim Allers
Joerg Wassmer
John Sisson
Jon Dickinson
Jon S. Stevens
Jose Alberto Fernandez


+ 2
- 0
WHATSNEW View File

@@ -94,6 +94,8 @@ Changes that could break older environments:

Fixed bugs:
-----------
* <manifest> now closes the inputstream explicitly. Bug report 39628

* <rpm> now also correctly searches the first element of the path. Bug report 39345.

* ant.bat now handles classpath set to "". Bug report 38914.


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

@@ -29,6 +29,7 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.util.FileUtils;

/**
* Holds the data of a jar manifest.
@@ -698,28 +699,34 @@ public class Manifest {
* default manifest
*/
public static Manifest getDefaultManifest() throws BuildException {
InputStream in = null;
InputStreamReader insr = null;
try {
String defManifest = "/org/apache/tools/ant/defaultManifest.mf";
InputStream in = Manifest.class.getResourceAsStream(defManifest);
in = Manifest.class.getResourceAsStream(defManifest);
if (in == null) {
throw new BuildException("Could not find default manifest: "
+ defManifest);
}
try {
Manifest defaultManifest
= new Manifest(new InputStreamReader(in, "UTF-8"));
insr = new InputStreamReader(in, "UTF-8");
Manifest defaultManifest = new Manifest(insr);
Attribute createdBy = new Attribute("Created-By",
System.getProperty("java.vm.version") + " ("
+ System.getProperty("java.vm.vendor") + ")");
defaultManifest.getMainSection().storeAttribute(createdBy);
return defaultManifest;
} catch (UnsupportedEncodingException e) {
return new Manifest(new InputStreamReader(in));
insr = new InputStreamReader(in);
return new Manifest(insr);
}
} catch (ManifestException e) {
throw new BuildException("Default manifest is invalid !!", e);
} catch (IOException e) {
throw new BuildException("Unable to read default manifest", e);
} finally {
FileUtils.close(insr);
FileUtils.close(in);
}
}



Loading…
Cancel
Save