Bug 47007 - On z/OS, environment variables mishandled when specifying a non-EBCDIC encoding in -Dfile.encoding
Summary: On z/OS, environment variables mishandled when specifying a non-EBCDIC encodi...
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.7.1
Hardware: PC other
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-09 05:45 UTC by Robin Fernandes
Modified: 2009-04-09 05:45 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Fernandes 2009-04-09 05:45:26 UTC
On z/OS, <property environment="..." /> fails when specifying a non-EBCDIC encoding in -Dfile.encoding.

Given the following test.xml:
<project basedir="." default="" name="common">
        <property environment="env" />
</project>

Output for 'export ANT_OPTS="-Dfile.encoding=UTF-8 -Dconsole.encoding=IBM-1047 -Xnoargsconversion" && ant -v -f test.xml':
...
 [property] Loading Environment env.
 [property] Ignoring:
 [property] <...garbage characters here...>
... 

This occurs on Java 1.4.2, 5.0 and 6.0 and is present in Ant 1.7.1 and trunk.

A solution is to remove the special casing in org/apache/tools/ant/taskdefs/Execute.java in Execute.toString(ByteArrayOutputStream bos) and just return bos.toString() (see below).

The issue may be related to the change made under bug 13047. Perhaps -Dfile.encoding was not respected for env vars on earlier JDKs?


--- C:\code\ant\apache-ant-1.7.1-orig\src\main\org\apache\tools\ant\taskdefs\Execute.java	2008-06-27 05:05:22.000000000 +-0100
+++ C:\code\ant\apache-ant-1.7.1-patched\src\main\org\apache\tools\ant\taskdefs\Execute.java	2009-04-09 13:39:24.000000000 +-0100
@@ -259,25 +259,12 @@
      * @return the output stream as a string, read with
      * special encodings in the case of z/os and os/400.
      *
      * @since Ant 1.5
      */
     public static String toString(ByteArrayOutputStream bos) {
-        if (Os.isFamily("z/os")) {
-            try {
-                return bos.toString("Cp1047");
-            } catch (java.io.UnsupportedEncodingException e) {
-                //noop default encoding used
-            }
-        } else if (Os.isFamily("os/400")) {
-            try {
-                return bos.toString("Cp500");
-            } catch (java.io.UnsupportedEncodingException e) {
-                //noop default encoding used
-            }
-        }
         return bos.toString();
     }
 
     /**
      * Creates a new execute object using <code>PumpStreamHandler</code> for
      * stream handling.



This issue has been raised on the user mailing list: http://www.nabble.com/Ant-on-z-OS-tt5429644.html#a22832757