[java] #16753 workaround for JDK bug JDK-8228970#16793
[java] #16753 workaround for JDK bug JDK-8228970#16793asolntsev merged 1 commit intoSeleniumHQ:trunkfrom
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||
8b0de03 to
9808f74
Compare
…rg/browse/JDK-8228970 Replace all usages of JDK built-in method `stream.readAllBytes()` by our own (fixed) method `Read.toByteArray(stream)`.
9808f74 to
7378ea4
Compare
cgoldberg
left a comment
There was a problem hiding this comment.
Looks fine.. but is it really necessary to implement an alternative instead of just catching AssertionError that might happen in Java 11 if you try to read an empty InputStream? The existing readAllBytes should work otherwise, right?
|
@cgoldberg I don't think it happens only for empty stream. I manage to reproduce the issue when reading output of "get screenshot" and "get page source" operations which obviously don't return empty stream. |
cgoldberg
left a comment
There was a problem hiding this comment.
Sounds good. Thanks for fixing this.
User description
Replace all usages of JDK built-in method
stream.readAllBytes()by our own (fixed) methodRead.toByteArray(stream).🔗 Related Issues
#16753
JDK bug: https://bugs.openjdk.org/browse/JDK-8228970
🔄 Types of changes
PR Type
Bug fix
Description
Create new
Readutility class with workaround for JDK-8228970 bugReplace all
stream.readAllBytes()calls withRead.toByteArray()Add helper methods
toString()andresourceAsString()for convenienceImprove resource stream handling with proper try-with-resources patterns
Diagram Walkthrough
File Walkthrough
1 files
New utility class for safe stream reading6 files
Replace readAllBytes with Read.toStringReplace readAllBytes with Read.toByteArrayUse Read.resourceAsString for script loadingReplace readAllBytes with resourceAsStringReplace readAllBytes with Read.toByteArrayReplace readAllBytes with Read.toByteArray1 files
Add unit tests for Read utility class2 files
Add io module dependency to seleniumExpand visibility for io module