You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2016/11/15 10:57:12 UTC
[1/4] cayenne git commit: NPE in BaseSchemaUpdateStrategy
Repository: cayenne
Updated Branches:
refs/heads/master 5708e3530 -> 627a67334
NPE in BaseSchemaUpdateStrategy
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/416c3699
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/416c3699
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/416c3699
Branch: refs/heads/master
Commit: 416c3699b0cf4513ebf0047fc6f83335a48f91e5
Parents: 5708e35
Author: Andrei Tomashpolskiy <no...@gmail.com>
Authored: Tue Nov 15 12:12:59 2016 +0300
Committer: Andrei Tomashpolskiy <no...@gmail.com>
Committed: Tue Nov 15 12:12:59 2016 +0300
----------------------------------------------------------------------
.../apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cayenne/blob/416c3699/cayenne-server/src/main/java/org/apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy.java b/cayenne-server/src/main/java/org/apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy.java
index 0d77585..47460bb 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy.java
@@ -30,20 +30,20 @@ import java.sql.SQLException;
public abstract class BaseSchemaUpdateStrategy implements SchemaUpdateStrategy {
protected volatile boolean run;
- protected volatile ThreadLocal<Boolean> threadRunInProgress;
+ protected final ThreadLocal<Boolean> threadRunInProgress;
public BaseSchemaUpdateStrategy() {
// this barrier is needed to prevent stack overflow in the same thread
// (getConnection/updateSchema/getConnection/...)
this.threadRunInProgress = new ThreadLocal<>();
- this.threadRunInProgress.set(false);
}
@Override
public void updateSchema(DataNode dataNode) throws SQLException {
- if (!run && !threadRunInProgress.get()) {
+ Boolean inProgress = threadRunInProgress.get();
+ if (!run && (inProgress == null || !inProgress)) {
synchronized (this) {
if (!run) {
[3/4] cayenne git commit: Merge branch '130'
Posted by aa...@apache.org.
Merge branch '130'
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/a551e01d
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/a551e01d
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/a551e01d
Branch: refs/heads/master
Commit: a551e01d72cb651a375745f5fe359c2b4d1e8835
Parents: e77e278 416c369
Author: Andrus Adamchik <an...@objectstyle.com>
Authored: Tue Nov 15 13:52:58 2016 +0300
Committer: Andrus Adamchik <an...@objectstyle.com>
Committed: Tue Nov 15 13:52:58 2016 +0300
----------------------------------------------------------------------
.../apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
[4/4] cayenne git commit: CAY-2143 NPE in BaseSchemaUpdateStrategy
Posted by aa...@apache.org.
CAY-2143 NPE in BaseSchemaUpdateStrategy
* release notes
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/627a6733
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/627a6733
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/627a6733
Branch: refs/heads/master
Commit: 627a67334ca8da09ffc5ed22920b227ae2c97ff3
Parents: a551e01
Author: Andrus Adamchik <an...@objectstyle.com>
Authored: Tue Nov 15 13:52:42 2016 +0300
Committer: Andrus Adamchik <an...@objectstyle.com>
Committed: Tue Nov 15 13:55:14 2016 +0300
----------------------------------------------------------------------
docs/doc/src/main/resources/RELEASE-NOTES.txt | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cayenne/blob/627a6733/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 066f890..eaca48f 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -67,6 +67,7 @@ CAY-2126 Modeler cannot upgrade project from v7 to v9
CAY-2128 Modeler stored procedures are not imported
CAY-2131 Modeler NullPointerException in reverse engineering when importing different catalogs in one datamap
CAY-2138 NVARCHAR, LONGNVARCHAR and NCLOB types are missing from Firebird types.xml
+CAY-2143 NPE in BaseSchemaUpdateStrategy
----------------------------------
Release: 4.0.M3
[2/4] cayenne git commit: CAY-2143 NPE in BaseSchemaUpdateStrategy
Posted by aa...@apache.org.
CAY-2143 NPE in BaseSchemaUpdateStrategy
* tests
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/e77e278b
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/e77e278b
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/e77e278b
Branch: refs/heads/master
Commit: e77e278b296525364c43554c14a681daaf5b4c0b
Parents: 5708e35
Author: Andrus Adamchik <an...@objectstyle.com>
Authored: Tue Nov 15 13:52:42 2016 +0300
Committer: Andrus Adamchik <an...@objectstyle.com>
Committed: Tue Nov 15 13:52:45 2016 +0300
----------------------------------------------------------------------
...aseSchemaUpdateStrategy_ConcurrencyTest.java | 98 ++++++++++++++++++++
1 file changed, 98 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cayenne/blob/e77e278b/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy_ConcurrencyTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy_ConcurrencyTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy_ConcurrencyTest.java
new file mode 100644
index 0000000..695202d
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/dbsync/BaseSchemaUpdateStrategy_ConcurrencyTest.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cayenne.access.dbsync;
+
+import org.apache.cayenne.access.DataNode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.mockito.Mockito.mock;
+
+public class BaseSchemaUpdateStrategy_ConcurrencyTest {
+
+ private static final Log LOGGER = LogFactory.getLog(BaseSchemaUpdateStrategy_ConcurrencyTest.class);
+
+ private ExecutorService threadPool;
+ private DataNode dataNode;
+
+ @Before
+ public void before() {
+ threadPool = Executors.newFixedThreadPool(2);
+ dataNode = mock(DataNode.class);
+ }
+
+ @After
+ public void after() {
+ threadPool.shutdownNow();
+ }
+
+ @Test
+ public void testUpdateSchema_Concurrency() throws InterruptedException, ExecutionException, TimeoutException {
+
+ final AtomicInteger counter = new AtomicInteger();
+ final AtomicBoolean errors = new AtomicBoolean(false);
+
+ final BaseSchemaUpdateStrategy strategy = new BaseSchemaUpdateStrategy() {
+ @Override
+ protected void processSchemaUpdate(DataNode dataNode) throws SQLException {
+ counter.incrementAndGet();
+ }
+ };
+
+ Collection<Future<?>> tasks = new ArrayList<>();
+
+ for (int i = 0; i < 20; i++) {
+ tasks.add(threadPool.submit(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ strategy.updateSchema(dataNode);
+ } catch (SQLException e) {
+ LOGGER.error("error in test", e);
+ errors.set(true);
+ }
+ }
+ }));
+ }
+
+ for(Future<?> f : tasks) {
+ f.get(1, TimeUnit.SECONDS);
+ }
+
+ assertFalse(errors.get());
+ assertEquals(1, counter.get());
+ }
+}