kalayciburak opened a new pull request, #4336: URL: https://github.com/apache/logging-log4j2/pull/4336
Fixes #4333. `DatagramOutputStream.copy` allocated a new exact-size array and copied the accumulated bytes on every `write()`. The encoder writes events in 8 KiB chunks, so assembling a datagram was O(n²). This change backs the accumulator with `ByteArrayOutputStream` (amortized growth) and skips `DatagramSocket.send` when the payload exceeds 65,507 bytes, logging a `StatusLogger` warning instead of letting `send` fail. ## Test Executed: ``` JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 ./mvnw -pl log4j-core-test -am test -Dtest=DatagramOutputStreamTest -Dsurefire.failIfNoSpecifiedTests=false ``` RED: `flushShouldWarnAndDropWhenChunkedPayloadExceedsMaxDatagramSize` failed with `SocketException: Message too long` at `DatagramSocket.send`. GREEN: 2 tests, 0 failures (also 2/0 on `test-without-jackson-databind` and `test-without-jackson-dataformat-yaml`). ## Checklist * Base your changes on `2.x` branch if you are targeting Log4j 2; use `main` otherwise * Focused tests passed as above * Changelog entry in `src/changelog/.2.x.x` * Tests are provided -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
