From 4c295a28d5b31ae58a155a12b014a98289ffb3bc Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Thu, 21 Apr 2011 11:37:22 -0400 Subject: [PATCH] Don't attempt to load camelCased version of the package name. It's unlikely that a package would have a camelCased name and an attempt to load a class with wrong case is causing NoClassDefFoundError instead of ClassNotFoundException on non case-sensitive file systems. --- .../elasticsearch/common/settings/ImmutableSettings.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java index b824710c1c6..294c707b92a 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/settings/ImmutableSettings.java @@ -213,16 +213,11 @@ public class ImmutableSettings implements Settings { try { return (Class) getClassLoader().loadClass(fullClassName); } catch (ClassNotFoundException e1) { - fullClassName = prefixPackage + toCamelCase(sValue) + "." + Strings.capitalize(toCamelCase(sValue)) + suffixClassName; + fullClassName = prefixPackage + toCamelCase(sValue).toLowerCase() + "." + Strings.capitalize(toCamelCase(sValue)) + suffixClassName; try { return (Class) getClassLoader().loadClass(fullClassName); } catch (ClassNotFoundException e2) { - fullClassName = prefixPackage + toCamelCase(sValue).toLowerCase() + "." + Strings.capitalize(toCamelCase(sValue)) + suffixClassName; - try { - return (Class) getClassLoader().loadClass(fullClassName); - } catch (ClassNotFoundException e3) { - throw new NoClassSettingsException("Failed to load class setting [" + setting + "] with value [" + sValue + "]", e); - } + throw new NoClassSettingsException("Failed to load class setting [" + setting + "] with value [" + sValue + "]", e); } } }