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

Fix kafka connection string auth configuration condition and improve BPP #43854

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

moarychan
Copy link
Member

Description

Fixes #43853

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.

@github-actions github-actions bot added the azure-spring All azure-spring related issues label Jan 21, 2025
@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@moarychan moarychan marked this pull request as ready for review January 21, 2025 07:40

@SuppressWarnings("unchecked")
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (needsPostProcess(bean)) {
azureGlobalProperties = applicationContext.getBean(AzureGlobalProperties.class);
Copy link
Member

Choose a reason for hiding this comment

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

do we need to handle the case when the bean is not present?

Copy link
Member Author

Choose a reason for hiding this comment

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

the getBean will throw exception when not found the global properties.

Copy link
Member

Choose a reason for hiding this comment

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

But the other two BPP won't throw any exceptions, so do we need to throw the exception here?

@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
static BeanPostProcessor kafkaPropertiesBeanPostProcessor(AzureGlobalProperties properties) {
return new KafkaPropertiesBeanPostProcessor(properties);
static BeanPostProcessor kafkaPropertiesBeanPostProcessor() {
Copy link
Member

Choose a reason for hiding this comment

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

does this mean there will be two kafka properties bpp in the context?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, one for jaas based on conn string, another for jaas based on OAuth2.

Copy link
Member

Choose a reason for hiding this comment

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

Are they exclusive? Will they be in the context at the same time?


@SuppressWarnings("unchecked")
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (needsPostProcess(bean)) {
azureGlobalProperties = applicationContext.getBean(AzureGlobalProperties.class);
Copy link
Member

Choose a reason for hiding this comment

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

But the other two BPP won't throw any exceptions, so do we need to throw the exception here?

@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
static BeanPostProcessor kafkaPropertiesBeanPostProcessor(AzureGlobalProperties properties) {
return new KafkaPropertiesBeanPostProcessor(properties);
static BeanPostProcessor kafkaPropertiesBeanPostProcessor() {
Copy link
Member

Choose a reason for hiding this comment

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

Are they exclusive? Will they be in the context at the same time?

moarychan and others added 2 commits January 22, 2025 16:07
…azure/spring/cloud/autoconfigure/implementation/eventhubs/kafka/KafkaPropertiesBeanPostProcessor.java

Co-authored-by: Xiaolu Dai <31124698+saragluna@users.noreply.github.com>
…azure/spring/cloud/autoconfigure/implementation/eventhubs/kafka/KafkaPropertiesBeanPostProcessor.java

Co-authored-by: Xiaolu Dai <31124698+saragluna@users.noreply.github.com>
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
3 participants