- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug
Milestone
Description
!!Use pwebb rather than philw opened SPR-8698 and commented
The GenericTypeResolver can throw null pointer exception when types cannot be resolved, I think that it should simply return a null value.
java.lang.NullPointerException
	at java.lang.Class.isAssignableFrom(Native Method)
	at org.springframework.core.GenericTypeResolver.doResolveTypeArguments(GenericTypeResolver.java:209)
	at org.springframework.core.GenericTypeResolver.doResolveTypeArguments(GenericTypeResolver.java:181)
	at org.springframework.core.GenericTypeResolver.resolveTypeArguments(GenericTypeResolver.java:166)
	at org.springframework.core.GenericTypeResolver.resolveTypeArgument(GenericTypeResolver.java:145)
Here is a test to replicate:
@Test
public void resolvesNullIfNotResolvable() throws Exception {
	GenericClass<String> o = new GenericClass<String>();
	assertNull(GenericTypeResolver.resolveTypeArgument(o.getClass(), GenericClass.class));
}
static class GenericClass<T> {
}
I think the fix should be to add a null check on doResolveTypeArguments
private static Class[] doResolveTypeArguments(Class ownerClass, Type ifc, Class genericIfc) {
	if (ifc != null) {
		if (ifc instanceof ParameterizedType) {
		...
Affects: 3.0.6, 3.1 M2
Issue Links:
- DATACMNS-104 Upgrade to Spring 3.0.7. ("is depended on by")
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug