cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject cayenne git commit: CAY-2110 Obfuscated exception when processing iterated results
Date Tue, 06 Sep 2016 08:59:28 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 5838101e5 -> 43a382ee0


CAY-2110 Obfuscated exception when processing iterated results

* making sure there's no way we'd commit a rolled back transaction


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/43a382ee
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/43a382ee
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/43a382ee

Branch: refs/heads/master
Commit: 43a382ee04a4689050c7e46942ad6b759b1e8b0f
Parents: 5838101
Author: Andrus Adamchik <andrus@objectstyle.com>
Authored: Tue Sep 6 11:54:42 2016 +0300
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Tue Sep 6 11:59:12 2016 +0300

----------------------------------------------------------------------
 .../access/TransactionResultIteratorDecorator.java       | 11 +++++++++++
 .../cayenne/access/DataContextIteratedQueryIT.java       |  2 +-
 docs/doc/src/main/resources/RELEASE-NOTES.txt            |  1 +
 3 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/43a382ee/cayenne-server/src/main/java/org/apache/cayenne/access/TransactionResultIteratorDecorator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/TransactionResultIteratorDecorator.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/TransactionResultIteratorDecorator.java
index b269f8d..d0045f3 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/TransactionResultIteratorDecorator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/TransactionResultIteratorDecorator.java
@@ -36,9 +36,17 @@ import java.util.List;
 final class TransactionResultIteratorDecorator<T> implements ResultIterator<T>
{
 
     private ResultIterator<T> result;
+
+
     private Transaction tx;
 
     public TransactionResultIteratorDecorator(ResultIterator<T> result, Transaction
tx) {
+
+        // make sure it is still valid before proceeding with the iterator
+        if(tx.isRollbackOnly()) {
+            throw new CayenneRuntimeException("Transaction passed should be rolled back");
+        }
+
         this.result = result;
         this.tx = tx;
     }
@@ -56,6 +64,9 @@ final class TransactionResultIteratorDecorator<T> implements ResultIterator<T>
{
 
         try {
             result.close();
+
+            // we can safely commit here as the transaction is internal to this decorator,
and we already checked
+            // that it hasn't been rolled back in constructor.
             tx.commit();
         } catch (Exception e) {
             try {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/43a382ee/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextIteratedQueryIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextIteratedQueryIT.java
b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextIteratedQueryIT.java
index e630e46..ff5f65e 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextIteratedQueryIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextIteratedQueryIT.java
@@ -236,7 +236,7 @@ public class DataContextIteratedQueryIT extends ServerCase {
         createArtistsDataSet();
 
         try (ResultIterator<?> it = context.performIteratedQuery(SelectQuery.query(Artist.class));)
{
-            assertNull(BaseTransaction.getThreadTransaction());
+            assertNull("Iterator transaction was not unbound from thread", BaseTransaction.getThreadTransaction());
         }
 
         // TODO: how do we test that transaction unbound from the thread is closed/committed
at the end?

http://git-wip-us.apache.org/repos/asf/cayenne/blob/43a382ee/docs/doc/src/main/resources/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/RELEASE-NOTES.txt b/docs/doc/src/main/resources/RELEASE-NOTES.txt
index aa2df92..d496e84 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -47,6 +47,7 @@ CAY-2097 NullPointerException while updating relationships for entities
with ver
 CAY-2101 DataContext.currentSnapshot() doesn't set snapshot entity name
 CAY-2105 Add missing elements to the reverseEngineering.xsd
 CAY-2108 cayenne-di: StackOverflow for decorator that takes Provider of the delegate
+CAY-2110 Obfuscated exception when processing iterated results
 
 ----------------------------------
 Release: 4.0.M3


Mime
View raw message