alhudz opened a new pull request, #1831:
URL: https://github.com/apache/commons-lang/pull/1831

   `ExceptionUtils.removeCommonFrames` walks the cause and wrapper traces from 
the bottom and removes every cause frame that equals the wrapper frame at the 
same offset, but it never stops at the first difference. Common frames are only 
the trailing run both traces share (what `Throwable.printStackTrace` folds into 
`... n more`), so a frame that matches again above a divergence is deleted from 
the middle of the cause trace. `getRootCauseStackTrace`, 
`getRootCauseStackTraceList` and `printRootCauseStackTrace` then print a 
root-cause trace with real frames missing.
   
   The usual trigger is a shared exception factory method that builds both the 
cause and the wrapper:
   
   ```java
   static RuntimeException make(String m, Throwable c) { return new 
RuntimeException(m, c); }
   // cause:   make <- viaA <- run <- main
   // wrapper: make <- viaB <- run <- main
   ```
   
   Expected (as the JDK prints it): the cause section keeps `at Rz.make(...)` 
and `at Rz.viaA(...)`, then `... 2 more`.
   Actual: `getRootCauseStackTrace` prints the cause with only `at 
Rz.viaA(...)`. The frame where the root cause was created is gone.
   
   The fix stops the scan at the first differing frame. Traces whose common 
part is a single trailing run, which covers the normal case, are unchanged.
   
   Tests: `testRemoveCommonFramesStopsAtFirstDifference` covers the list-level 
contract, and `testRootCauseStackTraceKeepsSharedFactoryFrame` checks the same 
thing end to end through `getRootCauseStackTraceList`. Both fail before the 
change and pass after. A full default `mvn` build passes.
   
   
   Before you push a pull request, review this list:
   
   - [x] Read the [contribution guidelines](CONTRIBUTING.md) for this project.
   - [x] Read the [ASF Generative Tooling 
Guidance](https://www.apache.org/legal/generative-tooling.html) if you use 
Artificial Intelligence (AI).
   - [x] I used AI to create any part of, or all of, this pull request. Which 
AI tool was used to create this pull request, and to what extent did it 
contribute? Claude Code found the defect, wrote the patch and tests, and 
drafted this description. I reviewed all of it before submitting.
   - [x] Run a successful build using the default 
[Maven](https://maven.apache.org/) goal with `mvn`; that's `mvn` on the command 
line by itself.
   - [x] Write unit tests that match behavioral changes, where the tests fail 
if the changes to the runtime are not applied. This may not always be possible, 
but it is a best practice.
   - [x] Write a pull request description that is detailed enough to understand 
what the pull request does, how, and why.
   - [x] Each commit in the pull request should have a meaningful subject line 
and body. Note that a maintainer may squash commits during the merge process.
   


-- 
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]

Reply via email to