geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject incubator-geode git commit: GEODE-1431: Fix GfshParserJUnitTest failure
Date Mon, 23 May 2016 17:25:32 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 08c39c355 -> 15e985401


GEODE-1431: Fix GfshParserJUnitTest failure

* failure was introduced by exception refactoring with JoptOptionParserTest
* include Option when constructing Geode CLI exceptions


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/15e98540
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/15e98540
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/15e98540

Branch: refs/heads/develop
Commit: 15e985401e968e1a1c75a48f754625776b0943a2
Parents: 08c39c3
Author: Kirk Lund <klund@apache.org>
Authored: Mon May 23 09:53:21 2016 -0700
Committer: Kirk Lund <klund@apache.org>
Committed: Mon May 23 10:14:19 2016 -0700

----------------------------------------------------------------------
 ...CommandOptionHasMultipleValuesException.java |  6 +-
 .../CliCommandOptionMissingException.java       |  4 +
 .../CliCommandOptionNotApplicableException.java |  4 +
 .../CliCommandOptionValueMissingException.java  |  4 +
 .../cli/exceptions/ExceptionGenerator.java      | 20 ++---
 .../cli/exceptions/ExceptionHandler.java        | 77 +++++++-------------
 6 files changed, 56 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/15e98540/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionHasMultipleValuesException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionHasMultipleValuesException.java
b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionHasMultipleValuesException.java
index 2439945..fe48b57 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionHasMultipleValuesException.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionHasMultipleValuesException.java
@@ -36,7 +36,11 @@ public class CliCommandOptionHasMultipleValuesException extends CliCommandOption
     this(null, null, null, null, cause);
   }
 
