You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2015/04/23 19:35:59 UTC
[4/6] isis git commit: ISIS-1134: reviewing Martin's changes and
comments, tiny refactorings.
ISIS-1134: reviewing Martin's changes and comments, tiny refactorings.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/909831e5
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/909831e5
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/909831e5
Branch: refs/heads/master
Commit: 909831e5ff6ff2df7afcc7baf399f92fe3faa699
Parents: 8b45bd4
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Apr 23 14:58:28 2015 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Apr 23 14:59:04 2015 +0100
----------------------------------------------------------------------
.../system/context/IsisContextThreadLocal.java | 9 +++------
...rsistenceQueryFindUsingApplibQueryProcessor.java | 16 ++++++++++------
2 files changed, 13 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/909831e5/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContextThreadLocal.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContextThreadLocal.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContextThreadLocal.java
index ff8b175..5c34916 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContextThreadLocal.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContextThreadLocal.java
@@ -19,10 +19,9 @@
package org.apache.isis.core.runtime.system.context;
+import java.util.IdentityHashMap;
import java.util.Map;
-import com.google.common.collect.Maps;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,8 +42,7 @@ public class IsisContextThreadLocal extends IsisContext {
return new IsisContextThreadLocal(sessionFactory);
}
- // TODO Review. Use IdentityHashMap to make it clear that Thread as a key is compared by identity
- private final Map<Thread, IsisSession> sessionsByThread = Maps.newHashMap();
+ private final Map<Thread, IsisSession> sessionsByThread = new IdentityHashMap<>();
// //////////////////////////////////////////////
@@ -71,9 +69,8 @@ public class IsisContextThreadLocal extends IsisContext {
protected void shutdownAllThreads() {
synchronized (sessionsByThread) {
- int i = 0;
for (final Map.Entry<Thread, IsisSession> entry : sessionsByThread.entrySet()) {
- LOG.info("Shutting down thread: {}", i++); // TODO this 'i' is meaningless. Use entry.getKey().getName() instead ?
+ LOG.info("Shutting down thread: {}", entry.getKey().getName());
final IsisSession data = entry.getValue();
data.closeAll();
}
http://git-wip-us.apache.org/repos/asf/isis/blob/909831e5/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryFindUsingApplibQueryProcessor.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryFindUsingApplibQueryProcessor.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryFindUsingApplibQueryProcessor.java
index f6361e1..28233be 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryFindUsingApplibQueryProcessor.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryFindUsingApplibQueryProcessor.java
@@ -85,7 +85,8 @@ public class PersistenceQueryFindUsingApplibQueryProcessor extends PersistenceQu
}
try {
- return Lists.newArrayList((List<?>) jdoQuery.execute());
+ final List<?> results = (List<?>) jdoQuery.execute();
+ return Lists.newArrayList(results);
} finally {
jdoQuery.closeAll();
}
@@ -112,13 +113,16 @@ public class PersistenceQueryFindUsingApplibQueryProcessor extends PersistenceQu
if (LOG.isDebugEnabled()) {
LOG.debug(cls.getName() + " # " + queryName + " ( " + argumentsByParameterName + " )");
}
-
+
try {
final List<?> results = (List<?>) jdoQuery.executeWithMap(argumentsByParameterName);
- if (cardinality == QueryCardinality.MULTIPLE) {
- return Lists.newArrayList(results);
- }
- return results.isEmpty() ? Collections.emptyList() : Lists.newArrayList(results.subList(0, 1));
+ final List<?> resultsToReturn =
+ cardinality == QueryCardinality.MULTIPLE
+ ? results
+ : results.isEmpty()
+ ? Collections.emptyList()
+ : results.subList(0, 1);
+ return Lists.newArrayList(resultsToReturn);
} finally {
jdoQuery.closeAll();
}