Skip to content

Commit

Permalink
adds LOCALE.English to each toLowerCase call to avoid the famous Turk…
Browse files Browse the repository at this point in the history
…ish problem

refs: #7464
  • Loading branch information
robfrank committed Jun 6, 2017
1 parent c5f1722 commit 136db63
Show file tree
Hide file tree
Showing 58 changed files with 196 additions and 195 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ public int getClusterIdByName(final String iClusterName) {
if (Character.isDigit(iClusterName.charAt(0)))
return Integer.parseInt(iClusterName);

final OCluster cluster = clusterMap.get(iClusterName.toLowerCase());
final OCluster cluster = clusterMap.get(iClusterName.toLowerCase(Locale.ENGLISH));
if (cluster == null)
return -1;

Expand Down Expand Up @@ -1667,7 +1667,7 @@ public void updateStorageConfiguration(OStorageConfiguration storageConfiguratio
String clusterName = clusterConfig.getName();
final int clusterId = clusterConfig.getId();
if (clusterName != null) {
clusterName = clusterName.toLowerCase();
clusterName = clusterName.toLowerCase(Locale.ENGLISH);
cluster.configure(null, clusterId, clusterName);
if (clusterId >= clusters.length)
clusters = Arrays.copyOf(clusters, clusterId + 1);
Expand Down Expand Up @@ -1759,12 +1759,12 @@ public void addNewClusterToConfiguration(int clusterId, String iClusterName) {
stateLock.acquireWriteLock();
try {
final OClusterRemote cluster = new OClusterRemote();
cluster.configure(this, clusterId, iClusterName.toLowerCase());
cluster.configure(this, clusterId, iClusterName.toLowerCase(Locale.ENGLISH));

if (clusters.length <= clusterId)
clusters = Arrays.copyOf(clusters, clusterId + 1);
clusters[cluster.getId()] = cluster;
clusterMap.put(cluster.getName().toLowerCase(), cluster);
clusterMap.put(cluster.getName().toLowerCase(Locale.ENGLISH), cluster);
} finally {
stateLock.releaseWriteLock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@
import com.orientechnologies.orient.enterprise.channel.binary.OChannelDataOutput;

import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import java.util.UUID;

public class OBinaryProtocolHelper {

Expand Down Expand Up @@ -143,7 +140,7 @@ public static OCluster[] readClustersArray(final OChannelDataInput network) thro
String clusterName = network.readString();
final int clusterId = network.readShort();
if (clusterName != null) {
clusterName = clusterName.toLowerCase();
clusterName = clusterName.toLowerCase(Locale.ENGLISH);
cluster.configure(null, clusterId, clusterName);
if (clusterId >= clusters.length)
clusters = Arrays.copyOf(clusters, clusterId + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public static OCluster[] readClustersArray(final OChannelDataInput network) thro
String clusterName = network.readString();
final int clusterId = network.readShort();
if (clusterName != null) {
clusterName = clusterName.toLowerCase();
clusterName = clusterName.toLowerCase(Locale.ENGLISH);
cluster.configure(null, clusterId, clusterName);
if (clusterId >= clusters.length)
clusters = Arrays.copyOf(clusters, clusterId + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public boolean isEchoEnabled() {
protected boolean isPropertyEnabled(final String iPropertyName) {
String v = properties.get(iPropertyName);
if (v != null) {
v = v.toLowerCase();
v = v.toLowerCase(Locale.ENGLISH);
return v.equals("true") || v.equals("on");
}
return false;
Expand Down Expand Up @@ -328,7 +328,7 @@ protected RESULT execute(String iCommand) {
if (i > 0) {
commandLowerCase += " ";
}
commandLowerCase += commandWords[i].toLowerCase();
commandLowerCase += commandWords[i].toLowerCase(Locale.ENGLISH);
}

for (Entry<Method, Object> entry : getConsoleMethods().entrySet()) {
Expand Down Expand Up @@ -439,7 +439,7 @@ protected Method getMethod(String iCommand) {
Method lastMethodInvoked = null;
final StringBuilder lastCommandInvoked = new StringBuilder(1024);

final String commandLowerCase = iCommand.toLowerCase();
final String commandLowerCase = iCommand.toLowerCase(Locale.ENGLISH);

final Map<Method, Object> methodMap = getConsoleMethods();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public static String java2unicode(final String iInput) {
for (int j = 0; j < 4 - hex.length(); j++)
// Prepend zeros because unicode requires 4 digits
result.append('0');
result.append(hex.toLowerCase()); // standard unicode format.
result.append(hex.toLowerCase(Locale.ENGLISH)); // standard unicode format.
// ostr.append(hex.toLowerCase(Locale.ENGLISH));
}
}
Expand Down
17 changes: 2 additions & 15 deletions core/src/main/java/com/orientechnologies/orient/core/Orient.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,7 @@

import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
Expand Down Expand Up @@ -165,7 +152,7 @@ else if (thisObject != null && thatObject != null)

protected Orient() {
super(true);
this.os = System.getProperty("os.name").toLowerCase();
this.os = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
threadGroup = new ThreadGroup("OrientDB");
threadGroup.setDaemon(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@

import com.orientechnologies.common.comparator.ODefaultComparator;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;

/**
* Case insensitive collate.
Expand All @@ -41,7 +38,7 @@ public String getName() {

public Object transform(final Object obj) {
if (obj instanceof String)
return ((String) obj).toLowerCase();
return ((String) obj).toLowerCase(Locale.ENGLISH);

if(obj instanceof Set){
Set result = new HashSet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

public class OCommandManager {
Expand Down Expand Up @@ -70,7 +71,7 @@ public OScriptExecutor getScriptExecutor(String language) {
}
OScriptExecutor scriptExecutor = this.scriptExecutors.get(language);
if (scriptExecutor == null) {
scriptExecutor = this.scriptExecutors.get(language.toLowerCase());
scriptExecutor = this.scriptExecutors.get(language.toLowerCase(Locale.ENGLISH));
}
if (scriptExecutor == null)
throw new IllegalArgumentException("Cannot find a script executor requester for language: " + language);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public OScriptManager() {
scriptEngineManager = new ScriptEngineManager();

for (ScriptEngineFactory f : scriptEngineManager.getEngineFactories()) {
registerEngine(f.getLanguageName().toLowerCase(), f);
registerEngine(f.getLanguageName().toLowerCase(Locale.ENGLISH), f);

if (defaultLanguage == null)
defaultLanguage = f.getLanguageName();
Expand Down Expand Up @@ -103,15 +103,15 @@ public OScriptManager() {
}

public String getFunctionDefinition(final OFunction iFunction) {
final OScriptFormatter formatter = formatters.get(iFunction.getLanguage().toLowerCase());
final OScriptFormatter formatter = formatters.get(iFunction.getLanguage().toLowerCase(Locale.ENGLISH));
if (formatter == null)
throw new IllegalArgumentException("Cannot find script formatter for the language '" + iFunction.getLanguage() + "'");

return formatter.getFunctionDefinition(iFunction);
}

public String getFunctionInvoke(final OFunction iFunction, final Object[] iArgs) {
final OScriptFormatter formatter = formatters.get(iFunction.getLanguage().toLowerCase());
final OScriptFormatter formatter = formatters.get(iFunction.getLanguage().toLowerCase(Locale.ENGLISH));
if (formatter == null)
throw new IllegalArgumentException("Cannot find script formatter for the language '" + iFunction.getLanguage() + "'");

Expand Down Expand Up @@ -155,15 +155,15 @@ public boolean existsEngine(String iLanguage) {
if (iLanguage == null)
return false;

iLanguage = iLanguage.toLowerCase();
iLanguage = iLanguage.toLowerCase(Locale.ENGLISH);
return engines.containsKey(iLanguage);
}

public ScriptEngine getEngine(final String iLanguage) {
if (iLanguage == null)
throw new OCommandScriptException("No language was specified");

final String lang = iLanguage.toLowerCase();
final String lang = iLanguage.toLowerCase(Locale.ENGLISH);

final ScriptEngineFactory scriptEngineFactory = engines.get(lang);
if (scriptEngineFactory == null)
Expand Down Expand Up @@ -389,12 +389,12 @@ public OScriptManager registerEngine(final String iLanguage, final ScriptEngineF
}

public OScriptManager registerFormatter(final String iLanguage, final OScriptFormatter iFormatterImpl) {
formatters.put(iLanguage.toLowerCase(), iFormatterImpl);
formatters.put(iLanguage.toLowerCase(Locale.ENGLISH), iFormatterImpl);
return this;
}

public OScriptManager registerResultHandler(final String iLanguage, final OScriptResultHandler resultHandler) {
handlers.put(iLanguage.toLowerCase(), resultHandler);
handlers.put(iLanguage.toLowerCase(Locale.ENGLISH), resultHandler);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.orientechnologies.orient.core.storage.OStorage;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
Expand Down Expand Up @@ -371,9 +372,9 @@ private void checkForClose() {
*/
public Object setProperty(final String iName, final Object iValue) {
if (iValue != null) {
return properties.put(iName.toLowerCase(), iValue);
return properties.put(iName.toLowerCase(Locale.ENGLISH), iValue);
} else {
return properties.remove(iName.toLowerCase());
return properties.remove(iName.toLowerCase(Locale.ENGLISH));
}
}

Expand All @@ -384,7 +385,7 @@ public Object setProperty(final String iName, final Object iValue) {
* @return The previous value if any, otherwise null
*/
public Object getProperty(final String iName) {
return properties.get(iName.toLowerCase());
return properties.get(iName.toLowerCase(Locale.ENGLISH));
}

private static final class PoolData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ public int getClusters() {
@Override
public boolean existsCluster(final String iClusterName) {
checkIfActive();
return getStorage().getClusterNames().contains(iClusterName.toLowerCase());
return getStorage().getClusterNames().contains(iClusterName.toLowerCase(Locale.ENGLISH));
}

@Override
Expand All @@ -893,7 +893,7 @@ public int getClusterIdByName(final String iClusterName) {
return -1;

checkIfActive();
return getStorage().getClusterIdByName(iClusterName.toLowerCase());
return getStorage().getClusterIdByName(iClusterName.toLowerCase(Locale.ENGLISH));
}

@Override
Expand Down Expand Up @@ -990,14 +990,14 @@ public void checkForClusterPermissions(final String iClusterName) {
@Override
public Object setProperty(final String iName, final Object iValue) {
if (iValue == null)
return properties.remove(iName.toLowerCase());
return properties.remove(iName.toLowerCase(Locale.ENGLISH));
else
return properties.put(iName.toLowerCase(), iValue);
return properties.put(iName.toLowerCase(Locale.ENGLISH), iValue);
}

@Override
public Object getProperty(final String iName) {
return properties.get(iName.toLowerCase());
return properties.get(iName.toLowerCase(Locale.ENGLISH));
}

@Override
Expand Down Expand Up @@ -3046,21 +3046,21 @@ private void bindPropertiesToContext(OContextConfiguration configuration, final
configuration.setValue(OGlobalConfiguration.CLIENT_CONNECTION_STRATEGY, connectionStrategy);

final String compressionMethod = iProperties != null ?
(String) iProperties.get(OGlobalConfiguration.STORAGE_COMPRESSION_METHOD.getKey().toLowerCase()) :
(String) iProperties.get(OGlobalConfiguration.STORAGE_COMPRESSION_METHOD.getKey().toLowerCase(Locale.ENGLISH)) :
null;
if (compressionMethod != null)
// SAVE COMPRESSION METHOD IN CONFIGURATION
configuration.setValue(OGlobalConfiguration.STORAGE_COMPRESSION_METHOD, compressionMethod);

final String encryptionMethod = iProperties != null ?
(String) iProperties.get(OGlobalConfiguration.STORAGE_ENCRYPTION_METHOD.getKey().toLowerCase()) :
(String) iProperties.get(OGlobalConfiguration.STORAGE_ENCRYPTION_METHOD.getKey().toLowerCase(Locale.ENGLISH)) :
null;
if (encryptionMethod != null)
// SAVE ENCRYPTION METHOD IN CONFIGURATION
configuration.setValue(OGlobalConfiguration.STORAGE_ENCRYPTION_METHOD, encryptionMethod);

final String encryptionKey =
iProperties != null ? (String) iProperties.get(OGlobalConfiguration.STORAGE_ENCRYPTION_KEY.getKey().toLowerCase()) : null;
iProperties != null ? (String) iProperties.get(OGlobalConfiguration.STORAGE_ENCRYPTION_KEY.getKey().toLowerCase(Locale.ENGLISH)) : null;
if (encryptionKey != null)
// SAVE ENCRYPTION KEY IN CONFIGURATION
configuration.setValue(OGlobalConfiguration.STORAGE_ENCRYPTION_KEY, encryptionKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.orientechnologies.orient.core.db.record.ORecordOperation;
import com.orientechnologies.orient.core.id.ORID;

import java.util.Locale;

/**
* Exception thrown when MVCC is enabled and a record cannot be updated or deleted because versions don't match.
*
Expand Down Expand Up @@ -101,7 +103,7 @@ private static String makeMessage(int recordOperation, ORID rid, int databaseVer
sb.append(" the record ");
sb.append(rid);
sb.append(" because the version is not the latest. Probably you are ");
sb.append(operation.toLowerCase().substring(0, operation.length() - 1));
sb.append(operation.toLowerCase(Locale.ENGLISH).substring(0, operation.length() - 1));
sb.append("ing an old record or it has been modified by another user (db=v");
sb.append(databaseVersion);
sb.append(" your=v");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,22 @@
import com.orientechnologies.orient.core.metadata.security.OUser;
import com.orientechnologies.orient.core.metadata.sequence.OSequence;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.*;

/**
* Internal interface to manage metadata snapshots.
*/
public interface OMetadataInternal extends OMetadata {

Set<String> SYSTEM_CLUSTER = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
new String[] { OUser.CLASS_NAME.toLowerCase(), ORole.CLASS_NAME.toLowerCase(), OIdentity.CLASS_NAME.toLowerCase(),
OSecurity.RESTRICTED_CLASSNAME.toLowerCase(), OFunction.CLASS_NAME.toLowerCase(), "OTriggered".toLowerCase(),
"OSchedule".toLowerCase(), "internal", OSequence.CLASS_NAME.toLowerCase() })));
new String[] { OUser.CLASS_NAME.toLowerCase(Locale.ENGLISH),
ORole.CLASS_NAME.toLowerCase(Locale.ENGLISH),
OIdentity.CLASS_NAME.toLowerCase(Locale.ENGLISH),
OSecurity.RESTRICTED_CLASSNAME.toLowerCase(Locale.ENGLISH),
OFunction.CLASS_NAME.toLowerCase(Locale.ENGLISH),
"OTriggered".toLowerCase(Locale.ENGLISH),
"OSchedule".toLowerCase(Locale.ENGLISH), "internal",
OSequence.CLASS_NAME.toLowerCase(Locale.ENGLISH) })));

void makeThreadLocalSchemaSnapshot();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ public OClass addClusterId(final int clusterId) {
}

public static OClass addClusters(final OClass cls, final int iClusters) {
final String clusterBase = cls.getName().toLowerCase() + "_";
final String clusterBase = cls.getName().toLowerCase(Locale.ENGLISH) + "_";
for (int i = 1; i < iClusters; ++i) {
cls.addCluster(clusterBase + i);
}
Expand Down Expand Up @@ -2279,8 +2279,8 @@ private void setNameInternal(final String name) {
}

private void renameCluster(String oldName, String newName) {
oldName = oldName.toLowerCase();
newName = newName.toLowerCase();
oldName = oldName.toLowerCase(Locale.ENGLISH);
newName = newName.toLowerCase(Locale.ENGLISH);

final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
Expand Down Expand Up @@ -2723,7 +2723,7 @@ private void removeClusterFromIndexes(final int iId) {
}

private void tryDropCluster(final int defaultClusterId) {
if (name.toLowerCase().equals(getDatabase().getClusterNameById(defaultClusterId))) {
if (name.toLowerCase(Locale.ENGLISH).equals(getDatabase().getClusterNameById(defaultClusterId))) {
// DROP THE DEFAULT CLUSTER CALLED WITH THE SAME NAME ONLY IF EMPTY
if (getDatabase().getClusterRecordSizeById(defaultClusterId) == 0)
getDatabase().getStorage().dropCluster(defaultClusterId, true);
Expand Down
Loading

0 comments on commit 136db63

Please sign in to comment.