You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2012/10/12 23:25:58 UTC
svn commit: r1397727 - in
/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq:
commands/BrokerError.cpp commands/BrokerError.h
transport/correlator/ResponseCorrelator.cpp
Author: tabish
Date: Fri Oct 12 21:25:58 2012
New Revision: 1397727
URL: http://svn.apache.org/viewvc?rev=1397727&view=rev
Log:
work for: https://issues.apache.org/jira/browse/AMQCPP-435
Add a way for BrokerError to wrap a local exception so that async sends can set any exception type either from local errors or from the broker.
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/BrokerError.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/BrokerError.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/correlator/ResponseCorrelator.cpp
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/BrokerError.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/BrokerError.cpp?rev=1397727&r1=1397726&r2=1397727&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/BrokerError.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/BrokerError.cpp Fri Oct 12 21:25:58 2012
@@ -45,7 +45,12 @@ using namespace decaf::lang;
using namespace decaf::lang::exceptions;
////////////////////////////////////////////////////////////////////////////////
-BrokerError::BrokerError() : BaseCommand(), message(), exceptionClass(), stackTraceElements(), cause() {
+BrokerError::BrokerError() : BaseCommand(), message(), exceptionClass(), stackTraceElements(), cause(), exCause() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+BrokerError::BrokerError(decaf::lang::Pointer<decaf::lang::Exception> exCause) :
+ BaseCommand(), message(), exceptionClass(), stackTraceElements(), cause(), exCause(exCause) {
}
////////////////////////////////////////////////////////////////////////////////
@@ -66,6 +71,7 @@ void BrokerError::copyDataStructure(cons
this->setExceptionClass(srcErr->getExceptionClass());
this->setStackTraceElements(srcErr->getStackTraceElements());
this->setCause(srcErr->getCause());
+ this->setLocalException(srcErr->getLocalException());
}
////////////////////////////////////////////////////////////////////////////////
@@ -77,6 +83,8 @@ Pointer<commands::Command> BrokerError::
decaf::lang::Exception BrokerError::createExceptionObject() {
StringTokenizer tokenizer(this->exceptionClass);
+
+
std::string exceptionClass = this->exceptionClass;
while (tokenizer.hasMoreTokens()) {
@@ -114,7 +122,11 @@ decaf::lang::Exception BrokerError::crea
} else if (exceptionClass == "UnsupportedOperationException") {
cause = new cms::UnsupportedOperationException(this->message);
} else {
- cause = new cms::CMSException(this->message);
+ if (exCause != NULL) {
+ cause = new cms::CMSException(this->message);
+ } else {
+ cause = new cms::CMSException(this->exCause->getMessage());
+ }
}
// Wrap in a Decaf exception to carry the pointer until it can be
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/BrokerError.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/BrokerError.h?rev=1397727&r1=1397726&r2=1397727&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/BrokerError.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/BrokerError.h Fri Oct 12 21:25:58 2012
@@ -53,11 +53,14 @@ namespace commands {
std::string exceptionClass;
std::vector< decaf::lang::Pointer<StackTraceElement> > stackTraceElements;
decaf::lang::Pointer<BrokerError> cause;
+ decaf::lang::Pointer<decaf::lang::Exception> exCause;
public:
BrokerError();
+ BrokerError(decaf::lang::Pointer<decaf::lang::Exception> exCause);
+
virtual ~BrokerError();
/**
@@ -160,6 +163,23 @@ namespace commands {
}
/**
+ * @returns the local Exception that was the source of this BrokerError instance
+ */
+ decaf::lang::Pointer<decaf::lang::Exception> getLocalException() const {
+ return this->exCause;
+ }
+
+ /**
+ * Sets the Pointer to the local exception that is the source of this Error
+ *
+ * @param exCause
+ * The Exception that originated this BrokerError.
+ */
+ void setLocalException(decaf::lang::Pointer<decaf::lang::Exception> exCause) {
+ this->exCause = exCause;
+ }
+
+ /**
* Creates and returns a Decaf Exception object that contains the error data from the Broker.
*
* The returned exception will if possible contain a cms::CMSException pointer that represents
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/correlator/ResponseCorrelator.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/correlator/ResponseCorrelator.cpp?rev=1397727&r1=1397726&r2=1397727&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/correlator/ResponseCorrelator.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/correlator/ResponseCorrelator.cpp Fri Oct 12 21:25:58 2012
@@ -139,8 +139,6 @@ void ResponseCorrelator::oneway(const Po
////////////////////////////////////////////////////////////////////////////////
Pointer<FutureResponse> ResponseCorrelator::asyncRequest(const Pointer<Command> command, const Pointer<ResponseCallback> responseCallback) {
- throw UnsupportedOperationException(__FILE__, __LINE__, "Not yet ready for use.");
-
try {
command->setCommandId(this->impl->nextCommandId.getAndIncrement());
@@ -159,7 +157,13 @@ Pointer<FutureResponse> ResponseCorrelat
}
if (priorError != NULL) {
- //futureResponse->setResponse(new ExceptionResponse(priorError));
+
+ Pointer<commands::BrokerError> exception(new commands::BrokerError(priorError));
+ Pointer<commands::ExceptionResponse> response(new commands::ExceptionResponse);
+ response->setException(exception);
+
+ futureResponse->setResponse(response);
+
throw IOException(__FILE__, __LINE__, this->impl->priorError->getMessage().c_str());
}