activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Timothy Bish (Updated) (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (AMQCPP-373) AMQ_CATCH_RETHROW upcasts the re-thrown exception
Date Mon, 07 Nov 2011 21:58:51 GMT

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

Timothy Bish updated AMQCPP-373:
--------------------------------

    Fix Version/s: 3.4.1
    
> 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.4.1, 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.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message