Defensive null check against name parameter in AutowireMode#from
See gh-24285
This commit is contained in:
parent
3c1ee64b7f
commit
99bd1a1533
|
|
@ -133,12 +133,9 @@ public @interface TestConstructor {
|
||||||
ANNOTATED;
|
ANNOTATED;
|
||||||
|
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(AutowireMode.class);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@code AutowireMode} enum constant with the supplied name,
|
* Get the {@code AutowireMode} enum constant with the supplied name,
|
||||||
* ignoring case.
|
* ignoring case.
|
||||||
*
|
|
||||||
* @param name the name of the enum constant to retrieve
|
* @param name the name of the enum constant to retrieve
|
||||||
* @return the corresponding enum constant or {@code null} if not found
|
* @return the corresponding enum constant or {@code null} if not found
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
|
|
@ -146,17 +143,20 @@ public @interface TestConstructor {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static AutowireMode from(@Nullable String name) {
|
public static AutowireMode from(@Nullable String name) {
|
||||||
|
if (name == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return AutowireMode.valueOf(name.trim().toUpperCase());
|
return AutowireMode.valueOf(name.trim().toUpperCase());
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (IllegalArgumentException ex) {
|
||||||
|
Log logger = LogFactory.getLog(AutowireMode.class);
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug(String.format("Failed to parse autowire mode from '%s': %s", name,
|
logger.debug(String.format("Failed to parse autowire mode from '%s': %s", name, ex.getMessage()));
|
||||||
ex.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue