directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r165592 - /directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java /directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java
Date Mon, 02 May 2005 07:02:24 GMT
Author: trustin
Date: Mon May  2 00:02:23 2005
New Revision: 165592

URL: http://svn.apache.org/viewcvs?rev=165592&view=rev
Log:
Simplified exception handling of SSLFilter

Modified:
    directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java
    directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java

Modified: directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java?rev=165592&r1=165591&r2=165592&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/filter/SSLFilter.java Mon May  2 00:02:23
2005
@@ -184,7 +184,7 @@
 
     // IoFilter impl.
 
-    public void sessionOpened( NextFilter nextFilter, IoSession session )
+    public void sessionOpened( NextFilter nextFilter, IoSession session ) throws SSLException
     {
         // Create an SSL handler
         createSSLSessionHandler( session );
@@ -284,7 +284,7 @@
         nextFilter.dataWritten( session, marker );
     }
 
-    public void filterWrite( NextFilter nextFilter, IoSession session, ByteBuffer buf, Object
marker )
+    public void filterWrite( NextFilter nextFilter, IoSession session, ByteBuffer buf, Object
marker ) throws SSLException
     {
 
         SSLHandler handler = createSSLSessionHandler( session );
@@ -309,29 +309,21 @@
             if( handler.isInitialHandshakeComplete() )
             {
                 // SSL encrypt
-                try
+                if( log.isLoggable( Level.FINEST ) )
                 {
-                    if( log.isLoggable( Level.FINEST ) )
-                    {
-                        log.log( Level.FINEST, session + " encrypt: " + buf );
-                    }
-                    handler.encrypt( buf.buf() );
-                    ByteBuffer encryptedBuffer = copy( handler
-                            .getOutNetBuffer() );
-
-                    if( log.isLoggable( Level.FINEST ) )
-                    {
-                        log.log( Level.FINEST, session + " encrypted buf: " + encryptedBuffer);
-                    }
-                    buf.release();
-                    nextFilter.filterWrite( session, encryptedBuffer, marker );
-                    return;
+                    log.log( Level.FINEST, session + " encrypt: " + buf );
                 }
-                catch( SSLException ssle )
+                handler.encrypt( buf.buf() );
+                ByteBuffer encryptedBuffer = copy( handler
+                        .getOutNetBuffer() );
+
+                if( log.isLoggable( Level.FINEST ) )
                 {
-                    throw new RuntimeException(
-                            "Unexpected SSLException.", ssle );
+                    log.log( Level.FINEST, session + " encrypted buf: " + encryptedBuffer);
                 }
+                buf.release();
+                nextFilter.filterWrite( session, encryptedBuffer, marker );
+                return;
             }
             else
             {
@@ -478,7 +470,7 @@
 
     // Utilities to mainpulate SSLHandler based on IoSession
 
-    private SSLHandler createSSLSessionHandler( IoSession session )
+    private SSLHandler createSSLSessionHandler( IoSession session ) throws SSLException
     {
         SSLHandler handler = ( SSLHandler ) sslSessionHandlerMap.get( session );
         if( handler == null )
@@ -488,18 +480,21 @@
                 handler = ( SSLHandler ) sslSessionHandlerMap.get( session );
                 if( handler == null )
                 {
+                    boolean done = false;
                     try
                     {
                         handler =
                             new SSLHandler( this, sslContext, session );
                         sslSessionHandlerMap.put( session, handler );
                         handler.doHandshake();
+                        done = true;
                     }
-                    catch( SSLException e )
+                    finally 
                     {
-                        sslSessionHandlerMap.remove( session );
-                        throw new RuntimeException(
-                                "Failed to initialize SSLEngine.", e );
+                        if( !done )
+                        {
+                            sslSessionHandlerMap.remove( session );
+                        }
                     }
                 }
             }

Modified: directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java?rev=165592&r1=165591&r2=165592&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java Mon May  2
00:02:23 2005
@@ -187,7 +187,7 @@
         writeMarkerQueue.push( marker );
     }
     
-    public synchronized void flushScheduledWrites()
+    public synchronized void flushScheduledWrites() throws SSLException
     {
         NextFilter nextFilter;
         org.apache.mina.common.ByteBuffer scheduledBuf;



Mime
View raw message