On Wed, 17 Dec 2025 11:50:53 GMT, eunbin son <[email protected]> wrote:
>> ## Summary >> Adds comprehensive edge case tests for `Objects.requireNonNull`, >> `requireNonNullElse`, and `requireNonNullElseGet` methods to improve >> test coverage. >> >> ## Problem >> The current test suite for `Objects.requireNonNull` methods covers >> basic cases but lacks edge case coverage. >> >> ## Solution >> This PR adds tests for the following edge cases: >> - requireNonNull with null Supplier parameter >> - requireNonNull with Supplier that throws exception >> - requireNonNullElse with both arguments null >> - requireNonNullElseGet with null supplier >> - requireNonNullElseGet with supplier returning null >> >> ## Issue >> Fixes JDK-8373661 >> >> **JBS Issue Link**: >> https://bugs.java.com/bugdatabase/view_bug?bug_id=JDK-8373661 >> >> ## Type of Change >> - [x] Test addition/modification >> - [ ] Bug fix >> - [ ] New feature >> - [ ] Documentation improvement >> - [ ] Refactoring >> >> ## Testing >> >> make test TEST="jtreg:test/jdk/java/util/Objects" > > eunbin son has updated the pull request incrementally with one additional > commit since the last revision: > > 8373661: Use assertSame for exception instance verification > > Updated testRequireNonNullWithSupplierThrowingException to allocate > the exception outside of the lambda and use assertSame to verify > the same exception instance is thrown, as suggested by @liach. > > This provides a more precise verification that the exception from > the supplier is thrown directly, not wrapped. > > Thanks to @liach for the feedback. I agree with Roger's points about simplifying some test messages. Sometimes we don't even write test messages if the subject is clear from the test code context, because the exceptions usually include the line numbers already. However, these are not critical. However, I think Roger might be too strict on imports and Assertions.fail vs exceptions - these are acceptable because they don't affect the test quality, so I am not concerned. ------------- PR Comment: https://git.openjdk.org/jdk/pull/28845#issuecomment-3667486305
