directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r433693 - /directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/MessageDecoder.java
Date Tue, 22 Aug 2006 17:07:02 GMT
Author: elecharny
Date: Tue Aug 22 10:07:01 2006
New Revision: 433693

URL: http://svn.apache.org/viewvc?rev=433693&view=rev
Log:
A little bit ugly : we receive a decoderException, and we
must transform it to a MessageException, because those exception 
are not compatible

Modified:
    directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/MessageDecoder.java

Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/MessageDecoder.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/MessageDecoder.java?rev=433693&r1=433692&r2=433693&view=diff
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/MessageDecoder.java
(original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/message/MessageDecoder.java
Tue Aug 22 10:07:01 2006
@@ -28,6 +28,7 @@
 import org.apache.directory.shared.asn1.codec.stateful.DecoderCallback;
 import org.apache.directory.shared.asn1.codec.stateful.DecoderMonitor;
 import org.apache.directory.shared.asn1.codec.stateful.StatefulDecoder;
+import org.apache.directory.shared.ldap.codec.ResponseCarryingException;
 import org.apache.directory.shared.ldap.message.spi.Provider;
 import org.apache.directory.shared.ldap.message.spi.ProviderDecoder;
 import org.apache.directory.shared.ldap.message.spi.TransformerSpi;
@@ -167,21 +168,28 @@
     {
         Object providerEnvelope;
 
-        if ( lock == null )
-        {
-            // Complain here somehow first then do the following w/o synch!
-
-            // Call provider decoder to demarshall PDU into berlib specific form
-            providerEnvelope = decoder.decode( lock, in );
-        }
-        else
+        try
         {
-            synchronized ( lock )
+            if ( lock == null )
             {
-                // Same as above but a synchronized read using valid lock object
+                // Complain here somehow first then do the following w/o synch!
+    
+                // Call provider decoder to demarshall PDU into berlib specific form
                 providerEnvelope = decoder.decode( lock, in );
-                lock.notifyAll();
             }
+            else
+            {
+                synchronized ( lock )
+                {
+                    // Same as above but a synchronized read using valid lock object
+                    providerEnvelope = decoder.decode( lock, in );
+                    lock.notifyAll();
+                }
+            }
+        }
+        catch (Exception e) 
+        {
+            throw (MessageException)e;
         }
 
         // Call on transformer to convert stub based PDU into Message based PDU
@@ -207,7 +215,18 @@
         }
         catch ( DecoderException e )
         {
-            throw new MessageException( "decoder failture: " + e.getMessage() );
+            // transform the DecoderException message to a MessageException
+            if ( e instanceof ResponseCarryingException ) 
+            {
+                ResponseCarryingMessageException rcme = new ResponseCarryingMessageException(
e.getMessage() );
+                rcme.setResponse( ((ResponseCarryingException)e).getResponse() );
+                
+                throw rcme;
+            }
+            else
+            {
+                throw new MessageException( "decoder failture: " + e.getMessage() );
+            }
         }
     }
 



Mime
View raw message