-
Notifications
You must be signed in to change notification settings - Fork 1.7k
GH-842: Fix NPEs in KafkaListenerAnnotationBPP #864
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
Conversation
Fixes spring-projects#842 **Cherry-pick to 2.1.x, 2.0.x and 1.3.x**
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one minor issue (x3) I can fix on merge if you agree.
...main/java/org/springframework/kafka/annotation/KafkaListenerAnnotationBeanPostProcessor.java
Outdated
Show resolved
Hide resolved
| else if (resolved == null) { | ||
| return null; | ||
| } | ||
| else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You misunderstood me; we don't need an extra branch at all...
private Pattern resolvePattern(KafkaListener kafkaListener) {
Pattern pattern = null;
String text = kafkaListener.topicPattern();
if (StringUtils.hasText(text)) {
Object resolved = resolveExpression(text);
if (resolved instanceof Pattern) {
pattern = (Pattern) resolved;
}
else if (resolved instanceof String) {
pattern = Pattern.compile((String) resolved);
}
else if (resolved != null) {
throw new IllegalStateException(
"topicPattern must resolve to a Pattern or String, not " + resolved.getClass());
}
}
return pattern;
}|
And cherry-picked to all after resolving conflicts. |
Fixes #842
Cherry-pick to 2.1.x, 2.0.x and 1.3.x