Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JBIDE-22153 Closing log of a pod throws an exception #1109

Merged
merged 1 commit into from
Apr 11, 2016

Conversation

scabanovich
Copy link
Contributor

No description provided.

@scabanovich
Copy link
Contributor Author

@jcantrill , @fbricon , please review.

@@ -160,10 +160,10 @@ protected void runOCBinary(MultiStatus multiStatus) {
final MessageConsoleStream os = console.newMessageStream();
os.setEncoding("UTF-8");
try {
final InputStream logs = new BufferedInputStream(capability.getLogs(true, key.container, OpenShiftBinaryOption.SKIP_TLS_VERIFY));
byte [] data = new byte [8192];
final InputStream logs = capability.getLogs(true, key.container, OpenShiftBinaryOption.SKIP_TLS_VERIFY);
Copy link
Member

Choose a reason for hiding this comment

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

we're not buffering anything anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Stack trace shows that there is already a BufferedInputStream in the chain of streams :). Anyway, if we read into array, it is by itself a buffer. Performance is affected only when we read by one byte.

@fbricon fbricon merged commit 3bf1690 into jbosstools:master Apr 11, 2016
try {
return logs.read(data);
} catch (IOException e) {
if("Stream closed".equals(e.getMessage())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this as exact of an exception we can get to identify a closed stream?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is thrown by BufferedInputStream. It would be nice to have in InputStream an interfce method isClosed() but I could not find it. The best approximation is the check (InputStream.available() < 0) but if we have BufferedInputStream, it throws that "Stream closed" in that method too instead of returning -1. So, I have decided that these too checks together may be reliable enough.

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.

None yet

3 participants