bodewig 01/12/11 04:55:55
Modified: src/main/org/apache/tools/ant/taskdefs Jar.java
Manifest.java
Log:
Use the proper encoding for the default manifest.
Revision Changes Path
1.29 +15 -9
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Jar.java
Index: Jar.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Jar.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Jar.java 2001/11/08 16:16:08 1.28
+++ Jar.java 2001/12/11 12:55:55 1.29
@@ -128,10 +128,10 @@
this.manifestFile = manifestFile;
- InputStream is = null;
+ Reader r = null;
try {
- is = new FileInputStream(manifestFile);
- Manifest newManifest = new Manifest(is);
+ r = new FileReader(manifestFile);
+ Manifest newManifest = new Manifest(r);
if (manifest == null) {
manifest = getDefaultManifest();
}
@@ -145,9 +145,9 @@
throw new BuildException("Unable to read manifest file: " +
manifestFile, e);
}
finally {
- if (is != null) {
+ if (r != null) {
try {
- is.close();
+ r.close();
}
catch (IOException e) {
// do nothing
@@ -259,7 +259,13 @@
if (in == null) {
throw new BuildException("Could not find default manifest: "
+ s);
}
- return new Manifest(in);
+ try {
+ return new Manifest(new InputStreamReader(in, "ASCII"));
+ } catch (UnsupportedEncodingException e) {
+ // impossible with ASCII encoding
+ log("ASCII encoding not supported by JVM", Project.MSG_ERR);
+ return new Manifest(new InputStreamReader(in));
+ }
}
catch (ManifestException e) {
throw new BuildException("Default manifest is invalid !!");
@@ -280,10 +286,10 @@
private void zipManifestEntry(InputStream is) throws IOException {
try {
if (execManifest == null) {
- execManifest = new Manifest(is);
+ execManifest = new Manifest(new InputStreamReader(is));
}
else if (isAddingNewFiles()) {
- execManifest.merge(new Manifest(is));
+ execManifest.merge(new Manifest(new InputStreamReader(is)));
}
}
catch (ManifestException e) {
@@ -344,7 +350,7 @@
log("Updating jar since the current jar has no
manifest", Project.MSG_VERBOSE);
return false;
}
- Manifest currentManifest = new
Manifest(theZipFile.getInputStream(entry));
+ Manifest currentManifest = new Manifest(new
InputStreamReader(theZipFile.getInputStream(entry)));
if (manifest == null) {
manifest = getDefaultManifest();
}
1.12 +5 -6
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java
Index: Manifest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Manifest.java 2001/11/21 09:05:15 1.11
+++ Manifest.java 2001/12/11 12:55:55 1.12
@@ -60,8 +60,7 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.Reader;
import java.io.StringWriter;
import org.apache.tools.ant.BuildException;
@@ -504,15 +503,15 @@
}
/**
- * Read a manifest file from the given input stream
+ * Read a manifest file from the given reader
*
- * @param is the input stream from which the Manifest is read
+ * @param is the reader from which the Manifest is read
*
* @throws ManifestException if the manifest is not valid according to
the JAR spec
* @throws IOException if the manifest cannot be read from the reader.
*/
- public Manifest(InputStream is) throws ManifestException, IOException {
- BufferedReader reader = new BufferedReader(new
InputStreamReader(is));
+ public Manifest(Reader r) throws ManifestException, IOException {
+ BufferedReader reader = new BufferedReader(r);
// This should be the manifest version
String nextSectionName = mainSection.read(reader);
String readManifestVersion =
mainSection.getAttributeValue(ATTRIBUTE_MANIFEST_VERSION);
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>