Hi folks,

Looking for a review for this change:

https://bugs.openjdk.java.net/browse/JDK-8141148
http://cr.openjdk.java.net/~robm/8141148/webrev.01/

A fairly straightforward fix for a class cast problem. From the bug:

As a result of https://bugs.openjdk.java.net/browse/JDK-7072353:

http://hg.openjdk.java.net/jdk8u/jdk8u-dev/jdk/rev/18329abcdb7c

The test attached to the bug fails with the following trace:

Exception in thread "main" java.lang.ClassCastException: 
com.sun.jndi.ldap.LdapSearchEnumeration cannot be cast to 
com.sun.jndi.ldap.LdapNamingEnumeration
   at 
com.sun.jndi.ldap.LdapNamingEnumeration.getReferredResults(LdapNamingEnumeration.java:78)
   at 
com.sun.jndi.ldap.LdapNamingEnumeration.getReferredResults(LdapNamingEnumeration.java:36)
   at 
com.sun.jndi.ldap.AbstractLdapNamingEnumeration.hasMoreReferrals(AbstractLdapNamingEnumeration.java:330)
   at 
com.sun.jndi.ldap.AbstractLdapNamingEnumeration.hasMoreImpl(AbstractLdapNamingEnumeration.java:227)
   at 
com.sun.jndi.ldap.AbstractLdapNamingEnumeration.hasMore(AbstractLdapNamingEnumeration.java:189)
   at 
com.sun.jndi.ldap.AbstractLdapNamingEnumeration.hasMoreElements(AbstractLdapNamingEnumeration.java:117)
   at TestLdap.query(TestLdap.java:43)
   at TestLdap.main(TestLdap.java:19)

Post refactor we have a NamingEnumeration interface which is implemented by an 
abstract class AbstractLdapNamingEnumeration.

3 implementations, LdapBindingEnumeration, LdapNamingEnumeration & 
LdapSearchEnumeration extend AbstractLdapNamingEnumeration.

Each implementation has its own getReferredResults method which returns an 
object of the individual implementations type.

Unfortunately this falls down (as can be seen in the stack) because an 
LdapNamingEnumeration.getReferredResults can call refCtx.search, which returns 
an LdapSearchEnumeration. This leads to a situation where LdapNamingEnumeration 
needs to cast an LdapSearchEnumeration which results in the exception above.

        -Rob

Reply via email to