Spring Boot BufferedApplicationStartup drained after first request

Viewed 85

I am using the great new ApplicationStartup recording feature of Spring 5.3 / Spring Boot 2.4, with BufferedApplicationStartup (only provided by SB 2.4).

However,

  • on the very first access to the /startup endpoint I seem to get all startup events, but
  • on subsequent calls to the endpoint I only get 3 (exactly 3) new events.

Is this documented somewhere? Is it configurable? It would be great if the data was not lost after the first call. Or is it a bug?

1 Answers

This is the expected behavior here as we are draining the buffer before sending startup events over the wire. Usage of the HTTP POST method also show that this method is not free of side effects.

This aspect could be better documented so feel free to create an issue.

The goal here is to free memory from those buffered events as soon as possible since there might be many. The Java Flight Recorder implementation is also interesting if you wish to record startup events and get more information like GC and class loading.

Once the application is available, most of the startup events should be there. If your application has lazy components, you won’t get that data until they’re called, which can happen anytime during the application runtime.

Related