Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-41178

Loading a properties file containing unicode characters fails on JDK 7/JDK 8



      0- Start potal with JDK 7/JDK 8
      1- Deploy language-hook-
      2- Go to Admins/Content
      3- Switch language to "hu"

      Expected Result
      Title of "Documents and Media" should be "ékezet"

      Actual result
      Title of "Documents and Media" should be "�kezet"

      === Technical background
      It can be a common coding policy at our customers that prohibits to use special characters in properties files.

      1- Create a language-hook (use https://github.com/lipusz/liferay-plugins/tree/LPS-41178-sample-language-hook)
      2- This hook contains a file called Language_ext_hu.properties
      3- This file originally contained


      then, it was converted to ASCII/Unicode by "native2ascii", so now contains UNICODE characters. Result is the same if you save it in UTF-8.


      4- HookHotDeployListener#initLanguageProperties calls

      properties = PropertiesUtil.load(is, StringPool.UTF8);

      5- Using JDK 7/JDK 8, it will fallback to

      public static Properties loadJDK5(InputStream is, String charsetName)

      that executes an encode-decode logic on every key-value pairs.

      6- Calling an encode-decode on a UNICODE sequence will produce such incorrect values.
      7- You can also test it by running the simple tester.jar

      Cannot be reproduce on JDK 6, as "loadJDK6(Reader reader)" uses UTF-8 to encode.

      === Alternative way to reproduce
      1- Modify Language_hu.props in portal-impl/src/content/ similarly to the hook
      2- Execute "ant deploy" from "portal-impl" to deploy the changes to your server
      3- Repeat the steps above


        1. fix.png
          49 kB
        2. language-hook-
          2 kB
        3. reproduce.png
          45 kB
        4. tester.jar
          10 kB
        5. tester-project.zip
          13 kB

          Issue Links



              • Votes:
                2 Vote for this issue
                6 Start watching this issue


                • Created:
                  Days since last comment:
                  3 years, 20 weeks ago


                  Version Package
                  6.2.X EE
                  7.0.0 M1