`LogbackLoggingSystem` and `Log4J2LoggingSystem` install a JUL bridge
handler only when the application is not already managing `java.util.logging`.
However, `cleanUp()` removed the bridge handler whenever the bridge class
was present on the classpath, so Spring Boot uninstalled a bridge handler
that an application had installed and managed itself.
Track whether the bridge handler was installed by Spring Boot and only
remove it during cleanup when that is the case.
See gh-50779
Signed-off-by: dhruv-15-03 <dhruvrastogi2004@gmail.com>
Align `MapBinder` with `IndexedElementsBinder` to ensure that
empty strings are bound as empty `Map` instances rather than
throwing a `ConverterNotFoundException`.
See gh-50773
Signed-off-by: Ahmed El amraouiyine <ahmed.elamraouiyine@vilavi.fr>
Update initialization order in `SpringApplication` to ensure
`setAllowBeanDefinitionOverriding` is called before initializiers.
This prevents an initializer from accidentially overriding a bean.
Closes gh-50264
Update the default implementation of `WritableJson.toByteArray()`
to reduce the amount of garbage created from repeated calls.
Prior to this commit, each call would create a new
`ByteArrayOutputStream` and `OutputStreamWriter` to create the
byte array. Writing structured JSON results in many calls to
the `toByteArray()` method, which means we repeatedly create
and destroy the `ByteArrayOutputStream` and `OutputStreamWriter`
objects. Furthermore, both contain buffers that are often
expanded and will overlap with each other.
The updated implementation uses a custom `Appendable`
implementation that uses a single `ByteBuffer` buffer. It also
has a `ThreadLocal` cache so that repeated calls from the same
thread can reuse the buffer. The cache uses a `SoftReference`
to ensure that the JVM can reclaim space if needed (for example,
if a large JSON line was written).
Closes gh-49428