-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -318,6 +318,17 @@ public static void assertExceptionContains(String expectedText, Throwable t) { | |
assertExceptionContains(expectedText, t, ""); | ||
} | ||
|
||
/** | ||
* Assert that an exception's <code>toString()</code> value | ||
* matches the regex pattern. | ||
* @param pattern regex pattern to match | ||
* @param t thrown exception | ||
* @throws AssertionError if the pattern does not match | ||
*/ | ||
public static void assertExceptionMatches(Pattern pattern, Throwable t) { | ||
assertExceptionMatches(pattern, t, ""); | ||
} | ||
|
||
/** | ||
* Assert that an exception's <code>toString()</code> value | ||
* contained the expected text. | ||
|
@@ -345,6 +356,33 @@ public static void assertExceptionContains(String expectedText, | |
} | ||
} | ||
|
||
/** | ||
* Assert that an exception's <code>toString()</code> value | ||
* matches the pattern. | ||
* @param pattern regex pattern to match | ||
* @param t thrown exception | ||
* @param message any extra text for the string | ||
* @throws AssertionError if the expected string is not found | ||
*/ | ||
public static void assertExceptionMatches(Pattern pattern, | ||
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 commentThe 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) |
||
if (msg == null) { | ||
throw new AssertionError(E_NULL_THROWABLE_STRING, t); | ||
} | ||
if (pattern != null && !pattern.matcher(msg).matches()) { | ||
steveloughran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
String prefix = org.apache.commons.lang3.StringUtils.isEmpty(message) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
? "" : (message + ": "); | ||
throw new AssertionError( | ||
String.format("%s Expected to match '%s' %s: %s", | ||
prefix, pattern, E_UNEXPECTED_EXCEPTION, | ||
StringUtils.stringifyException(t)), | ||
t); | ||
} | ||
} | ||
|
||
/** | ||
* Wait for the specified test to return true. The test will be performed | ||
* initially and then every {@code checkEveryMillis} until at least | ||
|
Uh oh!
There was an error while loading. Please reload this page.