-  public CliCommandOptionHasMultipleValuesException(final CommandTarget commandTarget, Option
option, final OptionSet optionSet, final String value, final Throwable cause) {
+  public CliCommandOptionHasMultipleValuesException(final Option option, final Throwable
cause) {
+    this(null, option, null, null, cause);
+  }
+
+  public CliCommandOptionHasMultipleValuesException(final CommandTarget commandTarget, final
Option option, final OptionSet optionSet, final String value, final Throwable cause) {
     super(commandTarget, option, optionSet, value, cause);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/15e98540/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionMissingException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionMissingException.java
b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionMissingException.java
index 1a2c8fe..5f34821 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionMissingException.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionMissingException.java
@@ -34,6 +34,10 @@ public class CliCommandOptionMissingException extends CliCommandOptionException
     this(null, null, null, cause);
   }
 
+  public CliCommandOptionMissingException(final Option option, final Throwable cause) {
+    this(null, option, null, cause);
+  }
+
   public CliCommandOptionMissingException(final CommandTarget commandTarget, final Option
option, final OptionSet optionSet, final Throwable cause) {
     super(commandTarget, option, optionSet, cause);
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/15e98540/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionNotApplicableException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionNotApplicableException.java
b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionNotApplicableException.java
index 1e9f726..85eac38 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionNotApplicableException.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionNotApplicableException.java
@@ -34,6 +34,10 @@ public class CliCommandOptionNotApplicableException extends CliCommandOptionExce
     this(null, null, null, cause);
   }
 
+  public CliCommandOptionNotApplicableException(final Option option, final Throwable cause)
{
+    this(null, option, null, cause);
+  }
+
   public CliCommandOptionNotApplicableException(final CommandTarget commandTarget, final
Option option, final OptionSet optionSet, Throwable cause) {
     super(commandTarget, option, optionSet, cause);
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/15e98540/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionValueMissingException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionValueMissingException.java
b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionValueMissingException.java
index 5fa02d9..78f73cd 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionValueMissingException.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/CliCommandOptionValueMissingException.java
@@ -34,6 +34,10 @@ public class CliCommandOptionValueMissingException extends CliCommandOptionValue
     this(null, null, null, null, cause);
   }
 
+  public CliCommandOptionValueMissingException(final Option option, final Throwable cause)
{
+    this(null, option, null, null, cause);
+  }
+
   public CliCommandOptionValueMissingException(final CommandTarget commandTarget, final Option
option, final OptionSet optionSet, final String value, final Throwable cause) {
     super(commandTarget, option, optionSet, value);
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/15e98540/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/ExceptionGenerator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/ExceptionGenerator.java
b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/ExceptionGenerator.java
index 61af7a4..1868c11 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/ExceptionGenerator.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/ExceptionGenerator.java
@@ -22,25 +22,27 @@ import joptsimple.OptionException;
 import joptsimple.OptionMissingRequiredArgumentException;
 import joptsimple.UnrecognizedOptionException;
 
+import com.gemstone.gemfire.management.internal.cli.parser.CommandTarget;
 import com.gemstone.gemfire.management.internal.cli.parser.Option;
+import com.gemstone.gemfire.management.internal.cli.parser.OptionSet;
 
 /**
  * Converts joptsimple exceptions into corresponding exceptions for cli
  */
 public class ExceptionGenerator {
 
-  public static CliCommandOptionException generate(Option option, OptionException e) {
-    if (MissingRequiredOptionException.class.isInstance(e)) {
-      return new CliCommandOptionMissingException(e);
+  public static CliCommandOptionException generate(Option option, OptionException cause)
{
+    if (MissingRequiredOptionException.class.isInstance(cause)) {
+      return new CliCommandOptionMissingException(option, cause);
 
-    } else if (OptionMissingRequiredArgumentException.class.isInstance(e)) {
-      return new CliCommandOptionValueMissingException(e);
+    } else if (OptionMissingRequiredArgumentException.class.isInstance(cause)) {
+      return new CliCommandOptionValueMissingException(option, cause);
 
-    } else if (UnrecognizedOptionException.class.isInstance(e)) {
-      return new CliCommandOptionNotApplicableException(e);
+    } else if (UnrecognizedOptionException.class.isInstance(cause)) {
+      return new CliCommandOptionNotApplicableException(option, cause);
 
-    } else if (MultipleArgumentsForOptionException.class.isInstance(e)) {
-      return new CliCommandOptionHasMultipleValuesException(e);
+    } else if (MultipleArgumentsForOptionException.class.isInstance(cause)) {
+      return new CliCommandOptionHasMultipleValuesException(option, cause);
 
     } else {
       return null;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/15e98540/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/ExceptionHandler.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/ExceptionHandler.java
b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/ExceptionHandler.java
index 1a3997b..0d14c3a 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/ExceptionHandler.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/exceptions/ExceptionHandler.java
@@ -18,57 +18,43 @@ package com.gemstone.gemfire.management.internal.cli.exceptions;
 
 import java.util.logging.Logger;
 
-import com.gemstone.gemfire.management.internal.cli.parser.SyntaxConstants;
 import com.gemstone.gemfire.management.internal.cli.util.CLIConsoleBufferUtil;
+
 /**
- * 
- *         Prints the warning according the CliException
- * 
+ * Prints the warning according the CliException
  */
 public class ExceptionHandler {
 
-  private static Logger LOGGER = Logger.getLogger(ExceptionHandler.class
-      .getCanonicalName());
+  private static Logger LOGGER = Logger.getLogger(ExceptionHandler.class.getCanonicalName());
   
-
   //FIXME define handling when no match is present
   public static void handleException(CliException ce) {    
-    if (ce instanceof CliCommandException) {
-      if (ce instanceof CliCommandNotAvailableException) {
-        handleCommandNotAvailableException((CliCommandNotAvailableException) ce);
-      } else if (ce instanceof CliCommandInvalidException) {
-        handleCommandInvalidException((CliCommandInvalidException) ce);
-      } else if (ce instanceof CliCommandOptionException) {
-        handleOptionException((CliCommandOptionException) ce);
-      } 
+    if (ce instanceof CliCommandNotAvailableException) {
+      handleCommandNotAvailableException((CliCommandNotAvailableException) ce);
+    } else if (ce instanceof CliCommandInvalidException) {
+      handleCommandInvalidException((CliCommandInvalidException) ce);
+    } else if (ce instanceof CliCommandOptionException) {
+      handleOptionException((CliCommandOptionException) ce);
     }
   }
 
-  private static void handleMultiModeOptionException(
-      CliCommandMultiModeOptionException ce) {
+  private static void handleMultiModeOptionException(CliCommandMultiModeOptionException ce)
{
     switch(ce.getCode()){
-    case CliCommandMultiModeOptionException.MULTIPLE_LEAD_OPTIONS :
-      LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer(
-          "Input command contains multiple lead-options from modes : " + ce.getLeadOptionString()));
-      break;
-    case CliCommandMultiModeOptionException.OPTIONS_FROM_MULTIPLE_MODES :
-      LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer(
-          "Input command contains options from multilpe modes : " + ce.getLeadOptionString()));
-      break;
+      case CliCommandMultiModeOptionException.MULTIPLE_LEAD_OPTIONS :
+        LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer("Input
command contains multiple lead-options from modes : " + ce.getLeadOptionString()));
+        break;
+      case CliCommandMultiModeOptionException.OPTIONS_FROM_MULTIPLE_MODES :
+        LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer("Input
command contains options from multilpe modes : " + ce.getLeadOptionString()));
+        break;
     }
-    
   }
 
-  private static void handleCommandInvalidException(
-      CliCommandInvalidException ccie) {   
-    LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer(ccie.getCommandTarget().getGfshMethodTarget().getKey()
-        + " is not a valid Command"));   
+  private static void handleCommandInvalidException(CliCommandInvalidException ccie) {
+    LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer(ccie.getCommandTarget().getGfshMethodTarget().getKey()
+ " is not a valid Command"));
   }
 
-  private static void handleCommandNotAvailableException(
-      CliCommandNotAvailableException ccnae) {    
-    LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer(ccnae.getCommandTarget().getGfshMethodTarget().getKey()
-        + " is not available at the moment"));    
+  private static void handleCommandNotAvailableException(CliCommandNotAvailableException
ccnae) {
+    LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer(ccnae.getCommandTarget().getGfshMethodTarget().getKey()
+ " is not available at the moment"));
   }
 
   private static void handleOptionException(CliCommandOptionException ccoe) {
@@ -81,25 +67,18 @@ public class ExceptionHandler {
     } 
   }
 
-  private static void handleOptionInvalidExcpetion(
-      CliCommandOptionNotApplicableException cconae) {  
-    String messege = "Parameter " + cconae.getOption().getLongOption()
-    + " is not applicable for "
-    + cconae.getCommandTarget().getGfshMethodTarget().getKey();    
+  private static void handleOptionInvalidExcpetion(CliCommandOptionNotApplicableException
cconae) {
+    String messege = "Parameter " + cconae.getOption().getLongOption() + " is not applicable
for " + cconae.getCommandTarget().getGfshMethodTarget().getKey();
     LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer(messege));
 
   }
 
-  private static void handleOptionValueException(
-      CliCommandOptionValueException ccove) {
+  private static void handleOptionValueException(CliCommandOptionValueException ccove) {
     if (ccove instanceof CliCommandOptionHasMultipleValuesException) {
-      String messege = "Parameter " + ccove.getOption().getLongOption() + " can only be specified
once";
-      LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer(messege));
+      // unfortunately by changing from geode-joptsimple to jopt-simple we will lose ALL
such debugging info from exceptions
+      //String parameter = ccove != null && ccove.getOption() != null ? ccove.getOption().getLongOption()
: "<null>";
+      String parameter = ccove.getOption().getLongOption();
+      String message = "Parameter " + parameter + " can only be specified once";
+      LOGGER.warning(CLIConsoleBufferUtil.processMessegeForExtraCharactersFromConsoleBuffer(message));
     }
   }
-
-  public static Logger getExceptionHanlderLogger(){
-    return LOGGER;   
-  }
-
-
 }


Mime
View raw message