Skip to content

fix scs sources cannot be appended to Kafka binder context - #31715

Merged
yiliuTo merged 13 commits into
Azure:mainfrom
yiliuTo:fix-binder-source-append
Oct 28, 2022
Merged

fix scs sources cannot be appended to Kafka binder context#31715
yiliuTo merged 13 commits into
Azure:mainfrom
yiliuTo:fix-binder-source-append

Conversation

@yiliuTo

@yiliuTo yiliuTo commented Oct 25, 2022

Copy link
Copy Markdown
Member

Description

As subject. Currently when overriding Kafka binder context's sources, we detected the origin sources by property key of spring.main.sources. However, this property is stored in a Map thus its key is not flattened by default. Fix it by flatten it manually like how Spring Cloud Stream does.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@ghost ghost added the azure-spring All azure-spring related issues label Oct 25, 2022
@azure-sdk

Copy link
Copy Markdown
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

spring-cloud-azure-autoconfigure

@yiliuTo
yiliuTo marked this pull request as ready for review October 25, 2022 08:41
* @param flattenedProperties map to which we'll add the falttened property
*/
@SuppressWarnings("unchecked")
private void flatten(String propertyName, Object value,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not return a map instead passing in the map?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And hide the recursive call in another method?

(propertyName != null ? propertyName + "." : "") + k, v,
flattenedProperties));
} else {
flattenedProperties.put(propertyName, value.toString());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the flattenedProperties can be Map<String, String>?


private String buildKafkaBinderSources(BinderProperties binderProperties) {
Map<String, Object> flattenedProperties = new HashMap<>();
flatten(null, binderProperties.getEnvironment(), flattenedProperties);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what's the spring.main.sources property name like in this env?

@yiliuTo
yiliuTo merged commit f711924 into Azure:main Oct 28, 2022
yiliuTo added a commit to yiliuTo/azure-sdk-for-java that referenced this pull request Oct 28, 2022
yiliuTo added a commit to yiliuTo/azure-sdk-for-java that referenced this pull request Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azure-spring All azure-spring related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants