#ignite-758: Operation context is null by default.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b6bf81ad Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b6bf81ad Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b6bf81ad Branch: refs/heads/ignite-gg-9702 Commit: b6bf81add680b439ee3623d3a3d1252d27e16783 Parents: 6224b7e Author: ivasilinets <ivasilin...@gridgain.com> Authored: Fri Apr 17 17:10:59 2015 +0300 Committer: ivasilinets <ivasilin...@gridgain.com> Committed: Fri Apr 17 17:10:59 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/GridCacheProxyImpl.java | 24 +++++++++++--------- .../processors/cache/IgniteCacheProxy.java | 24 ++++++++++++++------ 2 files changed, 30 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b6bf81ad/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java index babb3ac..2294e8b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java @@ -82,7 +82,7 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte this.ctx = ctx; this.delegate = delegate; - this.opCtx = opCtx == null ? new CacheOperationContext() : opCtx; + this.opCtx = opCtx; gate = ctx.gate(); @@ -118,7 +118,7 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte CacheOperationContext prev = gate.enter(opCtx); try { - return opCtx.skipStore(); + return opCtx != null ? opCtx.skipStore() : false; } finally { gate.leave(prev); @@ -197,7 +197,8 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte /** {@inheritDoc} */ @Override public GridCacheProxyImpl<K, V> forSubjectId(UUID subjId) { - return new GridCacheProxyImpl<>(ctx, delegate, opCtx.forSubjectId(subjId)); + return new GridCacheProxyImpl<>(ctx, delegate, + opCtx != null ? opCtx.forSubjectId(subjId) : new CacheOperationContext(false, subjId, false, null)); } /** {@inheritDoc} */ @@ -205,10 +206,11 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte CacheOperationContext prev = gate.enter(opCtx); try { - if (opCtx.skipStore() == skipStore) + if (opCtx != null && opCtx.skipStore() == skipStore) return this; - return new GridCacheProxyImpl<>(ctx, delegate, opCtx.setSkipStore(skipStore)); + return new GridCacheProxyImpl<>(ctx, delegate, + opCtx != null ? opCtx.setSkipStore(skipStore) : new CacheOperationContext(true, null, false, null)); } finally { gate.leave(prev); @@ -217,10 +219,11 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte /** {@inheritDoc} */ @Override public <K1, V1> GridCacheProxyImpl<K1, V1> keepPortable() { - if (opCtx.isKeepPortable()) + if (opCtx != null && opCtx.isKeepPortable()) return (GridCacheProxyImpl<K1, V1>)this; - return new GridCacheProxyImpl<>((GridCacheContext<K1, V1>)ctx, (GridCacheAdapter<K1, V1>)delegate, opCtx.keepPortable()); + return new GridCacheProxyImpl<>((GridCacheContext<K1, V1>)ctx, (GridCacheAdapter<K1, V1>)delegate, + opCtx != null ? opCtx.keepPortable() : new CacheOperationContext(false, null, true, null)); } /** {@inheritDoc} */ @@ -1502,7 +1505,7 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte /** {@inheritDoc} */ @Nullable @Override public ExpiryPolicy expiry() { - return opCtx.expiry(); + return opCtx != null ? opCtx.expiry() : null; } /** {@inheritDoc} */ @@ -1510,9 +1513,8 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte CacheOperationContext prev = gate.enter(opCtx); try { - CacheOperationContext prj0 = opCtx.withExpiryPolicy(plc); - - return new GridCacheProxyImpl<>(ctx, delegate, prj0); + return new GridCacheProxyImpl<>(ctx, delegate, + opCtx != null ? opCtx.withExpiryPolicy(plc) : new CacheOperationContext(false, null, false, plc)); } finally { gate.leave(prev); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b6bf81ad/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index 128091f..9066cb8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@ -129,7 +129,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V this.ctx = ctx; this.delegate = delegate; - this.opCtx = opCtx == null ? new CacheOperationContext() : opCtx; + this.opCtx = opCtx; gate = ctx.gate(); @@ -238,7 +238,8 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V CacheOperationContext prev = onEnter(opCtx); try { - CacheOperationContext prj0 = opCtx.withExpiryPolicy(plc); + CacheOperationContext prj0 = opCtx != null ? opCtx.withExpiryPolicy(plc) : + new CacheOperationContext(false, null, false, plc); return new IgniteCacheProxy<>(ctx, delegate, prj0, isAsync(), lock); } @@ -347,10 +348,12 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V final CacheQuery<Map.Entry<K,V>> qry; final CacheQueryFuture<Map.Entry<K,V>> fut; + boolean isKeepPortable = opCtx != null ? opCtx.isKeepPortable() : false; + if (filter instanceof ScanQuery) { IgniteBiPredicate<K, V> p = ((ScanQuery)filter).getFilter(); - qry = ctx.queries().createScanQuery(p != null ? p : ACCEPT_ALL, opCtx.isKeepPortable()); + qry = ctx.queries().createScanQuery(p != null ? p : ACCEPT_ALL, isKeepPortable); if (grp != null) qry.projection(grp); @@ -360,7 +363,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V else if (filter instanceof TextQuery) { TextQuery p = (TextQuery)filter; - qry = ctx.queries().createFullTextQuery(p.getType(), p.getText(), opCtx.isKeepPortable()); + qry = ctx.queries().createFullTextQuery(p.getType(), p.getText(), isKeepPortable); if (grp != null) qry.projection(grp); @@ -368,7 +371,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V fut = qry.execute(); } else if (filter instanceof SpiQuery) { - qry = ctx.queries().createSpiQuery(opCtx.isKeepPortable()); + qry = ctx.queries().createSpiQuery(isKeepPortable); if (grp != null) qry.projection(grp); @@ -1442,7 +1445,11 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V try { CacheOperationContext opCtx0 = - new CacheOperationContext(opCtx.skipStore(), opCtx.subjectId(), true, opCtx.expiry()); + new CacheOperationContext( + opCtx != null ? opCtx.skipStore() : false, + opCtx != null ? opCtx.subjectId() : null, + true, + opCtx != null ? opCtx.expiry() : null); return new IgniteCacheProxy<>((GridCacheContext<K1, V1>)ctx, (GridCacheAdapter<K1, V1>)delegate, @@ -1468,7 +1475,10 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V return this; CacheOperationContext opCtx0 = - new CacheOperationContext(true, opCtx.subjectId(), opCtx.isKeepPortable(), opCtx.expiry()); + new CacheOperationContext(true, + opCtx != null ? opCtx.subjectId() : null, + opCtx != null ? opCtx.isKeepPortable() : false, + opCtx != null ? opCtx.expiry() : null); return new IgniteCacheProxy<>(ctx, delegate,