HADOOP-18814. Direct class cast causes ClassCastException in TestRPC#testReaderExceptions - #8636
HADOOP-18814. Direct class cast causes ClassCastException in TestRPC#testReaderExceptions#8636anshuksi282-ksolves wants to merge 1 commit into
Conversation
…testReaderExceptions
|
Hi, requesting a review whenever you get a chance. This picks up HADOOP-18814 from #6076 by @teamconfx, which had already passed full CI (checkstyle, unit tests, test4tests) but went stale due to inactivity. The fix here is functionally the same, just adapted to the current JUnit 5 style used in trunk. cc: @ayushtkn @dineshchitlangia @brahmareddybattula @pjfanning @slfan1989 |
|
🎊 +1 overall
This message was automatically generated. |
ayushtkn
left a comment
There was a problem hiding this comment.
If this doesn't fail only, then what are we fixing. I don't think this is something we need
Hi @ayushtkn, thanks for taking a look! To clarify, the test does fail in specific scenarios—specifically when hadoop.security.authentication is set to kerberos (as reported in HADOOP-18814). The issue is that when it fails in that environment, the direct cast (RemoteException)e.getCause() throws a ClassCastException. This completely swallows the actual underlying IOException, making it very confusing and difficult to debug what actually went wrong. This PR doesn't change the core test logic; it just adds a minimal defensive check. If an exception occurs, it ensures the real root cause is surfaced instead of hiding it behind a misleading ClassCastException. Since this was a reported pain point in JIRA (and previously validated in #6076 before going stale), I thought it would be a helpful quality-of-life improvement for developers debugging Kerberos setups. Let me know if that makes sense or if you'd still prefer to skip this! |
ayushtkn
left a comment
There was a problem hiding this comment.
I think the ticket itself is wrong, why would I run a test with some other config, when it isn't written for it. If the test passes doesn't logs anything irrelevant and behaving properly. IMO there is no need of code change here
Hi @ayushtkn, fair point. The only reason for this PR is that sometimes developers run the entire test suite globally with Kerberos enabled. When this test fails during those runs, the ClassCastException hides the real error, which wastes debugging time. However, if we shouldn't modify individual tests for custom global configs, I completely agree with avoiding unnecessary code changes. Just let me know, and I'm happy to close the PR! |
|
I'm fine with this defensive change, but it should not be classified as a Critical Bug as the JIRA ticket claimed, just a Minor Test improvement. |
Thanks @pan3793! I completely agree, it is definitely a minor test improvement rather than a critical bug. Since I don't have the necessary permissions to update the JIRA ticket, could one of the maintainers please update its priority/type? Let me know if anything else is needed from my side to get this merged. |
|
@anshuksi282-ksolves, I updated the JIRA ticket, and I can help merge this unless other maintainers have objections. (will wait for 1 or 2 days) |
Thanks a lot for updating the JIRA and for your help with the merge, @pan3793! Sounds good, I'll wait. |
Description of PR
This PR fixes HADOOP-18814.
TestRPC#testReaderExceptionsdirectly castse.getCause()toRemoteExceptionwithout first checking its type:If the root cause is not a
RemoteException(e.g. whenhadoop.security.authenticationis set tokerberos, where thecause can be a plain
IOExceptionsuch as an authentication failure), this direct cast throws aClassCastException, hiding the actual underlying exception and making the test failure confusing to debug.This PR adds a check for the cause's type before casting. If it is not a
RemoteException, the original exception is rethrown so the real cause is surfaced instead of a misleadingClassCastException.This continues the work started in #6076 by @teamconfx, which had already received a green CI run (checkstyle, unit tests, and test4tests all passed) but went stale due to inactivity.
How was this patch tested?
mvn -pl hadoop-common-project/hadoop-common test -Dtest=TestRPC#testReaderExceptionspasses.Note: per the JIRA's reproduction steps, the original
ClassCastExceptiononly manifests whenhadoop.security.authenticationis set tokerberos. Setting up a local Kerberos environment was out of scope for this fix; the change here is a minimal, low-risk defensive check matching the fix originally proposed and CI-validated in #6076.AI Tooling
Contains content generated by Claude (Anthropic). Used to help investigate the issue and draft the fix.