This discussion is archived
4 Replies Latest reply: May 3, 2010 3:43 PM by greybird RSS

Patch to fix time unit parsing in Turkish locale

762733 Newbie
Currently Being Moderated
For BDB Java Edition (Oracle: Berkeley DB, Java Edition 4.0.92: January 29, 2010)

In src/com/sleepycat/je/utilint/PropUtil.java in the parseDuration method around line 80:

. . . . StringTokenizer tokens =
. . . . . . new StringTokenizer(property.toUpperCase(), " \t");

when the default locale is Turkish, this fails to parse "75 min" with the following exception.
java.lang.ExceptionInInitializerError
. . at com.sleepycat.je.EnvironmentConfig.setTransactional(EnvironmentConfig.java:2270)
. . at org.prebake.fs.FileHashesTest.setUp(FileHashesTest.java:40)
Caused by: java.lang.IllegalArgumentException: Duration argument has unknown unit name: 75 min
. . at com.sleepycat.je.utilint.PropUtil.parseDuration(PropUtil.java:108)
. . at com.sleepycat.je.config.DurationConfigParam.(DurationConfigParam.java:41)
. . at com.sleepycat.je.config.EnvironmentParams.(EnvironmentParams.java:402)
Possibly, the "i" in "min" is uppercased to a Turkish dotted uppercase I as described at http://www.i18nguy.com/unicode/turkish-i18n.html .

Changing those two lines to
. . . . StringTokenizer tokens =
. . . . . . new StringTokenizer(property.toUpperCase(java.util.Locale.ENGLISH), " \t");
fixes the problem.

This is not a major issue. I run unittests in the Turkish locale to avoid case folding issues that could cause whitelists to be misapplied.

Cheers,
mike