[ http://issues.apache.org/jira/browse/DIRSERVER-212?page=all ]
     
Emmanuel Lecharny closed DIRSERVER-212:
---------------------------------------


Strange bug I created :) Let's close it

> Class SnickersEncoder does not send data with a WritableByteChannel on Linux
> ----------------------------------------------------------------------------
>
>          Key: DIRSERVER-212
>          URL: http://issues.apache.org/jira/browse/DIRSERVER-212
>      Project: Directory ApacheDS
>         Type: Bug

>   Components: ldap
>     Versions: pre-1.0
>  Environment: Linux Fedora Core 3
>     Reporter: Emmanuel Lecharny
>     Assignee: Alex Karasulu
>     Priority: Blocker
>      Fix For: pre-1.0

>
> Tracking the problem described in DIRLDAP-28 jira issue, I finally discovered 
> that data are not sent through the socket using a WritableByteChannel. I 
> replaced it by an OutputStream in the OutputCallback inner class, added a 
> flush() in the encodeOccurred method, and everything went well, ethereal was 
> quite happy to show a LDAP packet with the full (correct) BindRequest.
> My OutputCallback innerclass :
>    class OutputCallback implements EncoderCallback {
>         // private WritableByteChannel m_channel = null; // Does not send 
> data, don't know why?
>         private OutputStream m_out; // back to old API
>         /**
>          * Callback to deliver a fully encoded object.
>          * 
>          * @param encoder
>          *            the stateful encoder driving the callback
>          * @param encoded
>          *            the object that was encoded
>          */
>        public void encodeOccurred(StatefulEncoder encoder, Object encoded) {
>             try {
>                 ByteBuffer[] buffers = (ByteBuffer[])encoded;
>                 
>                 for (int i=0; i<buffers.length; i++) {
>                     m_out.write(buffers[i].array());
>                 }
>                 
>                 m_out.flush(); // don't forget to flush !!!
>             } catch (IOException e) {
>                 e.printStackTrace();
>             }
>         }
>         void attach(WritableByteChannel channel) {
>             m_channel = channel;
>         }
>         void attach(OutputStream out) {
>             m_out = out;
>             // m_channel = Channels.newChannel(out);
>         }
> I also tried to close the channel instead of using an OutputStream (just by 
> replacing flush by a close), but that is not an option : you can't anymore 
> read the response...
> I may have missed something about channels? Or is this a bug? I'm not very 
> experienced with NIO (the hendrix way of being experienced...), but I'll 
> tried to improve my knowledge by browsing Sun code, just to check. Didn't had 
> time to test it unde M$, but I gonna switch on my close source machine in a 
> couple of hours.
> Whatever, I still can't get a correct answer :
> [main] DEBUG BERDigester  - Rule [EMAIL PROTECTED] fired successfully by 
> digester [EMAIL PROTECTED]
> 29 [main] DEBUG BERDigester  - Rule [EMAIL PROTECTED] fired successfully by 
> digester [EMAIL PROTECTED]
> 29 [main] DEBUG BERDigester  - Rule [EMAIL PROTECTED] fired successfully by 
> digester [EMAIL PROTECTED]
> 29 [main] DEBUG BERDigester  - Rule [EMAIL PROTECTED] fired successfully by 
> digester [EMAIL PROTECTED]
> 29 [main] DEBUG BERDigester  - Rule [EMAIL PROTECTED] fired successfully by 
> digester [EMAIL PROTECTED]
> 31 [main] ERROR BERDigester  - Error while triggering rule [EMAIL PROTECTED] 
> with digester [EMAIL PROTECTED]: Rule.finish() threw exception
> java.util.EmptyStackException
>       at org.apache.commons.collections.ArrayStack.peek(ArrayStack.java:89)
>       at org.apache.asn1.ber.digester.BERDigester.peek(BERDigester.java:279)
>       at 
> org.apache.ldap.common.berlib.asn1.decoder.bind.BindResponseRule.finish(BindResponseRule.java:58)
>       at 
> org.apache.asn1.ber.digester.BERDigester.fireFinishEvent(BERDigester.java:1132)
>       at 
> org.apache.asn1.ber.digester.BERDigester$DigesterCallback.decodeOccurred(BERDigester.java:196)
>       at 
> org.apache.asn1.ber.BERDecoder.fireDecodeOccurred(BERDecoder.java:401)
>       at org.apache.asn1.ber.BERDecoder.updateStack(BERDecoder.java:462)
>       at org.apache.asn1.ber.BERDecoder.decodeOccurred(BERDecoder.java:301)
>       at 
> org.apache.asn1.codec.stateful.AbstractStatefulDecoder.decodeOccurred(AbstractStatefulDecoder.java:130)
>       at org.apache.asn1.ber.LengthDecoder.decode(LengthDecoder.java:58)
>       at org.apache.asn1.ber.BERDecoder.decode(BERDecoder.java:158)
>       at org.apache.asn1.ber.digester.BERDigester.decode(BERDigester.java:141)
>       at 
> org.apache.ldap.common.berlib.asn1.SnickersDecoder.digest(SnickersDecoder.java:187)
>       at 
> org.apache.ldap.common.berlib.asn1.SnickersDecoder.decode(SnickersDecoder.java:135)
>       at 
> org.apache.ldap.common.message.MessageDecoder.decode(MessageDecoder.java:107)
>       at org.apache.ldap.clients.LdapBind.bind(LdapBind.java:354)
>       at org.apache.ldap.clients.LdapSearch.main(LdapSearch.java:408)
> java.util.EmptyStackException
>       at org.apache.commons.collections.ArrayStack.peek(ArrayStack.java:89)
>       at org.apache.asn1.ber.digester.BERDigester.peek(BERDigester.java:279)
>       at 
> org.apache.ldap.common.berlib.asn1.decoder.bind.BindResponseRule.finish(BindResponseRule.java:58)
>       at 
> org.apache.asn1.ber.digester.BERDigester.fireFinishEvent(BERDigester.java:1132)
>       at 
> org.apache.asn1.ber.digester.BERDigester$DigesterCallback.decodeOccurred(BERDigester.java:196)
>       at 
> org.apache.asn1.ber.BERDecoder.fireDecodeOccurred(BERDecoder.java:401)
>       at org.apache.asn1.ber.BERDecoder.updateStack(BERDecoder.java:462)
>       at org.apache.asn1.ber.BERDecoder.decodeOccurred(BERDecoder.java:301)
>       at 
> org.apache.asn1.codec.stateful.AbstractStatefulDecoder.decodeOccurred(AbstractStatefulDecoder.java:130)
>       at org.apache.asn1.ber.LengthDecoder.decode(LengthDecoder.java:58)
>       at org.apache.asn1.ber.BERDecoder.decode(BERDecoder.java:158)
>       at org.apache.asn1.ber.digester.BERDigester.decode(BERDigester.java:141)
>       at 
> org.apache.ldap.common.berlib.asn1.SnickersDecoder.digest(SnickersDecoder.java:187)
>       at 
> org.apache.ldap.common.berlib.asn1.SnickersDecoder.decode(SnickersDecoder.java:135)
>       at 
> org.apache.ldap.common.message.MessageDecoder.decode(MessageDecoder.java:107)
>       at org.apache.ldap.clients.LdapBind.bind(LdapBind.java:354)
>       at org.apache.ldap.clients.LdapSearch.main(LdapSearch.java:408)
> 34 [main] FATAL org.apache.ldap.clients.LdapBind  - Failed to bind to server 
> due to message composition failure
> org.apache.ldap.common.message.spi.ProviderException: Snickers decoder 
> failure!
>       at 
> org.apache.ldap.common.berlib.asn1.SnickersDecoder.digest(SnickersDecoder.java:193)
>       at 
> org.apache.ldap.common.berlib.asn1.SnickersDecoder.decode(SnickersDecoder.java:135)
>       at 
> org.apache.ldap.common.message.MessageDecoder.decode(MessageDecoder.java:107)
>       at org.apache.ldap.clients.LdapBind.bind(LdapBind.java:354)
>       at org.apache.ldap.clients.LdapSearch.main(LdapSearch.java:408)
> Nested exceptions to follow:
>       <<========= Last Nested Exception ========>>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to