You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Martin Lepage (JIRA)" <ji...@apache.org> on 2011/05/26 15:31:47 UTC
[jira] [Created] (AMQCPP-373) AMQ_CATCH_RETHROW upcasts the
re-thrown exception
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
Attachments: exception.patch
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
[jira] [Updated] (AMQCPP-373) AMQ_CATCH_RETHROW upcasts the
re-thrown exception
Posted by "Timothy Bish (Updated) (JIRA)" <ji...@apache.org>.
[ 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
[jira] [Updated] (AMQCPP-373) AMQ_CATCH_RETHROW upcasts the
re-thrown exception
Posted by "Martin Lepage (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AMQCPP-373?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martin Lepage updated AMQCPP-373:
---------------------------------
Patch Info: (was: [Patch Available])
> 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
> 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
[jira] [Resolved] (AMQCPP-373) AMQ_CATCH_RETHROW upcasts the
re-thrown exception
Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
[ 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
[jira] [Updated] (AMQCPP-373) AMQ_CATCH_RETHROW upcasts the
re-thrown exception
Posted by "Martin Lepage (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AMQCPP-373?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martin Lepage updated AMQCPP-373:
---------------------------------
Attachment: exception.patch
A patch that solves the issue
> 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
> 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