You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@storm.apache.org by itaifrenkel <gi...@git.apache.org> on 2015/03/31 07:44:43 UTC

[GitHub] storm pull request: [STORM-733] [STORM-734] Fixed two bugs prevent...

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

    https://github.com/apache/storm/pull/489#discussion_r27454334
  
    --- Diff: storm-core/src/jvm/backtype/storm/utils/ShellProcess.java ---
    @@ -186,4 +163,35 @@ public String getProcessInfoString() {
         public String getProcessTerminationInfoString() {
             return String.format(" exitCode:%s, errorString:%s ", getExitCode(), getErrorsString());
         }
    +
    +    private Optional<String> getErrorStreamMessage() {
    +        int offset = 0;
    +        if (processErrorStream != null) {
    +            ByteArrayOutputStream out = null;
    +            try {
    +                do {
    +                    int bufferSize = processErrorStream.available();
    +                    if (bufferSize > 0) {
    +                        if (out == null) {
    +                            out = new ByteArrayOutputStream();
    +                        }
    +                        byte[] errorReadingBuffer = new byte[bufferSize];
    +                        final int read = processErrorStream.read(errorReadingBuffer, 0, bufferSize);
    +                        out.write(errorReadingBuffer, offset, bufferSize);
    +                        offset += read;
    +                    }
    +                } while (processErrorStream.available() > 0);
    +
    +                if (offset > 0)
    +                    return of(new String(out.toByteArray()));
    +            } catch (Exception e) {
    +                return of("(Unable to capture error stream)");
    +            } finally {
    +                if (out != null) {
    +                    IOUtils.closeQuietly(out);
    +                }
    +            }
    +        }
    +        return Optional.absent();
    --- End diff --
    
    @reembs This project ussually do not use Optional<>... so I would just return an empty string


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---