summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2012-07-30 21:18:07 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2012-07-30 21:18:07 +0000
commiteed0c3d16613998b02d324abe2abfb713113c261 (patch)
treef949eb4e817911d14306fe9b3db7c55a424a6e53
parentad7a94acd0bb798c0a6d9e51de09c07e4fa815bf (diff)
downloadqpid-python-eed0c3d16613998b02d324abe2abfb713113c261.tar.gz
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. git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/0.18@1367307 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java14
-rw-r--r--qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java26
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/AMQException.java20
3 files changed, 48 insertions, 12 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
index d70a54ccd4..1468e90c4e 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
@@ -801,11 +801,8 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P extends Basic
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 extends BasicMessageConsumer, P extends Basic
}
}
+ protected void stopDispatcherThread()
+ {
+ if (_dispatcherThread != null)
+ {
+ _dispatcherThread.interrupt();
+ }
+ }
/**
* Commits all messages done in this transaction and releases any locks currently held.
*
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
index 317c8902be..3deddbd918 100644
--- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
+++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_10.java
@@ -390,11 +390,7 @@ public class AMQSession_0_10 extends AMQSession<BasicMessageConsumer_0_10, Basic
*/
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 AMQSession<BasicMessageConsumer_0_10, Basic
{
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 AMQSession<BasicMessageConsumer_0_10, Basic
return _qpidSession.isFlowBlocked();
}
+ private void cancelTimerTask()
+ {
+ if (flushTask != null)
+ {
+ flushTask.cancel();
+ flushTask = null;
+ }
+ }
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java
index 86d439d269..2d54e35191 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java
@@ -40,6 +40,8 @@ public class AMQException extends Exception
/** 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 Exception
*/
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 Exception
public boolean isHardError()
{
- return true;
+ return _isHardError;
}
/**