提交 027429fd authored 作者: Thomas Mueller's avatar Thomas Mueller

String.toUpperCase() was used a few places, which is problematic when using the…

String.toUpperCase() was used a few places, which is problematic when using the Turkish locale. The method has been replaced with toUpperCase(Locale.ENGLISH) to solve such problems.
上级 6e271d45
......@@ -187,7 +187,7 @@ public class Database implements DataHandler {
Constants.DEFAULT_MAX_LENGTH_INPLACE_LOB2 : Constants.DEFAULT_MAX_LENGTH_INPLACE_LOB;
this.cipher = cipher;
String lockMethodName = ci.getProperty("FILE_LOCK", null);
this.accessModeData = ci.getProperty("ACCESS_MODE_DATA", "rw").toLowerCase();
this.accessModeData = StringUtils.toLowerEnglish(ci.getProperty("ACCESS_MODE_DATA", "rw"));
this.autoServerMode = ci.getProperty("AUTO_SERVER", false);
this.cacheSize = ci.getProperty("CACHE_SIZE", Constants.CACHE_SIZE_DEFAULT);
this.pageSize = ci.getProperty("PAGE_SIZE", Constants.DEFAULT_PAGE_SIZE);
......
......@@ -39,6 +39,7 @@ import org.h2.util.IOUtils;
import org.h2.util.JdbcUtils;
import org.h2.util.New;
import org.h2.util.ScriptReader;
import org.h2.util.StringUtils;
import org.h2.util.Utils;
/**
......@@ -403,7 +404,7 @@ public class PgServerThread implements Runnable {
}
private String getSQL(String s) {
String lower = s.toLowerCase();
String lower = StringUtils.toLowerEnglish(s);
if (lower.startsWith("show max_identifier_length")) {
s = "CALL 63";
} else if (lower.startsWith("set client_encoding to")) {
......@@ -564,7 +565,7 @@ public class PgServerThread implements Runnable {
startMessage('T');
writeShort(columns);
for (int i = 0; i < columns; i++) {
writeString(names[i].toLowerCase());
writeString(StringUtils.toLowerEnglish(names[i]));
// object ID
writeInt(0);
// attribute number of the column
......
......@@ -11,6 +11,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import org.h2.util.New;
import org.h2.util.StringUtils;
/**
* Contains meta data information about a database schema.
......@@ -63,9 +64,9 @@ public class DbSchema {
this.name = name;
this.quotedName = contents.quoteIdentifier(name);
this.isDefault = isDefault;
if (name.toUpperCase().startsWith("INFO")) {
if (StringUtils.toUpperEnglish(name).startsWith("INFO")) {
isSystem = true;
} else if (contents.isPostgreSQL && name.toUpperCase().startsWith("PG_")) {
} else if (contents.isPostgreSQL && StringUtils.toUpperEnglish(name).startsWith("PG_")) {
isSystem = true;
} else if (contents.isDerby && name.startsWith("SYS")) {
isSystem = true;
......
......@@ -488,7 +488,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
*/
public static void openBrowser(String url) throws Exception {
try {
String osName = Utils.getProperty("os.name", "linux").toLowerCase();
String osName = StringUtils.toLowerEnglish(Utils.getProperty("os.name", "linux"));
Runtime rt = Runtime.getRuntime();
String browser = Utils.getProperty(SysProperties.H2_BROWSER, null);
if (browser != null) {
......
......@@ -171,7 +171,7 @@ public class CompareMode {
name = name.substring(DEFAULT.length());
}
if (name.length() == 2) {
Locale locale = new Locale(name.toLowerCase(), "");
Locale locale = new Locale(StringUtils.toLowerEnglish(name), "");
if (compareLocaleNames(locale, name)) {
result = Collator.getInstance(locale);
}
......@@ -179,7 +179,7 @@ public class CompareMode {
// LL_CC (language_country)
int idx = name.indexOf('_');
if (idx >= 0) {
String language = name.substring(0, idx).toLowerCase();
String language = StringUtils.toLowerEnglish(name.substring(0, idx));
String country = name.substring(idx + 1);
Locale locale = new Locale(language, country);
if (compareLocaleNames(locale, name)) {
......
......@@ -10,6 +10,7 @@ import java.lang.reflect.Method;
import java.util.Comparator;
import java.util.Locale;
import org.h2.message.DbException;
import org.h2.util.StringUtils;
import org.h2.util.Utils;
/**
......@@ -43,7 +44,7 @@ public class CompareModeIcu4J extends CompareMode {
Class<?> collatorClass = Utils.loadUserClass("com.ibm.icu.text.Collator");
Method getInstanceMethod = collatorClass.getMethod("getInstance", Locale.class);
if (name.length() == 2) {
Locale locale = new Locale(name.toLowerCase(), "");
Locale locale = new Locale(StringUtils.toLowerEnglish(name), "");
if (compareLocaleNames(locale, name)) {
result = (Comparator<String>) getInstanceMethod.invoke(null, locale);
}
......@@ -51,7 +52,7 @@ public class CompareModeIcu4J extends CompareMode {
// LL_CC (language_country)
int idx = name.indexOf('_');
if (idx >= 0) {
String language = name.substring(0, idx).toLowerCase();
String language = StringUtils.toLowerEnglish(name.substring(0, idx));
String country = name.substring(idx + 1);
Locale locale = new Locale(language, country);
if (compareLocaleNames(locale, name)) {
......
......@@ -758,7 +758,7 @@ public abstract class TestBase {
*/
protected void assertStartsWith(String text, String expectedStart) {
if (!text.startsWith(expectedStart)) {
fail(text + " does not start with: " + expectedStart);
fail("[" + text + "] does not start with: [" + expectedStart + "]");
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论