Program: 28448
Project: 28448
Buggy source:
/** 
 * Actually execute the remote command.
 */
private void executeRemoteCommand(final ParameterMap params) throws CommandException {
  doHttpCommand(getCommandURI(),"String_Node_Str",new HttpCommand(){
    @Override public void prepareConnection(    final HttpURLConnection urlConnection) throws IOException {
      try {
        if (useSse()) {
          urlConnection.addRequestProperty("String_Node_Str",MEDIATYPE_SSE);
        }
 else {
          urlConnection.addRequestProperty("String_Node_Str",MEDIATYPE_JSON + "String_Node_Str" + MEDIATYPE_MULTIPART+ "String_Node_Str");
        }
      }
 catch (      CommandException cex) {
        throw new IOException(cex.getLocalizedMessage(),cex);
      }
      for (      Header h : requestHeaders) {
        urlConnection.addRequestProperty(h.getName(),h.getValue());
      }
      ParamsWithPayload pwp;
      if (doUpload) {
        urlConnection.setChunkedStreamingMode(0);
        pwp=new ParamsWithPayload(outboundPayload,params);
      }
 else {
        pwp=new ParamsWithPayload(null,params);
      }
      ProprietaryWriter writer=ProprietaryWriterFactory.getWriter(pwp);
      if (logger.isLoggable(Level.FINER)) {
        logger.log(Level.FINER,"String_Node_Str",writer.getClass().getName());
      }
      writer.writeTo(pwp,urlConnection);
    }
    @Override public void useConnection(    final HttpURLConnection urlConnection) throws CommandException, IOException {
      String resultMediaType=urlConnection.getContentType();
      if (logger.isLoggable(Level.FINER)) {
        logger.log(Level.FINER,"String_Node_Str",resultMediaType);
        logger.log(Level.FINER,"String_Node_Str",urlConnection.getClass().getName());
      }
      if (resultMediaType != null && resultMediaType.startsWith(MEDIATYPE_SSE)) {
        String instanceId=null;
        boolean retryableCommand=false;
        try {
          logger.log(Level.FINEST,"String_Node_Str");
          closeSse=false;
          ProprietaryReader<GfSseEventReceiver> reader=new GfSseEventReceiverProprietaryReader();
          GfSseEventReceiver eventReceiver=reader.readFrom(urlConnection.getInputStream(),resultMediaType);
          GfSseInboundEvent event;
          do {
            event=eventReceiver.readEvent();
            if (event != null) {
              if (logger.isLoggable(Level.FINEST)) {
                logger.log(Level.FINEST,"String_Node_Str",event.getName());
              }
              fireEvent(event.getName(),event);
              if (AdminCommandState.EVENT_STATE_CHANGED.equals(event.getName())) {
                AdminCommandState acs=event.getData(AdminCommandState.class,MEDIATYPE_JSON);
                if (acs.getId() != null) {
                  instanceId=acs.getId();
                  if (logger.isLoggable(Level.FINEST)) {
                    logger.log(Level.FINEST,"String_Node_Str",instanceId);
                  }
                }
                if (acs.getState() == AdminCommandState.State.COMPLETED || acs.getState() == AdminCommandState.State.RECORDED || acs.getState() == AdminCommandState.State.REVERTED) {
                  if (acs.getActionReport() != null) {
                    setActionReport(acs.getActionReport());
                  }
                  closeSse=true;
                  if (!acs.isOutboundPayloadEmpty()) {
                    logger.log(Level.FINEST,"String_Node_Str");
                    downloadPayloadFromManaged(instanceId);
                  }
                }
 else                 if (acs.getState() == AdminCommandState.State.FAILED_RETRYABLE) {
                  logger.log(Level.INFO,strings.get("String_Node_Str",acs.getId()));
                  if (acs.getActionReport() != null) {
                    setActionReport(acs.getActionReport());
                  }
                  closeSse=true;
                }
 else                 if (acs.getState() == AdminCommandState.State.FAILED_RETRYABLE) {
                  logger.log(Level.FINEST,"String_Node_Str");
                  retryableCommand=true;
                }
              }
            }
          }
 while (event != null && !eventReceiver.isClosed() && !closeSse);
          if (closeSse) {
            try {
              eventReceiver.close();
            }
 catch (            Exception exc) {
            }
          }
        }
 catch (        IOException ioex) {
          if (instanceId != null && "String_Node_Str".equals(ioex.getMessage())) {
            if (retryableCommand) {
              throw new CommandException(strings.get("String_Node_Str",new Object[]{instanceId}),ioex);
            }
 else {
              throw new CommandException(strings.get("String_Node_Str",new Object[]{instanceId}),ioex);
            }
          }
 else {
            throw new CommandException(ioex.getMessage(),ioex);
          }
        }
catch (        Exception ex) {
          throw new CommandException(ex.getMessage(),ex);
        }
      }
 else {
        ProprietaryReader<ParamsWithPayload> reader=ProprietaryReaderFactory.getReader(ParamsWithPayload.class,resultMediaType);
        if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) {
          ActionReport report;
          if (reader == null) {
            report=new CliActionReport();
            report.setActionExitCode(ExitCode.FAILURE);
            report.setMessage(urlConnection.getResponseMessage());
          }
 else {
            report=reader.readFrom(urlConnection.getErrorStream(),resultMediaType).getActionReport();
          }
          setActionReport(report);
        }
 else {
          ParamsWithPayload pwp=reader.readFrom(urlConnection.getInputStream(),resultMediaType);
          if (pwp.getPayloadInbound() == null) {
            setActionReport(pwp.getActionReport());
          }
 else           if (resultMediaType.startsWith("String_Node_Str")) {
            RestPayloadImpl.Inbound inbound=pwp.getPayloadInbound();
            setActionReport(pwp.getActionReport());
            if (logger.isLoggable(Level.FINER)) {
              logger.log(Level.FINER,"String_Node_Str");
              Iterator<Payload.Part> parts=inbound.parts();
              while (parts.hasNext()) {
                Payload.Part part=parts.next();
                logger.log(Level.FINER,"String_Node_Str",new Object[]{part.getName(),part.getContentType()});
              }
              logger.log(Level.FINER,"String_Node_Str");
            }
            PayloadFilesManager downloadedFilesMgr=new PayloadFilesManager.Perm(fileOutputDir,null,logger,null);
            try {
              downloadedFilesMgr.processParts(inbound);
            }
 catch (            CommandException cex) {
              throw cex;
            }
catch (            Exception ex) {
              throw new CommandException(ex.getMessage(),ex);
            }
          }
        }
      }
    }
  }
);
  if (actionReport == null) {
    this.output=null;
    throw new CommandException(strings.get("String_Node_Str"));
  }
  if (actionReport.getActionExitCode() == ExitCode.FAILURE) {
    throw new CommandException(strings.getString("String_Node_Str","String_Node_Str") + "String_Node_Str" + this.output);
  }
}

Fixed version (ground truth):
/** 
 * Actually execute the remote command.
 */
private void executeRemoteCommand(final ParameterMap params) throws CommandException {
  doHttpCommand(getCommandURI(),"String_Node_Str",new HttpCommand(){
    @Override public void prepareConnection(    final HttpURLConnection urlConnection) throws IOException {
      try {
        if (useSse()) {
          urlConnection.addRequestProperty("String_Node_Str",MEDIATYPE_SSE);
        }
 else {
          urlConnection.addRequestProperty("String_Node_Str",MEDIATYPE_JSON + "String_Node_Str" + MEDIATYPE_MULTIPART+ "String_Node_Str");
        }
      }
 catch (      CommandException cex) {
        throw new IOException(cex.getLocalizedMessage(),cex);
      }
      for (      Header h : requestHeaders) {
        urlConnection.addRequestProperty(h.getName(),h.getValue());
      }
      ParamsWithPayload pwp;
      if (doUpload) {
        urlConnection.setChunkedStreamingMode(0);
        pwp=new ParamsWithPayload(outboundPayload,params);
      }
 else {
        pwp=new ParamsWithPayload(null,params);
      }
      ProprietaryWriter writer=ProprietaryWriterFactory.getWriter(pwp);
      if (logger.isLoggable(Level.FINER)) {
        logger.log(Level.FINER,"String_Node_Str",writer.getClass().getName());
      }
      writer.writeTo(pwp,urlConnection);
    }
    @Override public void useConnection(    final HttpURLConnection urlConnection) throws CommandException, IOException {
      String resultMediaType=urlConnection.getContentType();
      if (logger.isLoggable(Level.FINER)) {
        logger.log(Level.FINER,"String_Node_Str",resultMediaType);
        logger.log(Level.FINER,"String_Node_Str",urlConnection.getClass().getName());
      }
      if (resultMediaType != null && resultMediaType.startsWith(MEDIATYPE_SSE)) {
        String instanceId=null;
        boolean retryableCommand=false;
        try {
          logger.log(Level.FINEST,"String_Node_Str");
          closeSse=false;
          ProprietaryReader<GfSseEventReceiver> reader=new GfSseEventReceiverProprietaryReader();
          GfSseEventReceiver eventReceiver=reader.readFrom(urlConnection.getInputStream(),resultMediaType);
          GfSseInboundEvent event;
          do {
            event=eventReceiver.readEvent();
            if (event != null) {
              if (logger.isLoggable(Level.FINEST)) {
                logger.log(Level.FINEST,"String_Node_Str",event.getName());
              }
              fireEvent(event.getName(),event);
              if (AdminCommandState.EVENT_STATE_CHANGED.equals(event.getName())) {
                AdminCommandState acs=event.getData(AdminCommandState.class,MEDIATYPE_JSON);
                if (acs.getId() != null) {
                  instanceId=acs.getId();
                  if (logger.isLoggable(Level.FINEST)) {
                    logger.log(Level.FINEST,"String_Node_Str",instanceId);
                  }
                }
                if (acs.getState() == AdminCommandState.State.COMPLETED || acs.getState() == AdminCommandState.State.RECORDED || acs.getState() == AdminCommandState.State.REVERTED) {
                  if (acs.getActionReport() != null) {
                    setActionReport(acs.getActionReport());
                  }
                  closeSse=true;
                  if (!acs.isOutboundPayloadEmpty()) {
                    logger.log(Level.FINEST,"String_Node_Str");
                    downloadPayloadFromManaged(instanceId);
                  }
                }
 else                 if (acs.getState() == AdminCommandState.State.FAILED_RETRYABLE) {
                  logger.log(Level.INFO,strings.get("String_Node_Str",acs.getId()));
                  if (acs.getActionReport() != null) {
                    setActionReport(acs.getActionReport());
                  }
                  closeSse=true;
                }
 else                 if (acs.getState() == AdminCommandState.State.RUNNING_RETRYABLE) {
                  logger.log(Level.FINEST,"String_Node_Str");
                  retryableCommand=true;
                }
              }
            }
          }
 while (event != null && !eventReceiver.isClosed() && !closeSse);
          if (closeSse) {
            try {
              eventReceiver.close();
            }
 catch (            Exception exc) {
            }
          }
        }
 catch (        IOException ioex) {
          if (instanceId != null && "String_Node_Str".equals(ioex.getMessage())) {
            if (retryableCommand) {
              throw new CommandException(strings.get("String_Node_Str",new Object[]{instanceId}),ioex);
            }
 else {
              throw new CommandException(strings.get("String_Node_Str",new Object[]{instanceId}),ioex);
            }
          }
 else {
            throw new CommandException(ioex.getMessage(),ioex);
          }
        }
catch (        Exception ex) {
          throw new CommandException(ex.getMessage(),ex);
        }
      }
 else {
        ProprietaryReader<ParamsWithPayload> reader=ProprietaryReaderFactory.getReader(ParamsWithPayload.class,resultMediaType);
        if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) {
          ActionReport report;
          if (reader == null) {
            report=new CliActionReport();
            report.setActionExitCode(ExitCode.FAILURE);
            report.setMessage(urlConnection.getResponseMessage());
          }
 else {
            report=reader.readFrom(urlConnection.getErrorStream(),resultMediaType).getActionReport();
          }
          setActionReport(report);
        }
 else {
          ParamsWithPayload pwp=reader.readFrom(urlConnection.getInputStream(),resultMediaType);
          if (pwp.getPayloadInbound() == null) {
            setActionReport(pwp.getActionReport());
          }
 else           if (resultMediaType.startsWith("String_Node_Str")) {
            RestPayloadImpl.Inbound inbound=pwp.getPayloadInbound();
            setActionReport(pwp.getActionReport());
            if (logger.isLoggable(Level.FINER)) {
              logger.log(Level.FINER,"String_Node_Str");
              Iterator<Payload.Part> parts=inbound.parts();
              while (parts.hasNext()) {
                Payload.Part part=parts.next();
                logger.log(Level.FINER,"String_Node_Str",new Object[]{part.getName(),part.getContentType()});
              }
              logger.log(Level.FINER,"String_Node_Str");
            }
            PayloadFilesManager downloadedFilesMgr=new PayloadFilesManager.Perm(fileOutputDir,null,logger,null);
            try {
              downloadedFilesMgr.processParts(inbound);
            }
 catch (            CommandException cex) {
              throw cex;
            }
catch (            Exception ex) {
              throw new CommandException(ex.getMessage(),ex);
            }
          }
        }
      }
    }
  }
);
  if (actionReport == null) {
    this.output=null;
    throw new CommandException(strings.get("String_Node_Str"));
  }
  if (actionReport.getActionExitCode() == ExitCode.FAILURE) {
    throw new CommandException(strings.getString("String_Node_Str","String_Node_Str") + "String_Node_Str" + this.output);
  }
}