You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2009/06/17 14:52:01 UTC
DO NOT REPLY [Bug 47382] New: Encoding attribute of loadproperties
does not function correctly
https://issues.apache.org/bugzilla/show_bug.cgi?id=47382
Summary: Encoding attribute of loadproperties does not function
correctly
Product: Ant
Version: 1.6.5
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P3
Component: Core tasks
AssignedTo: notifications@ant.apache.org
ReportedBy: oliver.deakin@googlemail.com
When running the Apache Harmony build on a z/OS machine I hit a problem loading
one of our properties files. We do something along the lines of:
<loadproperties srcfile="${basedir}/make/depends.properties">
...
</loadproperties>
However, on z/OS the depends.properties file is checked out as EBCDIC
automatically by svn so I tried adding the encoding attribute to this task:
<loadproperties srcfile="${basedir}/make/depends.properties.ascii"
encoding="ISO-8859-1">
...
</loadproperties>
Unfortunately this also failed to load the relevant properties. I had a dig
into the loadproperties task code and see that when an encoding is specified it
does something along the lines of:
instream = new InputStreamReader(bis, encoding);
String text = crh.readFully(instream);
ByteArrayInputStream tis = new ByteArrayInputStream(text.getBytes(encoding));
We end up failing to read the file because the specified encoding should *not*
be passed to getBytes(). What happens at the moment is:
- The first 2 lines read the properties file from the specified encoding
converting it to the default Java encoding (UTF-16?).
- The third line converts the text into a byte array specifying the encoding
to be converted from. However, "text" has already been converted into the
default Java encoding, and when getBytes() converts it from EBCDIC->UTF-16
again we end up with garbage.
The second getBytes() call should specify the encoding we expect it to convert
_from_, which is the Java default encoding here.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47382] Encoding attribute of loadproperties does
not function correctly
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47382
--- Comment #9 from Oliver Deakin <ol...@googlemail.com> 2009-06-19 07:39:43 PST ---
Thanks Stefan - Ill keep an eye on it and check the fix as soon as possible.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47382] Encoding attribute of loadproperties does
not function correctly
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47382
Oliver Deakin <ol...@googlemail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |
--- Comment #4 from Oliver Deakin <ol...@googlemail.com> 2009-06-19 06:56:27 PST ---
Hi Stefan - thanks for looking at this so quickly!
I just had a look at the change you made to call text.getBytes() without the
encoding specified and Im pretty sure that will also fail. If an encoding is
not specified, getBytes() defaults to converting from the default system
encoding to the Java default encoding.
So in my case calling text.getBytes() is the same as calling
text.getBytes("IBM-1047"), and will still try and convert text again from
EBCDIC->UTF-16. I think you need to explicitly specify that text is already in
UTF-16 to getBytes i.e. text.getBytes("UTF-16"). (Im assuming that UTF-16 is
the correct encoding here)
That said, I havn't tested the change yet locally - does the test you added
pass?
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47382] Encoding attribute of loadproperties does
not function correctly
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47382
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |FIXED
--- Comment #6 from Stefan Bodewig <bo...@apache.org> 2009-06-19 07:10:44 PST ---
The stream is passed to properties.load(InputStream) which explicitly expects
it to be iso-8859-1 encoded, IÄve adapted to code in svn revision 786515 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=786515 )
The real solution would involve Properties.load(Reader) which has been added in
Java 6 (and thus can be used in Ant in about five years, or so 8-).
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47382] Encoding attribute of loadproperties does
not function correctly
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47382
--- Comment #8 from Stefan Bodewig <bo...@apache.org> 2009-06-19 07:36:54 PST ---
The links on Ant's site are broken (and I'm not familiar enough with Teamcity
to fix them reliably):
http://teamcity.jetbrains.com/viewType.html?tab=buildTypeStatusDiv&buildTypeId=bt130
works for me. This isn't built continously (unlike the other Ant builds on
TeamCity) so you'll have to wait a day to get the result.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47382] Encoding attribute of loadproperties does
not function correctly
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47382
--- Comment #1 from Oliver Deakin <ol...@googlemail.com> 2009-06-17 05:52:39 PST ---
In the 2nd loadproperties snippet above, "depends.properties.ascii" should read
"depends.properties".
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47382] Encoding attribute of loadproperties does
not function correctly
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47382
Oliver Deakin <ol...@googlemail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |VERIFIED
--- Comment #10 from Oliver Deakin <ol...@googlemail.com> 2010-06-04 05:54:07 EDT ---
I've tested on the 1.8.0 release and this bug appears to be fixed now. Thanks
Stefan!
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47382] Encoding attribute of loadproperties does
not function correctly
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47382
Nathan Beyer <nd...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ndbeyer@apache.org
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47382] Encoding attribute of loadproperties does
not function correctly
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47382
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |1.8.0
--- Comment #3 from Stefan Bodewig <bo...@apache.org> 2009-06-19 06:46:13 PST ---
fixed in svn revision 786506 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=786506 )
Thanks!
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47382] Encoding attribute of loadproperties does
not function correctly
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47382
--- Comment #2 from Oliver Deakin <ol...@googlemail.com> 2009-06-17 05:56:25 PST ---
Copy-paste mistake - For clarity, that snippet should read
<loadproperties srcfile="${basedir}/make/depends.properties"
encoding="IBM-1047">
...
</loadproperties>
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47382] Encoding attribute of loadproperties does
not function correctly
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47382
--- Comment #5 from Stefan Bodewig <bo...@apache.org> 2009-06-19 07:03:47 PST ---
Hi Oliver, yes, the test passes on my local system (where the default encoding
most likely is some variant of iso-8859-15)
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47382] Encoding attribute of loadproperties does
not function correctly
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47382
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|VERIFIED |CLOSED
--- Comment #11 from Stefan Bodewig <bo...@apache.org> 2010-06-14 09:12:36 EDT ---
Thanks for confirming this, Oliver.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47382] Encoding attribute of loadproperties does
not function correctly
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47382
--- Comment #7 from Oliver Deakin <ol...@googlemail.com> 2009-06-19 07:15:18 PST ---
Brilliant, thanks Stefan! That looks good to me - what is the best way for me
to verify this is fixed? Are there nightly builds I can pick up?
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.