@@ -82,10 +82,7 @@ protected <T> T getProperty(String key, Class<T> targetValueType, boolean resolv
82
82
if (resolveNestedPlaceholders && value instanceof String ) {
83
83
value = resolveNestedPlaceholders ((String ) value );
84
84
}
85
- if (logger .isDebugEnabled ()) {
86
- logger .debug (String .format ("Found key '%s' in [%s] with type [%s] and value '%s'" ,
87
- key , propertySource .getName (), value .getClass ().getSimpleName (), value ));
88
- }
85
+ logKeyFound (key , propertySource , value );
89
86
return this .conversionService .convert (value , targetValueType );
90
87
}
91
88
}
@@ -106,10 +103,7 @@ public <T> Class<T> getPropertyAsClass(String key, Class<T> targetValueType) {
106
103
}
107
104
Object value = propertySource .getProperty (key );
108
105
if (value != null ) {
109
- if (logger .isDebugEnabled ()) {
110
- logger .debug (String .format (
111
- "Found key '%s' in [%s] with value '%s'" , key , propertySource .getName (), value ));
112
- }
106
+ logKeyFound (key , propertySource , value );
113
107
Class <?> clazz ;
114
108
if (value instanceof String ) {
115
109
try {
@@ -140,17 +134,36 @@ else if (value instanceof Class) {
140
134
return null ;
141
135
}
142
136
137
+ /**
138
+ * Log the given key as found in the given {@link PropertySource}, resulting in
139
+ * the given value.
140
+ * <p>The default implementation writes a debug log message, including the value.
141
+ * Subclasses may override this to change the log level and/or the log message.
142
+ * @param key the key found
143
+ * @param propertySource the {@code PropertySource} that the key has been found in
144
+ * @param value the corresponding value
145
+ * @since 4.3.1
146
+ */
147
+ protected void logKeyFound (String key , PropertySource <?> propertySource , Object value ) {
148
+ if (logger .isDebugEnabled ()) {
149
+ logger .debug (String .format ("Found key '%s' in [%s] with type [%s] and value '%s'" ,
150
+ key , propertySource .getName (), value .getClass ().getSimpleName (), value ));
151
+ }
152
+ }
153
+
143
154
144
155
@ SuppressWarnings ("serial" )
145
156
@ Deprecated
146
157
private static class ClassConversionException extends ConversionException {
147
158
148
159
public ClassConversionException (Class <?> actual , Class <?> expected ) {
149
- super (String .format ("Actual type %s is not assignable to expected type %s" , actual .getName (), expected .getName ()));
160
+ super (String .format ("Actual type %s is not assignable to expected type %s" ,
161
+ actual .getName (), expected .getName ()));
150
162
}
151
163
152
164
public ClassConversionException (String actual , Class <?> expected , Exception ex ) {
153
- super (String .format ("Could not find/load class %s during attempt to convert to %s" , actual , expected .getName ()), ex );
165
+ super (String .format ("Could not find/load class %s during attempt to convert to %s" ,
166
+ actual , expected .getName ()), ex );
154
167
}
155
168
}
156
169
0 commit comments