diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/util/AggregationAssessor.java b/logback-core/src/main/java/ch/qos/logback/core/joran/util/AggregationAssessor.java index 78e02860ef..64944df1c4 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/util/AggregationAssessor.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/util/AggregationAssessor.java @@ -21,6 +21,7 @@ import ch.qos.logback.core.joran.util.beans.BeanUtil; import ch.qos.logback.core.spi.ContextAwareBase; import ch.qos.logback.core.util.AggregationType; +import ch.qos.logback.core.util.StringUtil; import java.lang.annotation.Annotation; import java.lang.reflect.InvocationTargetException; @@ -53,7 +54,7 @@ public AggregationAssessor(BeanDescriptionCache beanDescriptionCache, Class objC * @return the computed {@link AggregationType} */ public AggregationType computeAggregationType(String name) { - String cName = capitalizeFirstLetter(name); + String cName = StringUtil.capitalizeFirstLetter(name); Method addMethod = findAdderMethod(cName); @@ -82,9 +83,10 @@ public AggregationType computeAggregationType(String name) { } } - String capitalizeFirstLetter(String name) { - return name.substring(0, 1).toUpperCase() + name.substring(1); - } + +// String capitalizeFirstLetter(String name) { +// return StringUtil.capitalizeFirstLetter(name); +// } Method findAdderMethod(String name) { String propertyName = BeanUtil.toLowerCamelCase(name); diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/util/PropertySetter.java b/logback-core/src/main/java/ch/qos/logback/core/joran/util/PropertySetter.java index 3d29a94458..199dc9a5db 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/joran/util/PropertySetter.java +++ b/logback-core/src/main/java/ch/qos/logback/core/joran/util/PropertySetter.java @@ -21,6 +21,7 @@ import ch.qos.logback.core.spi.ContextAwareBase; import ch.qos.logback.core.util.AggregationType; import ch.qos.logback.core.util.PropertySetterException; +import ch.qos.logback.core.util.StringUtil; import java.lang.reflect.Method; @@ -208,7 +209,7 @@ public void addBasicProperty(String name, String strValue) { return; } - name = aggregationAssessor.capitalizeFirstLetter(name); + name = StringUtil.capitalizeFirstLetter(name); Method adderMethod =aggregationAssessor.findAdderMethod(name); if (adderMethod == null) { diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/StringUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/StringUtil.java index 6f04f5a84a..3a66f5587d 100644 --- a/logback-core/src/main/java/ch/qos/logback/core/util/StringUtil.java +++ b/logback-core/src/main/java/ch/qos/logback/core/util/StringUtil.java @@ -39,4 +39,11 @@ public static boolean isNullOrEmpty(String str) { public static boolean notNullNorEmpty(String str) { return !isNullOrEmpty(str); } + + public static String capitalizeFirstLetter(String name) { + if(isNullOrEmpty(name)) + return name; + else + return name.substring(0, 1).toUpperCase() + name.substring(1); + } }