ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dma...@apache.org
Subject ignite git commit: Return modifiable versions of Sets, List and Maps to avoid UnsupportedOpertaionExceptions when iterator.remove() is used
Date Fri, 20 Nov 2015 10:05:45 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-801 d99233d66 -> 04d2c912e


Return modifiable versions of Sets, List and Maps to avoid UnsupportedOpertaionExceptions
when iterator.remove() is used


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/04d2c912
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/04d2c912
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/04d2c912

Branch: refs/heads/ignite-801
Commit: 04d2c912ed4238afa86395db6263900ce916521c
Parents: d99233d
Author: Denis Magda <dmagda@gridgain.com>
Authored: Fri Nov 20 13:05:05 2015 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Fri Nov 20 13:05:05 2015 +0300

----------------------------------------------------------------------
 .../IgniteTxImplicitSingleStateImpl.java        | 29 +++++++++++++++-----
 .../IgniteTxRemoteSingleStateImpl.java          | 19 ++++++++++---
 2 files changed, 37 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/04d2c912/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java
index c75a8f38..3e0231e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxImplicitSingleStateImpl.java
@@ -17,8 +17,10 @@
 
 package org.apache.ignite.internal.processors.cache.transactions;
 
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import org.apache.ignite.IgniteCheckedException;
@@ -28,6 +30,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture;
 import org.apache.ignite.internal.processors.cache.store.CacheStoreManager;
 import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
@@ -160,8 +163,13 @@ public class IgniteTxImplicitSingleStateImpl extends IgniteTxLocalStateAdapter
{
 
         CacheStoreManager store = cacheCtx.store();
 
-        if (store.configured())
-            return Collections.singleton(store);
+        if (store.configured()) {
+            HashSet<CacheStoreManager> set = new HashSet<>(3, 0.75f);
+
+            set.add(store);
+
+            return set;
+        }
 
         return null;
     }
@@ -192,12 +200,20 @@ public class IgniteTxImplicitSingleStateImpl extends IgniteTxLocalStateAdapter
{
 
     /** {@inheritDoc} */
     @Override public Set<IgniteTxKey> writeSet() {
-        return entry != null ? Collections.singleton(entry.txKey()) : Collections.<IgniteTxKey>emptySet();
+        if (entry != null) {
+            HashSet<IgniteTxKey> set = new HashSet<>(3, 0.75f);
+
+            set.add(entry.txKey());
+
+            return set;
+        }
+        else
+            return Collections.<IgniteTxKey>emptySet();
     }
 
     /** {@inheritDoc} */
     @Override public Collection<IgniteTxEntry> writeEntries() {
-        return entry != null ? Collections.singletonList(entry) : Collections.<IgniteTxEntry>emptyList();
+        return entry != null ? Arrays.asList(entry) : Collections.<IgniteTxEntry>emptyList();
     }
 
     /** {@inheritDoc} */
@@ -207,8 +223,7 @@ public class IgniteTxImplicitSingleStateImpl extends IgniteTxLocalStateAdapter
{
 
     /** {@inheritDoc} */
     @Override public Map<IgniteTxKey, IgniteTxEntry> writeMap() {
-        return entry != null ? Collections.singletonMap(entry.txKey(), entry) :
-            Collections.<IgniteTxKey, IgniteTxEntry>emptyMap();
+        return entry != null ? F.asMap(entry.txKey(), entry) : Collections.<IgniteTxKey,
IgniteTxEntry>emptyMap();
     }
 
     /** {@inheritDoc} */
@@ -223,7 +238,7 @@ public class IgniteTxImplicitSingleStateImpl extends IgniteTxLocalStateAdapter
{
 
     /** {@inheritDoc} */
     @Override public Collection<IgniteTxEntry> allEntries() {
-        return entry != null ? Collections.singletonList(entry) : Collections.<IgniteTxEntry>emptyList();
+        return entry != null ? Arrays.asList(entry) : Collections.<IgniteTxEntry>emptyList();
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/04d2c912/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteSingleStateImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteSingleStateImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteSingleStateImpl.java
index 22f04a8..90af517 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteSingleStateImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxRemoteSingleStateImpl.java
@@ -17,10 +17,13 @@
 
 package org.apache.ignite.internal.processors.cache.transactions;
 
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.jetbrains.annotations.Nullable;
 
@@ -62,12 +65,20 @@ public class IgniteTxRemoteSingleStateImpl extends IgniteTxRemoteStateAdapter
{
 
     /** {@inheritDoc} */
     @Override public Set<IgniteTxKey> writeSet() {
-        return entry != null ? Collections.singleton(entry.txKey()) : Collections.<IgniteTxKey>emptySet();
+        if (entry != null) {
+            HashSet<IgniteTxKey> set = new HashSet<>(3, 0.75f);
+
+            set.add(entry.txKey());
+
+            return set;
+        }
+        else
+            return Collections.<IgniteTxKey>emptySet();
     }
 
     /** {@inheritDoc} */
     @Override public Collection<IgniteTxEntry> writeEntries() {
-        return entry != null ? Collections.singletonList(entry) : Collections.<IgniteTxEntry>emptyList();
+        return entry != null ? Arrays.asList(entry) : Collections.<IgniteTxEntry>emptyList();
     }
 
     /** {@inheritDoc} */
@@ -77,7 +88,7 @@ public class IgniteTxRemoteSingleStateImpl extends IgniteTxRemoteStateAdapter
{
 
     /** {@inheritDoc} */
     @Override public Map<IgniteTxKey, IgniteTxEntry> writeMap() {
-        return entry != null ? Collections.singletonMap(entry.txKey(), entry) :
+        return entry != null ? F.asMap(entry.txKey(), entry) :
             Collections.<IgniteTxKey, IgniteTxEntry>emptyMap();
     }
 
@@ -93,7 +104,7 @@ public class IgniteTxRemoteSingleStateImpl extends IgniteTxRemoteStateAdapter
{
 
     /** {@inheritDoc} */
     @Override public Collection<IgniteTxEntry> allEntries() {
-        return entry != null ? Collections.singletonList(entry) : Collections.<IgniteTxEntry>emptyList();
+        return entry != null ? Arrays.asList(entry) : Collections.<IgniteTxEntry>emptyList();
     }
 
     /** {@inheritDoc} */


Mime
View raw message