ramanathan1504 commented on PR #4133: URL: https://github.com/apache/logging-log4j2/pull/4133#issuecomment-4596750454
@vy I wasn't able to download the `TestFriendlyException-identity-malfunction.patch` file directly due to an expired S3 link error on the GitHub attachment. However, I understood the intent of the identity malfunction and have updated the PR with your remarks in mind. #### 1. Comments Added I have added your requested comment above all `IdentityHashMap` instantiations in both `ThrowableStackTraceRenderer.java` and `ThrowableProxy.java`: `// `IdentityHashMap` is needed to deal with custom `equals()` and `hashCode()` implementations causing collisions` #### 2. Regression Test Instead of modifying the shared `TestFriendlyException` class (whose pre-existing cyclic setups and assertions make it difficult to isolate the failure), I have extended `ThrowablePatternConverterTest.java` with a dedicated, clean regression test: **`testThrowableProxySerializationCollision()`**. #### 3. How it Verifies the Bug This test serializes and deserializes a 3-level exception chain (`outer` -> `middle` -> `inner`) using a local `CollidingException` class that overrides `equals()` and `hashCode()` to compare messages rather than object identity. * The test fails. During `new ThrowableProxy(outer)`, the standard `HashMap` inside the constructor treats the colliding exceptions as circular, setting `causeProxy` to `null` and swallowing the `inner` cause during serialization. The deserialized output only prints 1 `Caused by:` line instead of 2 (failing the assertion). * The test passes successfully. The identity-based collections correctly use reference equality (`==`), resolving the collision and rendering the full 3-level chain accurately. --- If you can share a fresh link or re-upload the TestFriendlyException-identity-malfunction.patch file, I am more than happy to test with your exact patch approach as well and update the code accordingly. -- 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]
