Jruby-ldap search behavior

Greetings,

I’ve been using jruby-ldap for a long time with no problems. Recently I
noticed something peculiar and potentially damaging, please see below.

Very occasionally, our client will be disconnected from the LDAP server,
probably by unreliable network or other unfixable problem. When this
happens while iterating through results of search(), the client does not
learn about the disconnection (no exception is thrown). Instead,
search().each {…} terminates without any indication of problem. My
application unfortunately proceeds naively with an incomplete
result-set. I think the reason this happens is
jruby-ldap/lib/ldap/conn.rb line 185:

@context.search(base_dn, filter, controls).each do |val|
yield LDAP::Entry.create_from_search_result(val)
end

Where it treats the results as an Enumeration, rather than
NamingEnumeration[1]. The difference is NamingEnumeration can thrown
exceptions during the enumeration. I modified conn.rb:

results = @context.search(base_dn, filter, controls)
while results.has_more do
yield LDAP::Entry.create_from_search_result(results.next)
end

Which does throw an appropriately nasty exception if the connection is
severed mid-stream:

com/sun/jndi/ldap/Connection.java:419:in `readReply’:
javax.naming.ServiceUnavailableException: testing123.uchicago.edu:636;
socket closed (NativeException)

Thank you for your attention; please comment on my assessment if you
can. I know very little about JRuby internals, so my assumptions could
be all wrong.

http://download.oracle.com/javase/1,5.0/docs/api/javax/naming/NamingEnumeration.html

On 06/10/2011 10:18 AM, Colin Hudler wrote:

Greetings,

I’ve been using jruby-ldap for a long time with no problems. Recently
I noticed something peculiar and potentially damaging, please see below.

Absolute silence means perhaps I should move on. I have suspected that
jruby-ldap was abandoned. Ruby-net-ldap is workable.