RFR: JDK-8276939: Fix AbstractLdapNamingEnumeration next to throw NoSuchElementException instead of NullPointerException
andrewluotechnologies
duke at openjdk.java.net
Thu Nov 18 15:11:03 UTC 2021
`AbstractLdapNamingEnumeration` `next` throws `NullPointerException` instead of `NoSuchElementException`, however the javadoc for `NamingEnumeration` says that next should throw `NoSuchElementException` when no elements are available (https://docs.oracle.com/en/java/javase/17/docs/api/java.naming/javax/naming/NamingEnumeration.html#next())
The bug is basically that `next()` calls `hasMore()` -> `hasMoreImpl()` which calls `cleanup()` when there are no more elements. `cleanup()` sets `homeCtx = null;` which causes NullPointerException to be thrown on this line in `getNextBatch()`: `res = homeCtx.getSearchReply(enumClnt, res);`
-------------
Commit messages:
- JDK-8276939: Fix AbstractLdapNamingEnumeration next to throw NoSuchElementException instead of NullPointerException
Changes: https://git.openjdk.java.net/jdk/pull/6095/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6095&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8276939
Stats: 3 lines in 1 file changed: 3 ins; 0 del; 0 mod
Patch: https://git.openjdk.java.net/jdk/pull/6095.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/6095/head:pull/6095
PR: https://git.openjdk.java.net/jdk/pull/6095
More information about the core-libs-dev
mailing list