Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeDescriptor throws NPE due to because AnnotatedElement proxy is not cloning arrays #22695

Closed
philwebb opened this issue Mar 27, 2019 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: regression A bug that is also a regression
Milestone

Comments

@philwebb
Copy link
Member

Similar to #22655, the TypeDescriptor.AnnotatedElementAdapter class does not defensively clone the returned array. This means that second calls can result in the following NPE:

Caused by: java.lang.NullPointerException
	at org.springframework.core.convert.TypeDescriptor.annotationEquals(TypeDescriptor.java:502)
	at org.springframework.core.convert.TypeDescriptor.annotationsMatch(TypeDescriptor.java:492)
	at org.springframework.core.convert.TypeDescriptor.equals(TypeDescriptor.java:466)
	at org.springframework.core.convert.support.GenericConversionService$ConverterCacheKey.equals(GenericConversionService.java:470)
	at org.springframework.util.ObjectUtils.nullSafeEquals(ObjectUtils.java:325)
	at org.springframework.util.ConcurrentReferenceHashMap$Segment.findInChain(ConcurrentReferenceHashMap.java:648)
	at org.springframework.util.ConcurrentReferenceHashMap$Segment.getReference(ConcurrentReferenceHashMap.java:504)
	at org.springframework.util.ConcurrentReferenceHashMap.getReference(ConcurrentReferenceHashMap.java:265)
	at org.springframework.util.ConcurrentReferenceHashMap.get(ConcurrentReferenceHashMap.java:235)
	at org.springframework.core.convert.support.GenericConversionService.getConverter(GenericConversionService.java:255)
	at org.springframework.core.convert.support.GenericConversionService.canConvert(GenericConversionService.java:145)
	at org.springframework.boot.context.properties.bind.BindConverter$TypeConverterConversionService.canConvert(BindConverter.java:211)
	at org.springframework.boot.context.properties.bind.BindConverter$CompositeConversionService.convert(BindConverter.java:170)
	at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:98)
	at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:90)
	at org.springframework.boot.context.properties.bind.Binder.handleBindResult(Binder.java:234)
	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:223)

The arrays is also returned from the public getAnnotations() and getDeclaredAnnotations() methods.

@philwebb philwebb self-assigned this Mar 27, 2019
@philwebb philwebb added type: bug A general bug type: regression A bug that is also a regression in: core Issues in core modules (aop, beans, core, context, expression) and removed type: bug A general bug labels Mar 27, 2019
@philwebb philwebb added this to the 5.2 M1 milestone Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

1 participant