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

FlightRecorderApplicationStartup exception on processing Http Request #26057

Closed
ivan-shevtsov opened this issue Nov 9, 2020 · 3 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@ivan-shevtsov
Copy link

ivan-shevtsov commented Nov 9, 2020

Spring Boot 2.4.0-RC1 application with

  1. applicationStartup(new FlightRecorderApplicationStartup())
  2. web mvc controller

starts ok, and I can see messages in JDK mission control. I can execute few requests manually in browser, and they work ok...
But, when I do a load test with JMeter - i get exceptions:

java.util.NoSuchElementException: null
	at java.base/java.util.ArrayDeque.getFirst(ArrayDeque.java:402) ~[na:na]
	at org.springframework.core.metrics.jfr.FlightRecorderApplicationStartup.start(FlightRecorderApplicationStartup.java:55) ~[spring-core-5.3.0.jar:5.3.0]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:160) ~[spring-context-5.3.0.jar:5.3.0]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:426) ~[spring-context-5.3.0.jar:5.3.0]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383) ~[spring-context-5.3.0.jar:5.3.0]
	at org.springframework.web.servlet.FrameworkServlet.publishRequestHandledEvent(FrameworkServlet.java:1141) ~[spring-webmvc-5.3.0.jar:5.3.0]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1023) ~[spring-webmvc-5.3.0.jar:5.3.0]
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.0.jar:5.3.0]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:626) ~[tomcat-embed-core-9.0.39.jar:4.0.FR]
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.0.jar:5.3.0]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) ~[tomcat-embed-core-9.0.39.jar:4.0.FR]

Please find test application at:
https://github.com/lvivJavaClub/jfr-demo/tree/issue_branch
and very simple jmeter scenario https://github.com/lvivJavaClub/jfr-demo/blob/issue_branch/jfr_test_plan.jmx

@wilkinsona
Copy link
Member

Thanks for the sample. This looks like a Spring Framework issue to me. We'll transfer the issue to the Framework repository so that they can take a look.

@bclozel bclozel transferred this issue from spring-projects/spring-boot Nov 9, 2020
@bclozel bclozel self-assigned this Nov 9, 2020
@bclozel bclozel added status: waiting-for-triage An issue we've not yet triaged or decided on type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Nov 9, 2020
@bclozel bclozel added this to the 5.3.2 milestone Nov 9, 2020
@bclozel bclozel added the in: core Issues in core modules (aop, beans, core, context, expression) label Nov 9, 2020
@OrangeDog
Copy link

OrangeDog commented Nov 25, 2020

It happens for me on (I think) every authenticated request at some point after starting. Application was not run with JFR attached.

java.util.NoSuchElementException: null
    at java.util.ArrayDeque.getFirst(ArrayDeque.java:403)
    at org.springframework.core.metrics.jfr.FlightRecorderApplicationStartup.start(FlightRecorderApplicationStartup.java:55)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:160)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:426)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383)
    at org.springframework.security.access.intercept.AbstractSecurityInterceptor.publishEvent(AbstractSecurityInterceptor.java:452)
    at org.springframework.security.access.intercept.AbstractSecurityInterceptor.attemptAuthorization(AbstractSecurityInterceptor.java:248)
    at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:208)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:113)
    ...

@bclozel bclozel closed this as completed in 4337d84 Dec 3, 2020
@bclozel
Copy link
Member

bclozel commented Dec 3, 2020

Thanks for this report.

After considering several approaches, I decided to remove the instrumentation around listeners invocations. One of the main design points behind the ApplicationStartup is about the single-threaded nature of the application context refresh phase. Listener invocation can be concurrent, so we can't guarantee proper behavior here.

We'll consider other instrumentation points and metrics with ApplicationStartup in the future (feel free to suggest some!).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants