From 4b44d3129c40e2a53b57505f58314038918cc256 Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Sat, 1 Sep 2012 14:50:33 +0000 Subject: [PATCH] AMQ-4012: Use english locale when doing lower/upper case introspection to avoid issues when running on certain locales such as turkish. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1379765 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/activemq/broker/BrokerService.java | 3 ++- .../org/apache/activemq/broker/region/RegionBroker.java | 3 ++- .../apache/activemq/store/jdbc/JDBCPersistenceAdapter.java | 3 ++- .../activemq/transport/stomp/JmsFrameTranslator.java | 5 +++-- .../java/org/apache/activemq/transport/stomp/Stomp.java | 6 ++++-- .../org/apache/activemq/transport/stomp/StompFrame.java | 3 ++- .../org/apache/activemq/util/GenerateJDBCStatements.java | 5 +++-- .../org/apache/activemq/util/IntrospectionSupport.java | 7 ++++--- 8 files changed, 22 insertions(+), 13 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java b/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java index 787b88cd93..dcb6496543 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; @@ -1222,7 +1223,7 @@ public class BrokerService implements Service { if (uri != null) { String scheme = uri.getScheme(); if (scheme != null) { - answer.put(scheme.toLowerCase(), uri.toString()); + answer.put(scheme.toLowerCase(Locale.ENGLISH), uri.toString()); } } } catch (Exception e) { diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java b/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java index 1d1f6f5cc5..a68e96665f 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java @@ -48,6 +48,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -600,7 +601,7 @@ public class RegionBroker extends EmptyBroker { public String getBrokerName() { if (brokerName == null) { try { - brokerName = InetAddressUtil.getLocalHostName().toLowerCase(); + brokerName = InetAddressUtil.getLocalHostName().toLowerCase(Locale.ENGLISH); } catch (Exception e) { brokerName = "localhost"; } diff --git a/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java b/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java index 2a79be3e4b..d2fb03c7a3 100755 --- a/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java +++ b/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.sql.Connection; import java.sql.SQLException; import java.util.Collections; +import java.util.Locale; import java.util.Set; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -478,7 +479,7 @@ public class JDBCPersistenceAdapter extends DataSourceSupport implements Persist try { // Make the filename file system safe. String dirverName = c.getConnection().getMetaData().getDriverName(); - dirverName = dirverName.replaceAll("[^a-zA-Z0-9\\-]", "_").toLowerCase(); + dirverName = dirverName.replaceAll("[^a-zA-Z0-9\\-]", "_").toLowerCase(Locale.ENGLISH); try { adapter = finder.newInstance(dirverName); diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/JmsFrameTranslator.java b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/JmsFrameTranslator.java index 5274b341f9..357551b5f1 100644 --- a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/JmsFrameTranslator.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/JmsFrameTranslator.java @@ -21,6 +21,7 @@ import java.io.Serializable; import java.io.StringReader; import java.io.StringWriter; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import javax.jms.JMSException; @@ -171,7 +172,7 @@ public class JmsFrameTranslator extends LegacyFrameTranslator implements throws JMSException { StringWriter buffer = new StringWriter(); HierarchicalStreamWriter out; - if (transformation.toLowerCase().endsWith("json")) { + if (transformation.toLowerCase(Locale.ENGLISH).endsWith("json")) { out = new JettisonMappedXmlDriver(new Configuration(), false).createWriter(buffer); } else { out = new PrettyPrintWriter(buffer); @@ -201,7 +202,7 @@ public class JmsFrameTranslator extends LegacyFrameTranslator implements StringWriter buffer = new StringWriter(); HierarchicalStreamWriter out; - if (transformation.toLowerCase().endsWith("json")) { + if (transformation.toLowerCase(Locale.ENGLISH).endsWith("json")) { out = new JettisonMappedXmlDriver().createWriter(buffer); } else { out = new PrettyPrintWriter(buffer); diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Stomp.java b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Stomp.java index c502fbdc47..c726220a18 100644 --- a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Stomp.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Stomp.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.transport.stomp; +import java.util.Locale; + public interface Stomp { String NULL = "\u0000"; String NEWLINE = "\n"; @@ -172,11 +174,11 @@ public interface Stomp { JMS_ADVISORY_JSON; public String toString() { - return name().replaceAll("_", "-").toLowerCase(); + return name().replaceAll("_", "-").toLowerCase(Locale.ENGLISH); } public static Transformations getValue(String value) { - return valueOf(value.replaceAll("-", "_").toUpperCase()); + return valueOf(value.replaceAll("-", "_").toUpperCase(Locale.ENGLISH)); } } } diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompFrame.java b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompFrame.java index 30b208f1e8..68ed7855ad 100644 --- a/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompFrame.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompFrame.java @@ -19,6 +19,7 @@ package org.apache.activemq.transport.stomp; import java.io.UnsupportedEncodingException; import java.util.Arrays; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import org.apache.activemq.command.Command; @@ -186,7 +187,7 @@ public class StompFrame implements Command { for (Map.Entry entry : headers.entrySet()) { buffer.append(entry.getKey()); buffer.append(":"); - if (forLogging && entry.getKey().toString().toLowerCase().contains(Stomp.Headers.Connect.PASSCODE)) { + if (forLogging && entry.getKey().toString().toLowerCase(Locale.ENGLISH).contains(Stomp.Headers.Connect.PASSCODE)) { buffer.append("*****"); } else { buffer.append(entry.getValue()); diff --git a/activemq-core/src/main/java/org/apache/activemq/util/GenerateJDBCStatements.java b/activemq-core/src/main/java/org/apache/activemq/util/GenerateJDBCStatements.java index 2a50a99d50..1a2833d2cd 100644 --- a/activemq-core/src/main/java/org/apache/activemq/util/GenerateJDBCStatements.java +++ b/activemq-core/src/main/java/org/apache/activemq/util/GenerateJDBCStatements.java @@ -17,6 +17,7 @@ package org.apache.activemq.util; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Locale; import java.util.regex.Pattern; import org.apache.activemq.store.jdbc.Statements; @@ -55,14 +56,14 @@ public class GenerateJDBCStatements { } for(int i=0; i"); + System.out.println(""); } } //for a typo is not needed if removeMessageStatment typo is corrected Pattern sPattern2= Pattern.compile("get.*Statment$"); for(int i=0; i"); + System.out.println(""); } } //end of generating because of typo diff --git a/activemq-core/src/main/java/org/apache/activemq/util/IntrospectionSupport.java b/activemq-core/src/main/java/org/apache/activemq/util/IntrospectionSupport.java index 360c80261b..912c820f43 100755 --- a/activemq-core/src/main/java/org/apache/activemq/util/IntrospectionSupport.java +++ b/activemq-core/src/main/java/org/apache/activemq/util/IntrospectionSupport.java @@ -26,6 +26,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.Map.Entry; @@ -101,10 +102,10 @@ public final class IntrospectionSupport { continue; } if (name.startsWith("get")) { - name = name.substring(3, 4).toLowerCase() + name = name.substring(3, 4).toLowerCase(Locale.ENGLISH) + name.substring(4); } else { - name = name.substring(2, 3).toLowerCase() + name = name.substring(2, 3).toLowerCase(Locale.ENGLISH) + name.substring(3); } props.put(optionPrefix + name, strValue); @@ -293,7 +294,7 @@ public final class IntrospectionSupport { if (value instanceof ActiveMQDestination) { ActiveMQDestination destination = (ActiveMQDestination)value; buffer.append(destination.getQualifiedName()); - } else if (key.toString().toLowerCase().contains("password")){ + } else if (key.toString().toLowerCase(Locale.ENGLISH).contains("password")){ buffer.append("*****"); } else { buffer.append(value);