Author: rajith Date: Mon Jul 30 21:18:07 2012 New Revision: 1367307 URL: http://svn.apache.org/viewvc?rev=1367307&view=rev Log: Porting to 0.18 branch. QPID-3575 SessionExceptions (0-10 code path) are now marked as soft errors. When a Session receives an exception it is closed and the exception is notified via the ConnectionListener as well. However the exception is marked as a soft-error, therefore the connection will not be closed.
Modified: qpid/branches/0.18/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java qpid/branches/0.18/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java qpid/branches/0.18/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java Modified: qpid/branches/0.18/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java URL: http://svn.apache.org/viewvc/qpid/branches/0.18/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java?rev=1367307&r1=1367306&r2=1367307&view=diff ============================================================================== --- qpid/branches/0.18/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java (original) +++ qpid/branches/0.18/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java Mon Jul 30 21:18:07 2012 @@ -801,11 +801,8 @@ public abstract class AMQSession<C exten if (e instanceof AMQDisconnectedException) { - if (_dispatcherThread != null) - { - // Failover failed and ain't coming back. Knife the dispatcher. - _dispatcherThread.interrupt(); - } + // Failover failed and ain't coming back. Knife the dispatcher. + stopDispatcherThread(); } @@ -834,6 +831,13 @@ public abstract class AMQSession<C exten } } + protected void stopDispatcherThread() + { + if (_dispatcherThread != null) + { + _dispatcherThread.interrupt(); + } + } /** * Commits all messages done in this transaction and releases any locks currently held. * Modified: qpid/branches/0.18/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java URL: http://svn.apache.org/viewvc/qpid/branches/0.18/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java?rev=1367307&r1=1367306&r2=1367307&view=diff ============================================================================== --- qpid/branches/0.18/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java (original) +++ qpid/branches/0.18/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java Mon Jul 30 21:18:07 2012 @@ -390,11 +390,7 @@ public class AMQSession_0_10 extends AMQ */ public void sendClose(long timeout) throws AMQException, FailoverException { - if (flushTask != null) - { - flushTask.cancel(); - flushTask = null; - } + cancelTimerTask(); flushAcknowledgments(); try { @@ -1051,9 +1047,19 @@ public class AMQSession_0_10 extends AMQ { code = ee.getErrorCode().getValue(); } - AMQException amqe = new AMQException(AMQConstant.getConstant(code), se.getMessage(), se.getCause()); + AMQException amqe = new AMQException(AMQConstant.getConstant(code), false, se.getMessage(), se.getCause()); _currentException = amqe; } + cancelTimerTask(); + stopDispatcherThread(); + try + { + closed(_currentException); + } + catch(Exception e) + { + _logger.warn("Error closing session", e); + } getAMQConnection().exceptionReceived(_currentException); } @@ -1414,5 +1420,13 @@ public class AMQSession_0_10 extends AMQ return _qpidSession.isFlowBlocked(); } + private void cancelTimerTask() + { + if (flushTask != null) + { + flushTask.cancel(); + flushTask = null; + } + } } Modified: qpid/branches/0.18/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java URL: http://svn.apache.org/viewvc/qpid/branches/0.18/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java?rev=1367307&r1=1367306&r2=1367307&view=diff ============================================================================== --- qpid/branches/0.18/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java (original) +++ qpid/branches/0.18/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java Mon Jul 30 21:18:07 2012 @@ -40,6 +40,8 @@ public class AMQException extends Except /** Holds the AMQ error code constant associated with this exception. */ private AMQConstant _errorCode; + private boolean _isHardError; + /** * Creates an exception with an optional error code, optional message and optional underlying cause. * @@ -49,8 +51,24 @@ public class AMQException extends Except */ public AMQException(AMQConstant errorCode, String msg, Throwable cause) { + // isHardError is defaulted to true to avoid unnessacery modification to + // existing code. + this(errorCode,true,msg,cause); + } + + /** + * Creates an exception with an optional error code, optional message and optional underlying cause. + * + * @param errorCode The error code. May be null if not to be set. + * @param isHardError Denotes if the underlying error is considered a hard error. + * @param msg The exception message. May be null if not to be set. + * @param cause The underlying cause of the exception. May be null if not to be set. + */ + public AMQException(AMQConstant errorCode, boolean isHardError, String msg, Throwable cause) + { super(((msg == null) ? "" : msg), cause); _errorCode = errorCode; + _isHardError = isHardError; } /* @@ -92,7 +110,7 @@ public class AMQException extends Except public boolean isHardError() { - return true; + return _isHardError; } /** --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org