RFR: 8306461: ObjectInputStream::readObject() should handle negative array sizes without throwing NegativeArraySizeExceptions [v2]
Volker Simonis
simonis at openjdk.org
Wed Apr 26 11:56:24 UTC 2023
On Tue, 25 Apr 2023 21:01:04 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> test/jdk/java/io/ObjectInputStream/NegativeArraySizeTest.java line 88:
>>
>>> 86: } catch (ObjectStreamException ose) {
>>> 87: // OK, because a NegativeArraySizeException should be converted into a ObjectStreamException
>>> 88: if ("Array length is negative".equals(ose.getMessage())) {
>>
>> This feels like `!equals`, i.e. throw exception when the message is *not* "Array length is negative"?
>
> The complete `getMessage()` is `[Ljava.lang.String;; Array length is negative`.
> Perhaps:
>
> ose.getMessage().contains("Array length is negative") ...
Your right. @RogerRiggs I've further simplified the exception message to only contain the message "Array length is negative". I hope that's fine for you and in line with your previous comment to "*keep the exception logic simple/minimal*".
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13540#discussion_r1177751891
More information about the core-libs-dev
mailing list