hammant 2002/10/22 16:18:24 Modified: altrmi/src/java/org/apache/excalibur/altrmi/client/impl AbstractAltrmiFactory.java altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream StreamInvocationHandler.java altrmi/src/java/org/apache/excalibur/altrmi/server/impl StreamServerConnection.java Log: Tests pass again. Revision Changes Path 1.12 +3 -5 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/AbstractAltrmiFactory.java Index: AbstractAltrmiFactory.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/AbstractAltrmiFactory.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- AbstractAltrmiFactory.java 20 Oct 2002 19:19:51 -0000 1.11 +++ AbstractAltrmiFactory.java 22 Oct 2002 23:18:24 -0000 1.12 @@ -93,14 +93,12 @@ */ public void setHostContext( AltrmiHostContext hostContext, boolean allowOptimize ) throws IOException { - if( m_hostContext == null ) { m_hostContext = (AbstractHostContext) hostContext; m_clientInvocationHandler = m_hostContext.getClientInvocationHandler(); } - ( (AbstractClientInvocationHandler) m_clientInvocationHandler ).initialize(); UID machineID = allowOptimize ? U_ID : null; @@ -119,8 +117,8 @@ { AbstractSameVmBindableHostContext sameVmBindableHostContext = (AbstractSameVmBindableHostContext) m_hostContext; - m_hostContext = sameVmBindableHostContext.makeSameVmHostContext(); - if (m_hostContext == null) + AltrmiHostContext hContext = sameVmBindableHostContext.makeSameVmHostContext(); + if (hContext == null) { // Registry not found, or a different instance to the one // the server placed its piped instance in. 1.7 +16 -5 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream/StreamInvocationHandler.java Index: StreamInvocationHandler.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream/StreamInvocationHandler.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- StreamInvocationHandler.java 23 May 2002 21:37:19 -0000 1.6 +++ StreamInvocationHandler.java 22 Oct 2002 23:18:24 -0000 1.7 @@ -160,10 +160,7 @@ } catch( IOException ioe ) { - if( ioe instanceof SocketException | ioe instanceof EOFException - | ioe instanceof InterruptedIOException - | ( ( ioe.getMessage() != null ) - && ioe.getMessage().equals( "Read end dead" ) ) ) + if(isSafeEnd(ioe)) { int retryConnectTries = 0; @@ -208,6 +205,20 @@ throw new AltrmiInvocationException( "Class definition missing on Deserialization: " + e.getMessage() ); } + } + + private boolean isSafeEnd(IOException ioe) { + if (ioe instanceof SocketException | ioe instanceof EOFException + | ioe instanceof InterruptedIOException) { + return true; + } + if (ioe.getMessage() != null) { + String msg = ioe.getMessage(); + if (msg.equals("Read end dead") | msg.equals("Pipe closed")) { + return true; + } + } + return false; } /** 1.7 +44 -26 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/StreamServerConnection.java Index: StreamServerConnection.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/StreamServerConnection.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- StreamServerConnection.java 21 Sep 2002 15:52:56 -0000 1.6 +++ StreamServerConnection.java 22 Oct 2002 23:18:24 -0000 1.7 @@ -11,6 +11,7 @@ import java.io.IOException; import java.io.InterruptedIOException; import java.net.SocketException; + import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.excalibur.altrmi.common.AltrmiReply; import org.apache.excalibur.altrmi.common.AltrmiRequest; @@ -25,7 +26,7 @@ * @version $Revision$ */ public abstract class StreamServerConnection extends AbstractLogEnabled - implements Runnable, AltrmiServerConnection + implements Runnable, AltrmiServerConnection { /** @@ -51,8 +52,8 @@ * @param readWriter The Read Writer. * */ - public StreamServerConnection( AbstractServer abstractServer, - ServerStreamReadWriter readWriter ) + public StreamServerConnection(AbstractServer abstractServer, + ServerStreamReadWriter readWriter) { m_abstractServer = abstractServer; m_readWriter = readWriter; @@ -66,7 +67,7 @@ public void run() { - m_abstractServer.connectionStart( this ); + m_abstractServer.connectionStart(this); try { @@ -76,62 +77,79 @@ AltrmiRequest request = null; AltrmiReply reply = null; - while( more ) + while (more) { try { - if( request != null ) + if (request != null) { - reply = m_abstractServer.handleInvocation( request ); + reply = m_abstractServer.handleInvocation(request); } - request = m_readWriter.writeReplyAndGetRequest( reply ); + request = m_readWriter.writeReplyAndGetRequest(reply); // http://developer.java.sun.com/developer/bugParade/bugs/4499841.html // halves the performance though. //oOS.reset(); - if( m_endConnection ) + if (m_endConnection) { reply = new EndConnectionReply(); more = false; } } - catch( IOException ioe ) + catch (IOException ioe) { more = false; - if( ioe instanceof EOFException ) + if (ioe instanceof EOFException) { - getLogger().info( "One Connection closed. (EOF)" ); + getLogger().info("One Connection closed. (EOF)"); } - else if( ( ioe instanceof SocketException ) - || ioe.getClass().getName().equals( "java.net.SocketTimeoutException" ) - || ( ioe instanceof InterruptedIOException ) - || ( ( ioe.getMessage() != null ) - && ( ioe.getMessage().equals( "Write end dead" ) - || ioe.getMessage().equals( "Pipe broken" ) ) ) ) + else if (isSafeEnd(ioe)) { // TODO implement implementation indepandant logger - getLogger().info( "One Connection closed." ); + getLogger().info("One Connection closed."); } else { - getLogger().error( "Unexpected IOE in StreamServerConnection #1", ioe ); + getLogger().error("Unexpected IOE in StreamServerConnection #1", ioe); } } } } - catch( IOException e ) + catch (IOException e) { - getLogger().error( "Unexpected IOE in StreamServerConnection #2", e ); + getLogger().error("Unexpected IOE in StreamServerConnection #2", e); } - catch( ClassNotFoundException e ) + catch (ClassNotFoundException e) { - getLogger().error( "Unexpected ClassNotFoundException in StreamServerConnection", e ); + getLogger().error("Unexpected ClassNotFoundException in StreamServerConnection", e); } - m_abstractServer.connectionCompleted( this ); + m_abstractServer.connectionCompleted(this); + } + + private boolean isSafeEnd(IOException ioe) + { + if ((ioe instanceof SocketException) + || ioe.getClass().getName().equals("java.net.SocketTimeoutException") // 1.3 safe + || (ioe instanceof InterruptedIOException)) + { + return true; + } + + if (ioe.getMessage() != null) + { + String msg = ioe.getMessage(); + if (msg.equals("Write end dead") + | msg.equals("Pipe broken") + | msg.equals("Pipe closed")) + { + return true; + } + } + return false; } /**
-- To unsubscribe, e-mail: <mailto:avalon-cvs-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:avalon-cvs-help@;jakarta.apache.org>