Last active
December 16, 2016 06:01
-
-
Save k2sd/0976f3b53ece2eeae56458b00e4c5654 to your computer and use it in GitHub Desktop.
For fixing NPE msg on jbatch cli command.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: AbstractListCommandProxy.java | |
=================================================================== | |
--- AbstractListCommandProxy.java (revision 64309) | |
+++ AbstractListCommandProxy.java (working copy) | |
@@ -54,6 +54,8 @@ import org.glassfish.internal.api.Target; | |
import org.jvnet.hk2.annotations.Service; | |
import javax.inject.Inject; | |
+ | |
+import java.util.List; | |
import java.util.Properties; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; | |
@@ -107,6 +109,7 @@ public abstract class AbstractListCommandProxy | |
ActionReport subReport = null; | |
if (! preInvoke(context, actionReport)) { | |
commandsExitCode = ActionReport.ExitCode.FAILURE; | |
+ actionReport.setActionExitCode(commandsExitCode); | |
return; | |
} | |
@@ -129,17 +132,26 @@ public abstract class AbstractListCommandProxy | |
if (subReport.getExtraProperties() != null && subReport.getExtraProperties().size() > 0) | |
postInvoke(context, subReport); | |
else { | |
- if (subReport.getSubActionsReport() != null && subReport.getSubActionsReport().size() > 0) { | |
+ if (hasSubReportWithExtraProperties(subReport)) { | |
postInvoke(context, subReport.getSubActionsReport().get(0)); | |
} else { | |
actionReport.setMessage(subReport.getMessage()); | |
- commandsExitCode = subReport.getActionExitCode(); | |
} | |
} | |
+ commandsExitCode = subReport.getActionExitCode(); | |
} | |
actionReport.setActionExitCode(commandsExitCode); | |
} | |
+ private boolean hasSubReportWithExtraProperties(ActionReport report) { | |
+ List<? extends ActionReport> subReports = report.getSubActionsReport(); | |
+ if (subReports == null || subReports.size() == 0) { | |
+ return false; | |
+ } | |
+ Properties extraProps = subReports.get(0).getExtraProperties(); | |
+ return extraProps != null && extraProps.size() > 0; | |
+ } | |
+ | |
protected boolean preInvoke(AdminCommandContext ctx, ActionReport subReport) { | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Rev2 fixes NPE and modifies to set failure code correctly if the command fails on DAS.