[ https://issues.apache.org/jira/browse/GEODE-8830?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17271390#comment-17271390 ]
ASF subversion and git services commented on GEODE-8830: -------------------------------------------------------- Commit ec5e33f886d4308c84266bcfe406e416da108fb8 in geode-native's branch refs/heads/develop from Mario Salazar de Torres [ https://gitbox.apache.org/repos/asf?p=geode-native.git;h=ec5e33f ] GEODE-8830: Fix exception handling in transactions (#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. > 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 > Assignee: Mario Salazar de Torres > Priority: Major > Labels: pull-request-available > > 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)