[ https://issues.apache.org/jira/browse/GEODE-8830?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17264695#comment-17264695 ]
ASF GitHub Bot commented on GEODE-8830: --------------------------------------- gaussianrecurrence opened a new pull request #720: URL: https://github.com/apache/geode-native/pull/720 - Exceptions were not correctly handled during transaction operations, leading to the derived type of the exception to be lost on the internal source calls. - Problem was that in the process of capturing an re-throwing the exceptions, a copy of its more generic type, `Exception` was created and passed throught, instead of the original exception. This has been sorted out. - Also, several integration test were added, in order to ensure that the correct type of exceptions are thrown when an error occurs while executing transsactions operations. --- It seems C++ have some particular syntax when it comes to rethrowing exceptions, as can be seen here: https://stackoverflow.com/a/2360673/14434972 Hence, the problem was that a copy of type **Exception** was being thrown, instead of the original exception. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Exceptions not correctly re-thrown in the tx manager > ---------------------------------------------------- > > Key: GEODE-8830 > URL: https://issues.apache.org/jira/browse/GEODE-8830 > Project: Geode > Issue Type: Bug > Components: native client > Affects Versions: 1.12.0, 1.13.0, 1.13.1 > Reporter: Mario Salazar de Torres > Priority: Major > > Under several transactional scenarios exceptions are converted from its more > specific type to *Exception* type within the internal code of the native > client. The scenarios are the following ones: > # Whenever a transaction commit conflicts the native client user would > expect a *CommitConflictException*, but instead the user can only catch an > exception of type *Exception*. > # Whenever a transaction prepare conflicts the native client user would > expect a *CommitConflictException*, but instead the user can only catch an > exception of type *Exception*. > # Whenever rollback/prepare/commit is executed with no transaction ongoing > the native client user would expect an *IllegalStateException*, but instead > the user can only catch an exception of type *Exception*. > ---- > *Example:* > {code:c++} > auto tx_manager = cache.getCacheTransactionManager(); > // First transaction starts here > tx_manager->begin(); > region->put("key", "A"); > // First transaction is suspended before doing the commit > auto& tx_id = txm->suspend(); > // Second transaction starts here > tx_manager->begin(); > region->put("key", "B"); > tx_manager->commit(); > // After successfully committing the second transaction, the first > transaction is resumed > tx_manager->resume(tx_id); > try { > tx_manager->commit(); > } > catch(CommitConflictException& ex) { > // This is what should be in the output in this example > std::cerr << "A conflict occurred while committing the transaction!" << > std::endl; > } > catch(Exception& ex) { > // However, as there is some issue with exception handling, this is what's > currently shown > std::cerr << "An unknown exception occurred while committing the > transaction!" << std::endl; > }{code} > -- This message was sent by Atlassian Jira (v8.3.4#803005)