Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/906#discussion_r39967665
  
    --- Diff: 
software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessWinRmDriver.java
 ---
    @@ -134,37 +187,40 @@ protected void createDirectory(String directoryName, 
String summaryForLogging) {
             getLocation().executePsScript("New-Item -path \"" + directoryName 
+ "\" -type directory -ErrorAction SilentlyContinue");
         }
     
    -    protected WinRmToolResponse executeCommand(ConfigKey<String> 
regularCommandKey, ConfigKey<String> powershellCommandKey, boolean allowNoOp) {
    -        String regularCommand = getEntity().getConfig(regularCommandKey);
    -        String powershellCommand = 
getEntity().getConfig(powershellCommandKey);
    -        if (Strings.isBlank(regularCommand) && 
Strings.isBlank(powershellCommand)) {
    +    @Override
    +    public Integer executeNativeOrPsCommand(Map flags, String 
regularCommand, String powerShellCommand, String phase, Boolean allowNoOp) {
    +        if (Strings.isBlank(regularCommand) && 
Strings.isBlank(powerShellCommand)) {
                 if (allowNoOp) {
    -                return new WinRmToolResponse("", "", 0);
    +                return new WinRmToolResponse("", "", 0).getStatusCode();
                 } else {
    -                throw new IllegalStateException(String.format("Exactly one 
of %s or %s must be set", regularCommandKey.getName(), 
powershellCommandKey.getName()));
    +                throw new IllegalStateException(String.format("Exactly one 
of %s or %s must be set", regularCommand, powerShellCommand));
                 }
    -        } else if (!Strings.isBlank(regularCommand) && 
!Strings.isBlank(powershellCommand)) {
    -            throw new IllegalStateException(String.format("%s and %s 
cannot both be set", regularCommandKey.getName(), 
powershellCommandKey.getName()));
    +        } else if (!Strings.isBlank(regularCommand) && 
!Strings.isBlank(powerShellCommand)) {
    +            throw new IllegalStateException(String.format("%s and %s 
cannot both be set", regularCommand, powerShellCommand));
             }
     
             ByteArrayOutputStream stdIn = new ByteArrayOutputStream();
    -        ByteArrayOutputStream stdOut = new ByteArrayOutputStream();
    -        ByteArrayOutputStream stdErr = new ByteArrayOutputStream();
    +        ByteArrayOutputStream stdOut = flags.get("out") != null ? 
(ByteArrayOutputStream)flags.get("out") : new ByteArrayOutputStream();
    --- End diff --
    
    We should not assume that the caller has passed in a 
`ByteArrayOutputStream` when they have populated the `out` or `err` key in 
`flags`. 
    
    Let's not worry about it in this PR though. I see that 
`AbstractSoftwareProcessSshDriver` is bad as well, but in a different way. It 
overwrites any stdout and stderr keys (if any) that were passed in by the user.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to