Skip to content

fix null pointer exception in line 861 when the error stream is not provided - #1

Open
FlashBytes wants to merge 5 commits into
WWVengerov:masterfrom
FlashBytes:master
Open

fix null pointer exception in line 861 when the error stream is not provided#1
FlashBytes wants to merge 5 commits into
WWVengerov:masterfrom
FlashBytes:master

Conversation

@FlashBytes

Copy link
Copy Markdown

…resent but was used to read from it

@FlashBytes FlashBytes changed the title fix null pointer exception in line 861 when the error stream is not p… fix null pointer exception in line 861 when the error stream is not provided Feb 20, 2018
return null;
}

BufferedReader rd = new BufferedReader(new InputStreamReader(is));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can surround just this line with a try-catch block. Only put BufferedReader rd = null; before.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure as the lifetime of objects within a try block is local to the try block. This means other commands that are not part of the try block "do not see the object".

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable is not local to a scope if it was declared outside the scope. Therefore it should work:

BufferedReader rd = null;
try {
    rd = ....
} ...

@zhutik

zhutik commented Feb 21, 2018

Copy link
Copy Markdown

@renereichenbach we need to revise the implementation. There is already flow to retry getting output in catch statement of IO error. Basically, I recommend throw IOException in case is is null, so retry scenario will catch it

@FlashBytes

Copy link
Copy Markdown
Author

@zhutik I made a change. Please review. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants