This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 159366 - <loadproperties><filterchain><replacestring> fails to honor an encoding
Summary: <loadproperties><filterchain><replacestring> fails to honor an encoding
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Ant Project (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Milan Kubec
URL:
Keywords: I18N
Depends on:
Blocks:
 
Reported: 2009-02-28 08:50 UTC by rachotilko
Modified: 2009-05-20 07:18 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Evidence of the errorneous encoding operation (39.88 KB, image/jpeg)
2009-02-28 09:47 UTC, rachotilko
Details
Ant's detailed debug output (7.85 KB, text/plain)
2009-03-02 09:32 UTC, rachotilko
Details
Ant's detailed debug output (7.85 KB, application/x-compressed)
2009-03-02 09:33 UTC, rachotilko
Details
proposed fix (1.78 KB, text/plain)
2009-05-13 12:41 UTC, Milan Kubec
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rachotilko 2009-02-28 08:50:34 UTC
<loadproperties><filterchain><replacestring> seems to fail to honor the active encoding.

The following is a fragment of the JavaSE application project's build-impl.xml in case "Use Dedicated folder for Storing
Libraries" was selected:

        <loadproperties srcfile="${libraries.1.dir}/${libraries.1.basename}-private.properties">
            <filterchain>
                <replacestring from="$${base}" to="${libraries.1.dir}"/>
            </filterchain>
        </loadproperties>

The build process fails in case the value of "${libraries.1.dir}" contains some "exotic" characters (such as Slovak
letter 'ť').

Steps to reproduce the problem:

1, create user named "Rasťo" under windows xp (czech version).
2, log in as "Rasťo".
3, launch Netbeans.
4, create Java aplication project with dedicated folder for libraries.
5, build results in failure.
Comment 1 rachotilko 2009-02-28 09:47:07 UTC
Created attachment 77506 [details]
Evidence of the errorneous encoding operation
Comment 2 Milan Kubec 2009-03-02 08:11:54 UTC
Are you able to run the same script from command line? What build failure are you referring to?
Comment 3 rachotilko 2009-03-02 09:31:16 UTC
You might not have noticed I gave you an complete unambiguous description of the steps required to reproduce the
problem. Anyway, I append the file containing the ant's debugging output.
Comment 4 rachotilko 2009-03-02 09:32:14 UTC
Created attachment 77542 [details]
Ant's detailed debug output
Comment 5 rachotilko 2009-03-02 09:33:42 UTC
Created attachment 77543 [details]
Ant's detailed debug output
Comment 6 Milan Kubec 2009-03-02 09:45:39 UTC
I have noticed and steps to reproduce are OK, but build failure wasn't described in original report and my other
question still holds: Are you able to run the same script from command line? It's very likely that the problem is in Ant
tool itself.
Comment 7 rachotilko 2009-03-02 11:46:31 UTC
Unfortunatelly I don't think I have sufficient expertize on how to launch the ant properly from command line on windows
platform (especially what environment variables are to be set etc.). I agree the issue seems to be caused by the ant itself.
Comment 8 Jesse Glick 2009-03-02 20:51:53 UTC
Looks like a bug in the script to me. Although filter chains are character-oriented, LoadProperties.java uses the
encoding (if supplied) only to decode/encode the file for the benefit of filter chains, but finally uses
Properties.load(InputStream), which assumes ISO-8859-1 encoding. You would probably need to do something like this:

<loadproperties srcfile="${libraries.1.dir}/${libraries.1.basename}-private.properties" encoding="ISO-8859-1">
  <filterchain>
    <replacestring from="$${base}" to="${libraries.1.dir}"/>
    <escapeunicode/>
  </filterchain>
</loadproperties>
Comment 9 rachotilko 2009-03-05 15:11:02 UTC
Yes, that fixes it. I event tried it without setting the encoding explicitly via 'encoding' attribute of
<loadproperties> element, and it worked too. In other words, is 'encoding="ISO-8859-1"' necessary ?

It seems like build scripts of some project templates are to be fixed accordingly.
Comment 10 rachotilko 2009-03-05 15:17:10 UTC
This seems to be related to bug 155877
Comment 11 rachotilko 2009-03-05 15:17:51 UTC
This seems to be related to bug 155877
Comment 12 Jesse Glick 2009-03-05 19:50:25 UTC
encoding="ISO-8859-1" would matter only if someone used unescaped Latin-1 chars in libs.properties, which is unlikely
but technically legal.
Comment 13 Jesse Glick 2009-04-13 16:29:39 UTC
Seems like a simple fix, are you sure you want to defer this?
Comment 14 Milan Kubec 2009-05-13 12:41:57 UTC
Created attachment 82041 [details]
proposed fix
Comment 15 Milan Kubec 2009-05-13 12:43:17 UTC
Jesse, please review the patch. Thanks.
Comment 16 Jesse Glick 2009-05-15 05:39:22 UTC
Looks right, though it should be applied also to all other project types using <loadproperties> for sharable libs.
Comment 17 Milan Kubec 2009-05-18 08:52:29 UTC
Fixed for:

j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/resources/build-impl.xsl
j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/resources/build-impl.xsl
j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/resources/build-impl.xsl
java.j2seproject/src/org/netbeans/modules/java/j2seproject/resources/build-impl.xsl
web.project/src/org/netbeans/modules/web/project/resources/build-impl.xsl

http://hg.netbeans.org/core-main/rev/dd26bd3c27f4
Comment 18 Jesse Glick 2009-05-18 15:24:19 UTC
BTW it is a good idea to increment the spec versions of affected modules, too, since GeneratedFilesHelper uses this to
figure out whether a different version of the stylesheet is actually supposed to be new & improved. For example, a dev
build currently gives this when opening a project last edited just before your fix:

--- genfiles.properties Base (BASE)
+++ genfiles.properties Locally Modified (Based On LOCAL)
@@ -5,4 +5,4 @@
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
 nbproject/build-impl.xml.data.CRC32=301b1beb
 nbproject/build-impl.xml.script.CRC32=161a25fa
-nbproject/build-impl.xml.stylesheet.CRC32=8bdbeca0@1.25.0.45
+nbproject/build-impl.xml.stylesheet.CRC32=5c621a33@1.25.0.45

whereas you would want to see

--- genfiles.properties Base (BASE)
+++ genfiles.properties Locally Modified (Based On LOCAL)
@@ -5,4 +5,4 @@
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
 nbproject/build-impl.xml.data.CRC32=301b1beb
 nbproject/build-impl.xml.script.CRC32=161a25fa
-nbproject/build-impl.xml.stylesheet.CRC32=8bdbeca0@1.25.0.45
+nbproject/build-impl.xml.stylesheet.CRC32=5c621a33@1.26.0.45
                                                       ^

so that the change will not get reverted by someone using a slightly older IDE.
Comment 19 Quality Engineering 2009-05-18 18:29:43 UTC
Integrated into 'main-golden', will be available in build *200905181401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/dd26bd3c27f4
User: Milan Kubec <mkubec@netbeans.org>
Log: #159366: problems when loading localized properties
Comment 20 Milan Kubec 2009-05-19 09:51:41 UTC
Spec. versions incremented.

http://hg.netbeans.org/core-main/rev/9de47f3ba0ea
Comment 21 Quality Engineering 2009-05-20 07:18:49 UTC
Integrated into 'main-golden', will be available in build *200905200201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/9de47f3ba0ea
User: Milan Kubec <mkubec@netbeans.org>
Log: #159366: incrementing spec versions because of recent changes in build-impl.xsl