-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDFS-17828. SocketTimeoutException not recognized in TestWebHdfsTimeouts with Java 24 #7955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
💔 -1 overall
This message was automatically generated. |
PTAL @slfan1989 |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really like this. But you will need to add test cases to verify the exception matching itself works with
- regexp that doesn't parse
- null pattern
- no pattern match
- pattern match
throw new AssertionError(E_NULL_THROWABLE_STRING, t); | ||
} | ||
if (pattern != null && !pattern.matcher(msg).matches()) { | ||
String prefix = org.apache.commons.lang3.StringUtils.isEmpty(message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
our own StringUtils.hasLength(message) does this. silly name but at least unique.
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java
Show resolved
Hide resolved
Throwable t, | ||
String message) { | ||
assertNotNull(t, E_NULL_THROWABLE); | ||
String msg = t.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to caughtString; as msg means "message" to me, and it isn't as the code doesn't use getMessage(). (which I'm happy with not using)
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/test/GenericTestUtils.java
Show resolved
Hide resolved
That is not relevant as the method already expects a Pattern, not a String.
Added the other tests. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
Can you take another look @steveloughran ? If you prefer, I can make your suggested changes in both the old and new method, but I think they should be be as similar as possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented; looks like you aren't that familar with our intercept() method yet -it's how we assert operations raise exceptions
- returns the caught ex for further asserts
- if the exception wasn't raised, and the lambda expression returned something, the string value of that is included in the text
based on ScalaTest.intercept()'s design
|
||
@Test | ||
public void testAssertExceptionContainsNullEx() throws Throwable { | ||
boolean assertTriggered = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use LambdaTestUtils.intercept here.
intercept(AssertionError.class, E_NULL_THROWABLE, () -> assertExceptionContains("", null));
same below.
} catch (AssertionError e) { | ||
assertTriggered = true; | ||
String s = e.toString(); | ||
if (!s.contains(E_UNEXPECTED_EXCEPTION) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, use intercept, but here
AssertionError e = intercept(AssertionError.class, "", () ->
assertExceptionContains("Expected", new Exception("(actual)")));
// checks from L32 onwards
String s = e.toString();
if (!s.contains(E_UNEXPECTED_EXCEPTION) ...
Done @steveloughran |
💔 -1 overall
This message was automatically generated. |
Description of PR
Fixes a test issue where TestWebHdfsTimeouts exepects "connect timed out", but Java 24 returns "Connect timed out"
in the exception message.
How was this patch tested?
Ran the test with Java 24
For code changes:
LICENSE
,LICENSE-binary
,NOTICE-binary
files?