Skip to content

Conversation

@artembilan
Copy link
Member

Fixes #842

Cherry-pick to 2.1.x, 2.0.x and 1.3.x

Copy link
Contributor

@garyrussell garyrussell left a 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.

else if (resolved == null) {
return null;
}
else {
Copy link
Contributor

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;
	}

@garyrussell garyrussell merged commit 4cdaa94 into spring-projects:master Nov 7, 2018
garyrussell pushed a commit that referenced this pull request Nov 7, 2018
* GH-842: Fix NPEs in KafkaListenerAnnotationBPP

Fixes #842

**Cherry-pick to 2.1.x, 2.0.x and 1.3.x**

* * Move null check to the `else` branch

* * Do not use `if (resolved == null)` at all
garyrussell pushed a commit that referenced this pull request Nov 7, 2018
* GH-842: Fix NPEs in KafkaListenerAnnotationBPP

Fixes #842

**Cherry-pick to 2.1.x, 2.0.x and 1.3.x**

* * Move null check to the `else` branch

* * Do not use `if (resolved == null)` at all
garyrussell pushed a commit that referenced this pull request Nov 7, 2018
* GH-842: Fix NPEs in KafkaListenerAnnotationBPP

Fixes #842

**Cherry-pick to 2.1.x, 2.0.x and 1.3.x**

* * Move null check to the `else` branch

* * Do not use `if (resolved == null)` at all
@garyrussell
Copy link
Contributor

And cherry-picked to all after resolving conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants