Skip to content
Permalink
Browse files
FLUME-2475. toLowerCase/toUpperCase must specify Locale.
(Santiago M. Mola via Hari)
  • Loading branch information
harishreedharan committed Oct 10, 2014
1 parent 7ffbd86 commit f17c7d5022d3e9d112a3843909ad523535fe7e4f
Showing 33 changed files with 86 additions and 45 deletions.
@@ -19,6 +19,7 @@
package org.apache.flume.channel.file.encryption;

import java.security.Key;
import java.util.Locale;

import org.apache.flume.FlumeException;
import org.slf4j.Logger;
@@ -54,7 +55,7 @@ private static CipherProvider getProvider(String cipherProviderType) {
// try to find builder class in enum of known providers
CipherProviderType type;
try {
type = CipherProviderType.valueOf(cipherProviderType.toUpperCase());
type = CipherProviderType.valueOf(cipherProviderType.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException e) {
logger.debug("Not in enum, loading provider class: {}", cipherProviderType);
type = CipherProviderType.OTHER;
@@ -18,6 +18,8 @@
*/
package org.apache.flume.channel.file.encryption;

import java.util.Locale;

import org.apache.flume.Context;
import org.apache.flume.FlumeException;
import org.slf4j.Logger;
@@ -37,7 +39,7 @@ public static KeyProvider getInstance(String keyProviderType, Context context) {
// try to find builder class in enum of known providers
KeyProviderType type;
try {
type = KeyProviderType.valueOf(keyProviderType.toUpperCase());
type = KeyProviderType.valueOf(keyProviderType.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException e) {
logger.debug("Not in enum, loading provider class: {}", keyProviderType);
type = KeyProviderType.OTHER;
@@ -17,6 +17,8 @@
*/
package org.apache.flume.channel.jdbc;

import java.util.Locale;

public enum DatabaseType {
/** All other databases */
OTHER("OTHER", null),
@@ -56,7 +58,7 @@ public String getValidationQuery() {
public static DatabaseType getByName(String dbName) {
DatabaseType type = null;
try {
type = DatabaseType.valueOf(dbName.trim().toUpperCase());
type = DatabaseType.valueOf(dbName.trim().toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException ex) {
type = DatabaseType.OTHER;
}
@@ -18,6 +18,7 @@
package org.apache.flume.channel.jdbc;

import java.sql.Connection;
import java.util.Locale;

public enum TransactionIsolation {

@@ -47,6 +48,6 @@ public String toString() {
}

public static TransactionIsolation getByName(String name) {
return valueOf(name.trim().toUpperCase());
return valueOf(name.trim().toUpperCase(Locale.ENGLISH));
}
}
@@ -18,6 +18,7 @@
package org.apache.flume.channel.jdbc;

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

import org.junit.Assert;
@@ -61,7 +62,7 @@ public void testDatabaseTypeLookup() {
Assert.assertSame(type, lookupType);
Assert.assertEquals(key, lookupTypeName);

DatabaseType lookupType2 = DatabaseType.getByName(key.toLowerCase());
DatabaseType lookupType2 = DatabaseType.getByName(key.toLowerCase(Locale.ENGLISH));
Assert.assertSame(type, lookupType2);
}
}
@@ -18,6 +18,7 @@
package org.apache.flume.channel.jdbc;

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

import org.junit.Assert;
@@ -62,7 +63,7 @@ public void testReverseLookup() {
Assert.assertEquals(key, lookupTxIsolationName);

TransactionIsolation lookupTxIsolation2 =
TransactionIsolation.getByName(key.toLowerCase());
TransactionIsolation.getByName(key.toLowerCase(Locale.ENGLISH));
Assert.assertSame(txIsolation, lookupTxIsolation2);
}
}
@@ -18,6 +18,8 @@
*/
package org.apache.flume.clients.log4jappender;

import java.util.Locale;

public enum Log4jAvroHeaders {
OTHER("flume.client.log4j.logger.other"),
LOGGER_NAME("flume.client.log4j.logger.name"),
@@ -43,7 +45,7 @@ public String toString(){
public static Log4jAvroHeaders getByName(String headerName){
Log4jAvroHeaders hdrs = null;
try{
hdrs = Log4jAvroHeaders.valueOf(headerName.toLowerCase().trim());
hdrs = Log4jAvroHeaders.valueOf(headerName.toLowerCase(Locale.ENGLISH).trim());
}
catch(IllegalArgumentException e){
hdrs = Log4jAvroHeaders.OTHER;
@@ -16,6 +16,8 @@
*/
package org.apache.flume.conf;

import java.util.Locale;

import org.apache.flume.conf.ComponentConfiguration.ComponentType;
import org.apache.flume.conf.channel.ChannelConfiguration.ChannelConfigurationType;
import org.apache.flume.conf.channel.ChannelSelectorConfiguration.ChannelSelectorConfigurationType;
@@ -40,22 +42,22 @@ public class ComponentConfigurationFactory {
return confType.getConstructor(String.class).newInstance(type);
} catch (Exception ignored) {
try {
type = type.toUpperCase();
type = type.toUpperCase(Locale.ENGLISH);
switch(component){
case SOURCE:
return SourceConfigurationType.valueOf(type.toUpperCase())
return SourceConfigurationType.valueOf(type.toUpperCase(Locale.ENGLISH))
.getConfiguration(name);
case SINK:
return SinkConfigurationType.valueOf(type.toUpperCase())
return SinkConfigurationType.valueOf(type.toUpperCase(Locale.ENGLISH))
.getConfiguration(name);
case CHANNEL:
return ChannelConfigurationType.valueOf(type.toUpperCase())
return ChannelConfigurationType.valueOf(type.toUpperCase(Locale.ENGLISH))
.getConfiguration(name);
case SINK_PROCESSOR:
return SinkProcessorConfigurationType.valueOf(type.toUpperCase())
return SinkProcessorConfigurationType.valueOf(type.toUpperCase(Locale.ENGLISH))
.getConfiguration(name);
case CHANNELSELECTOR:
return ChannelSelectorConfigurationType.valueOf(type.toUpperCase())
return ChannelSelectorConfigurationType.valueOf(type.toUpperCase(Locale.ENGLISH))
.getConfiguration(name);
case SINKGROUP:
return new SinkGroupConfiguration(name);
@@ -24,6 +24,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -457,7 +458,7 @@ private Set<String> validateChannels(Set<String> channelSet) {
configSpecified = true;
}
} else {
config = chType.toString().toUpperCase();
config = chType.toString().toUpperCase(Locale.ENGLISH);
configSpecified = true;
}

@@ -553,7 +554,7 @@ private Set<String> validateSources(Set<String> channelSet) {
configSpecified = true;
}
} else {
config = srcType.toString().toUpperCase();
config = srcType.toString().toUpperCase(Locale.ENGLISH);
configSpecified = true;
}
try {
@@ -667,7 +668,7 @@ private Set<String> validateSinks(Set<String> channelSet) {
configSpecified = true;
}
} else {
config = sinkType.toString().toUpperCase();
config = sinkType.toString().toUpperCase(Locale.ENGLISH);
configSpecified = true;
}
try {
@@ -18,6 +18,7 @@

import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

@@ -93,7 +94,7 @@ public void configure(Context context) throws ConfigurationException {
config = "OTHER";
}
} else {
config = selectorType.toString().toUpperCase();
config = selectorType.toString().toUpperCase(Locale.ENGLISH);
}

this.selectorConf =
@@ -19,6 +19,7 @@
package org.apache.flume.channel;

import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.apache.flume.Channel;
@@ -73,7 +74,7 @@ private static ChannelSelector getSelectorForType(String type) {
ChannelSelectorType selectorType = ChannelSelectorType.OTHER;

try {
selectorType = ChannelSelectorType.valueOf(type.toUpperCase());
selectorType = ChannelSelectorType.valueOf(type.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException ex) {
LOGGER.debug("Selector type {} is a custom type", type);
}
@@ -19,6 +19,8 @@

package org.apache.flume.channel;

import java.util.Locale;

import org.apache.flume.Channel;
import org.apache.flume.ChannelFactory;
import org.apache.flume.FlumeException;
@@ -54,7 +56,7 @@ public Class<? extends Channel> getClass(String type)
String channelClassName = type;
ChannelType channelType = ChannelType.OTHER;
try {
channelType = ChannelType.valueOf(type.toUpperCase());
channelType = ChannelType.valueOf(type.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException ex) {
logger.debug("Channel type {} is a custom type", type);
}
@@ -568,7 +568,7 @@ public static class Builder {
SpoolDirectorySourceConfigurationConstants.DEFAULT_INPUT_CHARSET;
private DecodeErrorPolicy decodeErrorPolicy = DecodeErrorPolicy.valueOf(
SpoolDirectorySourceConfigurationConstants.DEFAULT_DECODE_ERROR_POLICY
.toUpperCase());
.toUpperCase(Locale.ENGLISH));
private ConsumeOrder consumeOrder =
SpoolDirectorySourceConfigurationConstants.DEFAULT_CONSUME_ORDER;

@@ -24,6 +24,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;

@@ -105,7 +106,7 @@ void register() {
if (!registered) {
try {
ObjectName objName = new ObjectName("org.apache.flume."
+ type.name().toLowerCase() + ":type=" + this.name);
+ type.name().toLowerCase(Locale.ENGLISH) + ":type=" + this.name);

if (ManagementFactory.getPlatformMBeanServer().isRegistered(objName)) {
logger.debug("Monitored counter group for type: " + type + ", name: "
@@ -149,7 +150,7 @@ public void stop() {
logger.info("Component type: " + type + ", name: " + name + " stopped");

// Retrieve the type for this counter group
final String typePrefix = type.name().toLowerCase();
final String typePrefix = type.name().toLowerCase(Locale.ENGLISH);

// Print out the startTime for this component
logger.info("Shutdown Metric for type: " + type + ", "
@@ -18,6 +18,8 @@

package org.apache.flume.interceptor;

import java.util.Locale;

import org.apache.flume.interceptor.Interceptor.Builder;

/**
@@ -28,7 +30,7 @@ public class InterceptorBuilderFactory {

private static Class<? extends Builder> lookup(String name) {
try {
return InterceptorType.valueOf(name.toUpperCase()).getBuilderClass();
return InterceptorType.valueOf(name.toUpperCase(Locale.ENGLISH)).getBuilderClass();
} catch (IllegalArgumentException e) {
return null;
}
@@ -43,6 +43,7 @@
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.Locale;

/**
* A deserializer that parses Avro container files, generating one Flume event
@@ -83,7 +84,7 @@ private AvroEventDeserializer(Context context, ResettableInputStream ris) {

schemaType = AvroSchemaType.valueOf(
context.getString(CONFIG_SCHEMA_TYPE_KEY,
AvroSchemaType.HASH.toString()).toUpperCase());
AvroSchemaType.HASH.toString()).toUpperCase(Locale.ENGLISH));
if (schemaType == AvroSchemaType.LITERAL) {
logger.warn(CONFIG_SCHEMA_TYPE_KEY + " set to " +
AvroSchemaType.LITERAL.toString() + ", so storing full Avro " +
@@ -26,6 +26,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Locale;

@InterfaceAudience.Private
@InterfaceStability.Stable
public class EventDeserializerFactory {
@@ -42,7 +44,7 @@ public static EventDeserializer getInstance(
// try to find builder class in enum of known output serializers
EventDeserializerType type;
try {
type = EventDeserializerType.valueOf(deserializerType.toUpperCase());
type = EventDeserializerType.valueOf(deserializerType.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException e) {
logger.debug("Not in enum, loading builder class: {}", deserializerType);
type = EventDeserializerType.OTHER;
@@ -20,6 +20,8 @@

import com.google.common.base.Preconditions;
import java.io.OutputStream;
import java.util.Locale;

import org.apache.flume.Context;
import org.apache.flume.FlumeException;
import org.apache.flume.annotations.InterfaceAudience;
@@ -43,7 +45,7 @@ public static EventSerializer getInstance(
// try to find builder class in enum of known output serializers
EventSerializerType type;
try {
type = EventSerializerType.valueOf(serializerType.toUpperCase());
type = EventSerializerType.valueOf(serializerType.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException e) {
logger.debug("Not in enum, loading builder class: {}", serializerType);
type = EventSerializerType.OTHER;
@@ -30,7 +30,6 @@
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

/**
* A deserializer that parses text lines from a file.
@@ -19,6 +19,8 @@

package org.apache.flume.sink;

import java.util.Locale;

import org.apache.flume.FlumeException;
import org.apache.flume.Sink;
import org.apache.flume.SinkFactory;
@@ -56,7 +58,7 @@ public Class<? extends Sink> getClass(String type)
String sinkClassName = type;
SinkType sinkType = SinkType.OTHER;
try {
sinkType = SinkType.valueOf(type.toUpperCase());
sinkType = SinkType.valueOf(type.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException ex) {
logger.debug("Sink type {} is a custom type", type);
}

0 comments on commit f17c7d5

Please sign in to comment.