[prev in list] [next in list] [prev in thread] [next in thread] 

List:       activemq-dev
Subject:    [jira] [Resolved] (AMQCPP-373) AMQ_CATCH_RETHROW upcasts the
From:       "Timothy Bish (JIRA)" <jira () apache ! org>
Date:       2011-05-26 14:01:47
Message-ID: 748310688.45357.1306418507939.JavaMail.tomcat () hel ! zones ! apache ! org
[Download RAW message or body]


     [ https://issues.apache.org/jira/browse/AMQCPP-373?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel \
]

Timothy Bish resolved AMQCPP-373.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 3.5.0

Fixed in trunk, thanks!

> AMQ_CATCH_RETHROW upcasts the re-thrown exception
> -------------------------------------------------
> 
> Key: AMQCPP-373
> URL: https://issues.apache.org/jira/browse/AMQCPP-373
> Project: ActiveMQ C++ Client
> Issue Type: Bug
> Components: CMS Impl, Decaf
> Affects Versions: 3.5.0
> Environment: Windows 7 (visual C++ 2005), Linux (gcc 4.1.2)
> Reporter: Martin Lepage
> Assignee: Timothy Bish
> Priority: Minor
> Labels: exception, exception_handling
> Fix For: 3.5.0
> 
> Attachments: exception.patch
> 
> Original Estimate: 0.25h
> Remaining Estimate: 0.25h
> 
> AMQ_CATCH_RETHROW and DECAF_CATCH_RETHROW as defined in \
> {{activemq/exceptions/ExceptionDefines.h}} and \
> {{decaf/lang/exceptions/ExceptionDefines.h}} upcast the exceptions when they \
> rethrow it, which results in loss of information (but not of data) along the way.  \
> Take for example the following c++ code fragment, which mimics the way \
> AMQ_CATCH_RETHROW is used throughout the code : {code:title=Exception \
> handling|borderStyle=solid} #include <iostream>
> #include <typeinfo>
> #include <activemq/exceptions/ExceptionDefines.h>
> #include <activemq/exceptions/BrokerException.h>
> int main()
> {
> try
> {
> try
> {
> try
> {
> throw activemq::exceptions::BrokerException(
> __FILE__, __LINE__, "Testing");
> }
> AMQ_CATCH_RETHROW(activemq::exceptions::BrokerException)
> }
> AMQ_CATCH_RETHROW(activemq::exceptions::ActiveMQException)
> }
> catch (decaf::lang::Throwable &e)
> {
> std::cout.flags(std::ios_base::boolalpha);
> std::cout << "Broker exception : " << (typeid(e).name() == 
> typeid(activemq::exceptions::BrokerException).name()) << "\n";
> std::cout << "ActiveMQException : " << (typeid(e).name() == 
> typeid(activemq::exceptions::ActiveMQException).name()) << "\n";
> 
> decaf::lang::Throwable *convertedException =
> dynamic_cast<activemq::exceptions::BrokerException *>(&e);
> std::cout << "Conversion failed : " << (convertedException == NULL)
> << "\n";
> }
> return 0;
> }
> {code} 
> which returns :
> {code:xml} 
> Broker exception : false
> ActiveMQException : true
> Conversion failed : true
> {code} 
> The solution is to replace '{{throw e;}}' by '{{throw;}}' in the definitions of \
> AMQ_CATCH_RETHROW and DECAF_CATCH_RETHROW.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic