- final DistributedDataStore dataStore =
- setupDistributedDataStore("transactionIntegrationTest", "test-1");
- dataStore.registerCommitCohort(TEST_ID, failedCohort);
- Thread.sleep(1000); // Registration is asynchronous
-
- DOMStoreWriteTransaction writeTx = dataStore.newWriteOnlyTransaction();
- writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
- DOMStoreThreePhaseCommitCohort dsCohort = writeTx.ready();
- try {
- // FIXME: Weird thing is that invoking canCommit on front-end invokes also
- // preCommit on backend.
- dsCohort.canCommit().get();
- fail("Exception should be raised.");
- } catch (Exception e) {
- assertSame(FAILED_CAN_COMMIT, Throwables.getRootCause(e));
+ try (final DistributedDataStore dataStore =
+ setupDistributedDataStore("transactionIntegrationTest", "test-1")) {
+ dataStore.registerCommitCohort(TEST_ID, failedCohort);
+ Thread.sleep(1000); // Registration is asynchronous
+
+ DOMStoreWriteTransaction writeTx = dataStore.newWriteOnlyTransaction();
+ writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+ DOMStoreThreePhaseCommitCohort dsCohort = writeTx.ready();
+ try {
+ // FIXME: Weird thing is that invoking canCommit on front-end invokes also
+ // preCommit on backend.
+ dsCohort.canCommit().get();
+ fail("Exception should be raised.");
+ } catch (Exception e) {
+ assertSame(FAILED_CAN_COMMIT, Throwables.getRootCause(e));
+ }