geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensde...@apache.org
Subject [geode] branch develop updated: GEODE-5322: Catch exceptions during plugin loading (#2058)
Date Fri, 15 Jun 2018 13:30:16 GMT
This is an automated email from the ASF dual-hosted git repository.

jensdeppe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new a76e951  GEODE-5322: Catch exceptions during plugin loading (#2058)
a76e951 is described below

commit a76e9519a4dc90c97deb22dfa097f58e29c67754
Author: Jens Deppe <jdeppe@pivotal.io>
AuthorDate: Fri Jun 15 06:29:39 2018 -0700

    GEODE-5322: Catch exceptions during plugin loading (#2058)
    
    - Revert to using an Iterator as the exceptions are generated from the next()
      call. Using forEach doesn't allow catch per-item exceptions just for the
      whole loop.
---
 .../geode/management/internal/cli/CommandManager.java      | 14 +++++++-------
 .../services/org.springframework.shell.core.CommandMarker  |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandManager.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandManager.java
index 690353a..354115c 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandManager.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/CommandManager.java
@@ -20,6 +20,7 @@ import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 import java.util.ServiceLoader;
@@ -150,21 +151,20 @@ public class CommandManager {
   private void loadPluginCommands() {
     ServiceLoader<CommandMarker> loader =
         ServiceLoader.load(CommandMarker.class, ClassPathLoader.getLatest().asClassLoader());
+    Iterator<CommandMarker> iterator = loader.iterator();
     try {
-      loader.forEach(commandMarker -> {
+      while (iterator.hasNext()) {
         try {
-          add(commandMarker);
-        } catch (Exception e) {
-          logWrapper.warning("Could not load Command from: " + commandMarker.getClass() +
" due to "
-              + e.getLocalizedMessage(), e); // continue
+          add(iterator.next());
+        } catch (Throwable t) {
+          logWrapper.warning("Could not load plugin command: " + t.getMessage());
         }
-      });
+      }
     } catch (Throwable th) {
       logWrapper.severe("Could not load plugin commands in the latest classLoader.", th);
     }
   }
 
-
   private void loadCommands() {
     loadUserCommands();
 
diff --git a/geode-core/src/test/resources/META-INF/services/org.springframework.shell.core.CommandMarker
b/geode-core/src/test/resources/META-INF/services/org.springframework.shell.core.CommandMarker
index 1bb7c6d..28eb157 100644
--- a/geode-core/src/test/resources/META-INF/services/org.springframework.shell.core.CommandMarker
+++ b/geode-core/src/test/resources/META-INF/services/org.springframework.shell.core.CommandMarker
@@ -5,4 +5,4 @@ org.apache.geode.management.internal.cli.CommandManagerJUnitTest$MockPluginComma
 
 
 # Mock Extension commands
-org.apache.geode.internal.cache.extension.mock.MockExtensionCommands
\ No newline at end of file
+org.apache.geode.internal.cache.extension.mock.MockExtensionCommands

-- 
To stop receiving notification emails like this one, please contact
jensdeppe@apache.org.

Mime
View raw message