[java-opensaml] branch master updated: OSJ-269 rollback commit failures
Daniel Fisher
dfisher at vt.edu
Thu Mar 14 23:34:45 EDT 2019
This is an automated email from the git hooks/post-receive script.
dfisher pushed a commit to branch master
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=ec5f3861cc23d933b125f962266a99dc58c04714
The following commit(s) were added to refs/heads/master by this push:
new ec5f386 OSJ-269 rollback commit failures
ec5f386 is described below
commit ec5f3861cc23d933b125f962266a99dc58c04714
Author: Daniel Fisher <dfisher at vt.edu>
AuthorDate: Thu Mar 14 23:23:31 2019 -0400
OSJ-269 rollback commit failures
Add transaction rollbacks for commits in finally blocks.
Add some smoke tests for case sensitive keys and contexts.
---
.../opensaml/storage/impl/JPAStorageService.java | 56 ++++++++++++++++
.../storage/impl/JPAStorageServiceTest.java | 78 ++++++++++++++++++++++
2 files changed, 134 insertions(+)
diff --git a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/JPAStorageService.java b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/JPAStorageService.java
index 2899d2c..b0b68e1 100644
--- a/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/JPAStorageService.java
+++ b/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/JPAStorageService.java
@@ -187,6 +187,13 @@ public class JPAStorageService extends AbstractStorageService implements Storage
transaction.commit();
} catch (final Exception e) {
log.error("Error committing transaction", e);
+ if (transaction.isActive()) {
+ try {
+ transaction.rollback();
+ } catch (final Exception ex) {
+ log.error("Error rolling back transaction", e);
+ }
+ }
}
}
}
@@ -347,6 +354,13 @@ public class JPAStorageService extends AbstractStorageService implements Storage
transaction.commit();
} catch (final Exception e) {
log.error("Error committing transaction", e);
+ if (transaction.isActive()) {
+ try {
+ transaction.rollback();
+ } catch (final Exception ex) {
+ log.error("Error rolling back transaction", e);
+ }
+ }
}
}
if (manager != null && manager.isOpen()) {
@@ -467,6 +481,13 @@ public class JPAStorageService extends AbstractStorageService implements Storage
transaction.commit();
} catch (final Exception e) {
log.error("Error committing transaction", e);
+ if (transaction.isActive()) {
+ try {
+ transaction.rollback();
+ } catch (final Exception ex) {
+ log.error("Error rolling back transaction", e);
+ }
+ }
}
}
}
@@ -561,6 +582,13 @@ public class JPAStorageService extends AbstractStorageService implements Storage
transaction.commit();
} catch (final Exception e) {
log.error("Error committing transaction", e);
+ if (transaction.isActive()) {
+ try {
+ transaction.rollback();
+ } catch (final Exception ex) {
+ log.error("Error rolling back transaction", e);
+ }
+ }
}
}
}
@@ -621,6 +649,13 @@ public class JPAStorageService extends AbstractStorageService implements Storage
transaction.commit();
} catch (final Exception e) {
log.error("Error committing transaction", e);
+ if (transaction.isActive()) {
+ try {
+ transaction.rollback();
+ } catch (final Exception ex) {
+ log.error("Error rolling back transaction", e);
+ }
+ }
}
}
}
@@ -705,6 +740,13 @@ public class JPAStorageService extends AbstractStorageService implements Storage
transaction.commit();
} catch (final Exception e) {
log.error("Error committing transaction", e);
+ if (transaction.isActive()) {
+ try {
+ transaction.rollback();
+ } catch (final Exception ex) {
+ log.error("Error rolling back transaction", e);
+ }
+ }
}
}
}
@@ -768,6 +810,13 @@ public class JPAStorageService extends AbstractStorageService implements Storage
transaction.commit();
} catch (final Exception e) {
log.error("Error committing transaction", e);
+ if (transaction.isActive()) {
+ try {
+ transaction.rollback();
+ } catch (final Exception ex) {
+ log.error("Error rolling back transaction", e);
+ }
+ }
}
}
}
@@ -832,6 +881,13 @@ public class JPAStorageService extends AbstractStorageService implements Storage
transaction.commit();
} catch (final Exception e) {
log.error("Error committing transaction", e);
+ if (transaction.isActive()) {
+ try {
+ transaction.rollback();
+ } catch (final Exception ex) {
+ log.error("Error rolling back transaction", e);
+ }
+ }
}
}
}
diff --git a/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/JPAStorageServiceTest.java b/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/JPAStorageServiceTest.java
index 5e18a4c..d3396e3 100644
--- a/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/JPAStorageServiceTest.java
+++ b/opensaml-storage-impl/src/test/java/org/opensaml/storage/impl/JPAStorageServiceTest.java
@@ -143,6 +143,17 @@ public class JPAStorageServiceTest extends StorageServiceTest {
Assert.assertFalse(result, "createString should have failed");
}
+ @Test(singleThreaded = false, threadPoolSize = 25, invocationCount = 100)
+ public void multithreadCaseSensitiveKey() throws IOException {
+ shared.create("unit_test", "foo", "bar", null);
+ shared.create("unit_test", "FOO", "bar", null);
+ StorageRecord rec1 = shared.read("unit_test", "foo");
+ StorageRecord rec2 = shared.read("unit_test", "FOO");
+ Assert.assertNotNull(rec1);
+ Assert.assertNotNull(rec2);
+ Assert.assertNotEquals(rec1, rec2);
+ }
+
@Test
public void keyCollision() throws IOException {
shared.create("unit_test", "dlo1", "value", null);
@@ -176,6 +187,73 @@ public class JPAStorageServiceTest extends StorageServiceTest {
Assert.assertNull(rec2);
}
+ @Test
+ public void caseSensitiveContext() throws IOException {
+ shared.create("foo", "bar", "value", null);
+ shared.create("FOO", "bar", "value", null);
+ StorageRecord rec1 = shared.read("foo", "bar");
+ StorageRecord rec2 = shared.read("FOO", "bar");
+ Assert.assertNotNull(rec1);
+ Assert.assertNotNull(rec2);
+ Assert.assertNotEquals(rec1, rec2);
+
+ shared.update("foo", "bar", "value2", null);
+ shared.update("FOO", "bar", "value2", null);
+ rec1 = shared.read("foo", "bar");
+ rec2 = shared.read("FOO", "bar");
+ Assert.assertNotNull(rec1);
+ Assert.assertNotNull(rec2);
+ Assert.assertNotEquals(rec1, rec2);
+
+ Assert.assertEquals(2, storageService.readAll().size());
+ Assert.assertEquals(1, storageService.readAll("foo").size());
+ Assert.assertEquals(1, storageService.readAll("FOO").size());
+
+ shared.delete("foo", "bar");
+ rec1 = shared.read("foo", "bar");
+ rec2 = shared.read("FOO", "bar");
+ Assert.assertNull(rec1);
+ Assert.assertNotNull(rec2);
+ shared.delete("FOO", "bar");
+ rec1 = shared.read("foo", "bar");
+ rec2 = shared.read("FOO", "bar");
+ Assert.assertNull(rec1);
+ Assert.assertNull(rec2);
+ }
+
+ @Test
+ public void caseSensitiveKey() throws IOException {
+ shared.create("unit_test", "foo", "value", null);
+ shared.create("unit_test", "FOO", "value", null);
+ StorageRecord rec1 = shared.read("unit_test", "foo");
+ StorageRecord rec2 = shared.read("unit_test", "FOO");
+ Assert.assertNotNull(rec1);
+ Assert.assertNotNull(rec2);
+ Assert.assertNotEquals(rec1, rec2);
+
+ shared.update("unit_test", "foo", "value2", null);
+ shared.update("unit_test", "FOO", "value2", null);
+ rec1 = shared.read("unit_test", "foo");
+ rec2 = shared.read("unit_test", "FOO");
+ Assert.assertNotNull(rec1);
+ Assert.assertNotNull(rec2);
+ Assert.assertNotEquals(rec1, rec2);
+
+ Assert.assertEquals(2, storageService.readAll().size());
+ Assert.assertEquals(2, storageService.readAll("unit_test").size());
+
+ shared.delete("unit_test", "foo");
+ rec1 = shared.read("unit_test", "foo");
+ rec2 = shared.read("unit_test", "FOO");
+ Assert.assertNull(rec1);
+ Assert.assertNotNull(rec2);
+ shared.delete("unit_test", "FOO");
+ rec1 = shared.read("unit_test", "foo");
+ rec2 = shared.read("unit_test", "FOO");
+ Assert.assertNull(rec1);
+ Assert.assertNull(rec2);
+ }
+
@Test(enabled = false)
public void largeValue() throws IOException {
// hsqldb defaults LOB length to 255 chars; disabled for now
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list