Mario Salazar de Torres created GEODE-8830:
----------------------------------------------

             Summary: 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.13.1, 1.13.0, 1.12.0
            Reporter: Mario Salazar de Torres


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)

Reply via email to