ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [1/3] incubator-ignite git commit: futures: api cleanup - removed final and nullable
Date Mon, 09 Mar 2015 17:59:16 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-143 45b676afc -> 7dbe2a398


futures: api cleanup - removed final and nullable


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

Branch: refs/heads/ignite-143
Commit: 95672d6cfbd61173b82dc86811dec33cf657b9a6
Parents: 45b676a
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Mon Mar 9 20:04:42 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Mon Mar 9 20:04:42 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/IgniteInternalFuture.java   |  2 +-
 .../util/future/GridFinishedFuture.java         |  7 ++--
 .../internal/util/future/GridFutureAdapter.java | 42 ++++++++++----------
 .../internal/util/future/IgniteFutureImpl.java  |  8 ++--
 .../processors/schedule/ScheduleFutureImpl.java | 40 +++++++++----------
 5 files changed, 50 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/95672d6c/modules/core/src/main/java/org/apache/ignite/internal/IgniteInternalFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteInternalFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/IgniteInternalFuture.java
index 255a067..78d64a1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteInternalFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteInternalFuture.java
@@ -111,7 +111,7 @@ public interface IgniteInternalFuture<R> {
      *
      * @param lsnr Listener closure to register. If not provided - this method is no-op.
      */
-    public void listen(@Nullable IgniteInClosure<? super IgniteInternalFuture<R>>
lsnr);
+    public void listen(IgniteInClosure<? super IgniteInternalFuture<R>> lsnr);
 
     /**
      * Make a chained future to convert result of this future (when complete) into a new
format.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/95672d6c/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFinishedFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFinishedFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFinishedFuture.java
index 691743f..379f078 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFinishedFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFinishedFuture.java
@@ -118,9 +118,10 @@ public class GridFinishedFuture<T> implements IgniteInternalFuture<T>
{
     }
 
     /** {@inheritDoc} */
-    @Override public void listen(final IgniteInClosure<? super IgniteInternalFuture<T>>
lsnr) {
-        if (lsnr != null)
-            lsnr.apply(this);
+    @Override public void listen(IgniteInClosure<? super IgniteInternalFuture<T>>
lsnr) {
+        assert lsnr != null;
+
+        lsnr.apply(this);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/95672d6c/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
index 5091655..89ef9fc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
@@ -163,32 +163,32 @@ public class GridFutureAdapter<R> extends AbstractQueuedSynchronizer
implements
     }
 
     /** {@inheritDoc} */
-    @Override public void listen(@Nullable final IgniteInClosure<? super IgniteInternalFuture<R>>
lsnr0) {
-        if (lsnr0 != null) {
-            boolean done = isDone();
-
-            if (!done) {
-                synchronized (this) {
-                    done = isDone(); // Double check.
-
-                    if (!done) {
-                        if (lsnr == null)
-                            lsnr = lsnr0;
-                        else if (lsnr instanceof ArrayListener)
-                            ((ArrayListener)lsnr).add(lsnr0);
-                        else {
-                            lsnr = (IgniteInClosure)new ArrayListener<IgniteInternalFuture>(lsnr,
lsnr0);
-                        }
-
-                        return;
+    @Override public void listen(IgniteInClosure<? super IgniteInternalFuture<R>>
lsnr0) {
+        assert lsnr0 != null;
+
+        boolean done = isDone();
+
+        if (!done) {
+            synchronized (this) {
+                done = isDone(); // Double check.
+
+                if (!done) {
+                    if (lsnr == null)
+                        lsnr = lsnr0;
+                    else if (lsnr instanceof ArrayListener)
+                        ((ArrayListener)lsnr).add(lsnr0);
+                    else {
+                        lsnr = (IgniteInClosure)new ArrayListener<IgniteInternalFuture>(lsnr,
lsnr0);
                     }
+
+                    return;
                 }
             }
+        }
 
-            assert done;
+        assert done;
 
-            notifyListener(lsnr0);
-        }
+        notifyListener(lsnr0);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/95672d6c/modules/core/src/main/java/org/apache/ignite/internal/util/future/IgniteFutureImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/future/IgniteFutureImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/future/IgniteFutureImpl.java
index 05858eb..ba3881f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/future/IgniteFutureImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/future/IgniteFutureImpl.java
@@ -23,7 +23,6 @@ import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
-import org.jetbrains.annotations.*;
 
 import java.util.concurrent.*;
 
@@ -71,9 +70,10 @@ public class IgniteFutureImpl<V> implements IgniteFuture<V>
{
     }
 
     /** {@inheritDoc} */
-    @Override public void listen(@Nullable final IgniteInClosure<? super IgniteFuture<V>>
lsnr) {
-        if (lsnr != null)
-            fut.listen(new InternalFutureListener(lsnr));
+    @Override public void listen(IgniteInClosure<? super IgniteFuture<V>> lsnr)
{
+        A.notNull(lsnr, "lsnr");
+
+        fut.listen(new InternalFutureListener(lsnr));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/95672d6c/modules/schedule/src/main/java/org/apache/ignite/internal/processors/schedule/ScheduleFutureImpl.java
----------------------------------------------------------------------
diff --git a/modules/schedule/src/main/java/org/apache/ignite/internal/processors/schedule/ScheduleFutureImpl.java
b/modules/schedule/src/main/java/org/apache/ignite/internal/processors/schedule/ScheduleFutureImpl.java
index 5f21297..7c1aedd 100644
--- a/modules/schedule/src/main/java/org/apache/ignite/internal/processors/schedule/ScheduleFutureImpl.java
+++ b/modules/schedule/src/main/java/org/apache/ignite/internal/processors/schedule/ScheduleFutureImpl.java
@@ -544,33 +544,33 @@ class ScheduleFutureImpl<R> implements SchedulerFuture<R>
{
     }
 
     /** {@inheritDoc} */
-    @Override public void listen(@Nullable IgniteInClosure<? super IgniteFuture<R>>
lsnr) {
-        if (lsnr != null) {
-            Throwable err;
-            R res;
+    @Override public void listen(IgniteInClosure<? super IgniteFuture<R>> lsnr)
{
+        A.notNull(lsnr, "lsnr");
 
-            boolean notifyLsnr = false;
+        Throwable err;
+        R res;
 
-            synchronized (mux) {
-                lsnrs.add(lsnr);
+        boolean notifyLsnr = false;
 
-                err = lastErr;
-                res = lastRes;
+        synchronized (mux) {
+            lsnrs.add(lsnr);
 
-                int cnt = stats.getExecutionCount();
+            err = lastErr;
+            res = lastRes;
 
-                if (cnt > 0 && lastLsnrExecCnt != cnt) {
-                    lastLsnrExecCnt = cnt;
+            int cnt = stats.getExecutionCount();
 
-                    notifyLsnr = true;
-                }
-            }
+            if (cnt > 0 && lastLsnrExecCnt != cnt) {
+                lastLsnrExecCnt = cnt;
 
-            // Avoid race condition in case if listener was added after
-            // first execution completed.
-            if (notifyLsnr)
-                notifyListener(lsnr, res, err);
+                notifyLsnr = true;
+            }
         }
+
+        // Avoid race condition in case if listener was added after
+        // first execution completed.
+        if (notifyLsnr)
+            notifyListener(lsnr, res, err);
     }
 
     /** {@inheritDoc} */
@@ -866,7 +866,7 @@ class ScheduleFutureImpl<R> implements SchedulerFuture<R>
{
         }
 
         /** {@inheritDoc} */
-        @Override public void listen(@Nullable IgniteInClosure<? super IgniteFuture<R>>
lsnr) {
+        @Override public void listen(IgniteInClosure<? super IgniteFuture<R>>
lsnr) {
             ref.listen(lsnr);
         }
 


Mime
View raw message