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

[BUG] AppConfigurationRefresh.refreshConfigurations() inconsistency #37018

Open
3 tasks done
yanivnahoum opened this issue Oct 1, 2023 · 4 comments
Open
3 tasks done
Assignees
Labels
azure-spring All azure-spring related issues azure-spring-app-configuration Spring app configuration related issues. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@yanivnahoum
Copy link

yanivnahoum commented Oct 1, 2023

Describe the bug
AppConfiguration for spring boot 2.7.x and 3.x behave inconsistently, and both seem wrong.
com.azure.spring:spring-cloud-azure-appconfiguration-config
In the 4.11.0 version (for Spring Boot 2.7.x), the method com.azure.spring.cloud.appconfiguration.config.AppConfigurationRefresh#refreshConfigurations is annotated with @Async, although it returns a type which is unsupported by Spring for @Async methods: Mono<T>
Effectively, it runs on a background thread just fine, but will throw a NPE if you try to obtain the returned boolean by calling Mono::block() or by assembling it in a reactive chain. When using Spring WebFlux - this is mandatory since the auto-refresh is not activated (it's for Spring MVC apps only).
In the 5.5.0 version (for Spring Boot 3.x), the method com.azure.spring.cloud.appconfiguration.config.AppConfigurationRefresh#refreshConfigurations is no longer annotated with @Async. So now it simply runs on the web worker thread synchronously, which I don't believe was the original intent.

Exception or Stack Trace
13:56:52.925 ERROR http-nio-8080-exec-1 o.a.c.c.C.[.[.[.[dispatcherServlet] Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException: Cannot invoke "reactor.core.publisher.Mono.block()" because the return value of "com.azure.spring.cloud.appconfiguration.config.AppConfigurationRefresh.refreshConfigurations()" is null] with root cause
java.lang.NullPointerException: Cannot invoke "reactor.core.publisher.Mono.block()" because the return value of "com.azure.spring.cloud.appconfiguration.config.AppConfigurationRefresh.refreshConfigurations()" is null
at com.att.training.springboot.examples.FeatureController.fetchAll(FeatureController.java:32)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1072)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:965)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:529)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:623)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:168)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:390)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:926)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1790)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:833)

To Reproduce
Inject a com.azure.spring.cloud.appconfiguration.config.AppConfigurationRefresh into a Spring controller and call
appConfigurationRefresh.refreshConfigurations().block() in one of its methods.

Expected behavior
I would expect refreshConfigurations to run non blocking, async io using a reactive web client. That would allow us to keep the Mono signature, and make it usable both for Spring MVC apps and for Spring WebFlux apps.
I know there are other gaps to fill for Spring WebFlux, but at least this basic functionality would work as expected.

Screenshots
If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: macOS Ventura
  • IDE: Intellij
  • Library/Libraries: com.azure.spring:spring-cloud-azure-appconfiguration-config 4.11.0 & 5.5.0
  • Java version: 17
  • Frameworks: Spring Boot 2.7.14 / 3.1.2

Additional context
Add any other context about the problem here.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
@github-actions github-actions bot added azure-spring All azure-spring related issues Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-triage Workflow: This issue needs the team to triage. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Oct 1, 2023
@Netyyyy
Copy link
Member

Netyyyy commented Oct 7, 2023

@mrm9084 Please take a look

@Netyyyy Netyyyy added azure-spring-app-configuration Spring app configuration related issues. and removed needs-team-triage Workflow: This issue needs the team to triage. labels Oct 7, 2023
@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Oct 7, 2023
@mrm9084 mrm9084 self-assigned this Oct 9, 2023
@mrm9084
Copy link
Member

mrm9084 commented Oct 9, 2023

This should be a dup of this #35845. Looking into updating both libraries to fix the issue.

@yanivnahoum
Copy link
Author

Hi @mrm9084, any progress with this?

@yanivnahoum
Copy link
Author

Almost a year later, version 4.19.0 still has the same bug:

@Async
Mono<Boolean> refreshConfigurations();

Any plans to fix this?

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 azure-spring-app-configuration Spring app configuration related issues. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
Status: Todo
Development

No branches or pull requests

3 participants