-
Bug
-
Resolution: Fixed
-
P1
-
1.4.0
-
rc1
-
x86
-
windows_nt
-
Verified
Name: pa48320 Date: 10/08/2001
We have a released product that works correctly with Java 2 SDK, Standard Edition Version 1.3.1_01. However, when this same product is run in Java 2 SDK, Standard Edition Version 1.4.0 Beta 3, we see a NoSuchElementException being thrown from NamingEnumeration.nextElement() even though NamingEnumeration.hasMoreElements() returns true.
When the included code snippet is run in JDK 1.4.0, Beta 3, we get the following output. Note that hasMoreElements() returns true and the NoSuchElementException is still thrown. One interesting observation is that I can change my NamingEnumeration.nextElement() call to NamingEnumeration.next() and the exception is no longer thrown.
Output:
class javax.naming.directory.InitialDirContext.search("sascomponent=sasPortal,cn=SAS,o=portal.sas.com", (&(objectClass=sasPortalWindow)(|(sasKeyword=PortalTool))), javax.naming.directory.SearchControls@8c436b)
enumerating over class com.sun.jndi.ldap.LdapSearchEnumeration
class com.sun.jndi.ldap.LdapSearchEnumeration. hasMoreElements() = true
class com.sun.jndi.ldap.LdapSearchEnumeration. nextElement() returned a class javax.naming.directory.SearchResult whose value = sasPortalWindowCn=PortalLogin,cn=Public,cn=sasPortalWindows: null:null:{objectclass=objectclass: sasportalwindow, sasportalwindo
wcn=sasportalwindowcn: PortalLogin, sasportaltitle=sasportaltitle: Login, sas-portalentitytype=sas-portalentitytype: sascustom, saskeyword=saskeyword: PortalTool, _SASPortal_}
class com.sun.jndi.ldap.LdapSearchEnumeration. hasMoreElements() = true
class com.sun.jndi.ldap.LdapSearchEnumeration. nextElement() returned a class javax.naming.directory.SearchResult whose value = sasPortalWindowCn=PortalLogout,cn=Public,cn=sasPortalWindows: null:null:{objectclass=objectclass: sasportalwindow, sasportalwind
owcn=sasportalwindowcn: PortalLogout, sasportaltitle=sasportaltitle: Logout, sas-portalentitytype=sas-portalentitytype: sascustom, saskeyword=saskeyword: PortalTool, _SASPortal_, sasportalmessage=sasportalmessage: You have been successfully logged out of t
he Portal.}
class com.sun.jndi.ldap.LdapSearchEnumeration. hasMoreElements() = true
class com.sun.jndi.ldap.LdapSearchEnumeration. nextElement() returned a class javax.naming.directory.SearchResult whose value = sasPortalWindowCn=PortalSearch,cn=Public,cn=sasPortalWindows: null:null:{objectclass=objectclass: sasportalwindow, sasportalwind
owcn=sasportalwindowcn: PortalSearch, sasportaltitle=sasportaltitle: Quick Search, sas-portalentitytype=sas-portalentitytype: sascustom, saskeyword=saskeyword: PortalTool, _SASPortal_}
class com.sun.jndi.ldap.LdapSearchEnumeration. hasMoreElements() = true
class com.sun.jndi.ldap.LdapSearchEnumeration. nextElement() returned a class javax.naming.directory.SearchResult whose value = sasPortalWindowCn=PortalHelp,cn=Public,cn=sasPortalWindows: null:null:{objectclass=objectclass: sasportalwindow, sasportalwindow
cn=sasportalwindowcn: PortalHelp, sasportaltitle=sasportaltitle: Help, sas-portalentitytype=sas-portalentitytype: sascustom, saskeyword=saskeyword: PortalTool, _SASPortal_}
class com.sun.jndi.ldap.LdapSearchEnumeration. hasMoreElements() = true
class com.sun.jndi.ldap.LdapSearchEnumeration. nextElement() returned a class javax.naming.directory.SearchResult whose value = sasPortalWindowCn=PortalCustomize,cn=Public,cn=sasPortalWindows: null:null:{objectclass=objectclass: sasportalwindow, sasportalw
indowcn=sasportalwindowcn: PortalCustomize, sasportaltitle=sasportaltitle: Customize, sas-portalentitytype=sas-portalentitytype: sascustom, saskeyword=saskeyword: PortalTool, _SASPortal_}
class com.sun.jndi.ldap.LdapSearchEnumeration. hasMoreElements() = true
class com.sun.jndi.ldap.LdapSearchEnumeration. nextElement() returned a class javax.naming.directory.SearchResult whose value = sasportalwindowcn=AddWindow,cn=Public,cn=sasPortalWindows: null:null:{objectclass=objectclass: sasportalwindow, sasportalwindowc
n=sasportalwindowcn: AddWindow, sasportaltitle=sasportaltitle: Add Window, sas-portalentitytype=sas-portalentitytype: sascustom, saskeyword=saskeyword: PortalTool, _SASPortal_}
class com.sun.jndi.ldap.LdapSearchEnumeration. hasMoreElements() = true
class com.sun.jndi.ldap.LdapSearchEnumeration. nextElement() returned a class javax.naming.directory.SearchResult whose value = sasportalwindowcn=Personalize,cn=Public,cn=sasPortalWindows: null:null:{objectclass=objectclass: sasportalwindow, sasportalwindo
wcn=sasportalwindowcn: Personalize, sasportaltitle=sasportaltitle: Personalize, sas-portalentitytype=sas-portalentitytype: sascustom, saskeyword=saskeyword: PortalTool, _SASPortal_}
class com.sun.jndi.ldap.LdapSearchEnumeration. hasMoreElements() = true
class com.sun.jndi.ldap.LdapSearchEnumeration. nextElement() returned a class javax.naming.directory.SearchResult whose value = sasPortalWindowCn=PortalAdvancedSearch,cn=Public,cn=sasPortalWindows: null:null:{objectclass=objectclass: sasportalwindow, saspo
rtalwindowcn=sasportalwindowcn: PortalAdvancedSearch, sasportaltitle=sasportaltitle: Detailed Search, sas-portalentitytype=sas-portalentitytype: sascustom, saskeyword=saskeyword: PortalTool, _SASPortal_}
class com.sun.jndi.ldap.LdapSearchEnumeration. hasMoreElements() = true
java.util.NoSuchElementException: invalid enumeration handle
at com.sun.jndi.ldap.LdapNamingEnumeration.nextAux(LdapNamingEnumeration.java:252)
at com.sun.jndi.ldap.LdapNamingEnumeration.nextElement(LdapNamingEnumeration.java:90)
at com.sas.edir.ldap.LdapEnterpriseDirectory.edirSearch(LdapEnterpriseDirectory.java:1325)
at com.sas.edir.ldap.LdapEnterpriseDirectory.edirSearch(LdapEnterpriseDirectory.java:1185)
at com.sas.edir.ldap.LdapEnterpriseDirectory.edirListIterator(LdapEnterpriseDirectory.java:1103)
at com.sas.edir.ldap.LdapEnterpriseDirectory.edirListIterator(LdapEnterpriseDirectory.java:935)
at com.sas.edir.webapp.portal.PortalLogicBean.getVisibleToolWindows(PortalLogicBean.java:293)
at com.sas.edir.webapp.portal.PortalLogicBean.getActiveWindow(PortalLogicBean.java:438)
at jsp.html.portal._0002fjsp_0002fhtml_0002fportal_0002fPortalWindow_0002ejspPortalWindow_jsp_0._jspService(_0002fjsp_0002fhtml_0002fportal_0002fPortalWindow_0002ejspPortalWindow_jsp_0.java:132)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.facade.RequestDispatcherImpl.doInclude(RequestDispatcherImpl.java:400)
at org.apache.tomcat.facade.RequestDispatcherImpl.include(RequestDispatcherImpl.java:270)
at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:414)
at jsp.html.portal._0002fjsp_0002fhtml_0002fportal_0002fPortal_0002ejspPortal_jsp_0._jspService(_0002fjsp_0002fhtml_0002fportal_0002fPortal_0002ejspPortal_jsp_0.java:449)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.facade.RequestDispatcherImpl.doForward(RequestDispatcherImpl.java:222)
at org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:162)
at com.sas.edir.webapp.portal.PortalServlet.doPost(PortalServlet.java:833)
at com.sas.edir.webapp.portal.PortalServlet.doGet(PortalServlet.java:116)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:539)
Code Snippet:
...
private DirContext _appContext;
...
try
{
if (_appContext != null)
{
System.out.println(_appContext.getClass() + ".search(" + context + ", " + filter + ", " + ctrl + ")");
results = _appContext.search(context, filter, ctrl);
}
}
catch (CommunicationException ex)
{
try
{
connect(_env);
results = _appContext.search(context, filter, ctrl);
}
catch( NamingException e )
{
throw new LdapEnterpriseDirectoryException( e ) ;
}
}
catch( NamingException ex )
{
throw new LdapEnterpriseDirectoryException( ex );
}
Vector v = new Vector( 20 );
if ( results != null )
{
System.out.println("enumerating over " + results.getClass());
while ( results.hasMoreElements() )
{
System.out.println(results.getClass() + ". hasMoreElements() = " + results.hasMoreElements());
SearchResult sResult = (SearchResult)results.nextElement();
System.out.println(results.getClass() + ". nextElement() returned a " + sResult.getClass() + " whose value = " + sResult);
v.add( new LdapEnterpriseDirectorySearchResult(sResult) );
}
}
======================================================================
- relates to
-
JDK-4406723 The hasMore and next methods should not have to be called in lockstep
-
- Resolved
-