Bug 40937 - Use String.toUpper/Lower case with Locale
Summary: Use String.toUpper/Lower case with Locale
Status: RESOLVED FIXED
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Configurator (show other bugs)
Version: 1.2
Hardware: Other Windows XP
: P4 minor
Target Milestone: ---
Assignee: log4j-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-09 05:41 UTC by y360
Modified: 2007-05-15 14:37 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description y360 2006-11-09 05:41:54 UTC
Level configuration such as the following 

log4j.logger.org.apache=info

is recognized as DEBUG rather than INFO in Turkish locale

This is caused by the "Turkish-i problem" that's explained on the following sites
http://java.sys-con.com/read/46241.htm
http://www.i18nguy.com/unicode/turkish-i18n.html

In summary the following assumptions fail, and produces "false" value in Turkish
locale
     "i".toUpperCase().equals("I");
     "I".toLowerCase().equals("i");

Solution is to compare the config level to "INFO" with explicit English locale

To reproduce, change the regional settings of Windows to be Turkish (via Control
Panel -> Regional)
Comment 1 Elias Ross 2007-01-26 16:03:41 UTC
See this:
http://pmd.sourceforge.net/rules/design.html

In general, we should avoid case conversions where possible, and if not possible
with a particular locale.
Comment 2 Elias Ross 2007-01-26 17:01:52 UTC
Changes for this checked into SVN trunk
Comment 3 Curt Arnold 2007-01-30 13:21:22 UTC
Elias committed changes against log4j trunk in rev 500441.

The changes would appear to result in several changed behaviors that may not be desirable, for example, 
Level.toLevel("\u0131NFO") (lowercase undotted I + NFO) would appear to return Level.INFO and now 
would return Level.DEBUG.
Comment 4 Curt Arnold 2007-02-01 14:49:01 UTC
Changes in rev 500441 were reverted in rev 502388 to fix unit test breakage in 
o.a.l.helpers.DateLayoutTest.testSetOptionDateFormat.

The scope of rev 500441 was way too broad and lacked unit tests to establish the pre-patch behavior that 
would be needed for changes to be applied in log4j 1.2.  I'll review this bug and see if I can come up with 
smaller patches that address the individual issues raised.
Comment 5 Curt Arnold 2007-02-22 15:32:18 UTC
Committed rev 510707 that addresses Level.getLevel("info") while still letting Level.getLevel("\u0131nfo") 
also work.  Only other places in 1.2 branch that I saw toLower/toUpper used was in LogFactor5 and 
TTCCLayout and since those are deprecated I did not want to open that up.

JoranConfig stuff in trunk uses it pretty heavily, but less need to support existing behavior there.

I'm considering this fixed in log4j 1.2 and open in 1.3.
Comment 6 Curt Arnold 2007-05-15 14:37:18 UTC
Closing bug.  Fixed in log4j 1.2, walking away from 1.3.