You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jc...@apache.org on 2020/02/06 21:26:27 UTC
[geode] 01/01: GEODE-7746: Fix the NullPointerException
This is an automated email from the ASF dual-hosted git repository.
jchen21 pushed a commit to branch feature/GEODE-7746
in repository https://gitbox.apache.org/repos/asf/geode.git
commit b73daaa00a480a14489c34e33a932617be4ddd6b
Author: Jianxia Chen <jc...@apache.org>
AuthorDate: Thu Feb 6 13:23:30 2020 -0800
GEODE-7746: Fix the NullPointerException
Add null check and throw NoAvailableServersException
---
.../geode/cache/client/internal/ExecuteFunctionOp.java | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/internal/ExecuteFunctionOp.java b/geode-core/src/main/java/org/apache/geode/cache/client/internal/ExecuteFunctionOp.java
index e16d6cd..c6ef1af 100755
--- a/geode-core/src/main/java/org/apache/geode/cache/client/internal/ExecuteFunctionOp.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/client/internal/ExecuteFunctionOp.java
@@ -24,6 +24,7 @@ import java.util.function.Supplier;
import org.apache.logging.log4j.Logger;
import org.apache.geode.InternalGemFireError;
+import org.apache.geode.cache.client.NoAvailableServersException;
import org.apache.geode.cache.client.ServerConnectivityException;
import org.apache.geode.cache.client.ServerOperationException;
import org.apache.geode.cache.execute.Function;
@@ -79,6 +80,10 @@ public class ExecuteFunctionOp {
List callableTasks = constructAndGetFunctionTasks(pool,
attributes, executeFunctionOpSupplier);
+ if (callableTasks.isEmpty()) {
+ throw new NoAvailableServersException();
+ }
+
SingleHopClientExecutor.submitAll(callableTasks);
} else {
@@ -128,11 +133,13 @@ public class ExecuteFunctionOp {
final Supplier<ExecuteFunctionOpImpl> executeFunctionOpSupplier) {
final List<SingleHopOperationCallable> tasks = new ArrayList<>();
List<ServerLocation> servers = pool.getConnectionSource().getAllServers();
- for (ServerLocation server : servers) {
- final AbstractOp op = executeFunctionOpSupplier.get();
- SingleHopOperationCallable task =
- new SingleHopOperationCallable(server, pool, op, attributes);
- tasks.add(task);
+ if (servers != null) {
+ for (ServerLocation server : servers) {
+ final AbstractOp op = executeFunctionOpSupplier.get();
+ SingleHopOperationCallable task =
+ new SingleHopOperationCallable(server, pool, op, attributes);
+ tasks.add(task);
+ }
}
return tasks;
}