| Summary: | InputStream from HostShellProcessAdapter incorrectly throws IOException | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Tools] Target Management | Reporter: | Greg Watson <g.watson> | ||||||
| Component: | RSE | Assignee: | Anna Dushistova <anna.dushistova> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | Martin Oberhuber <mober.at+eclipse> | ||||||
| Severity: | normal | ||||||||
| Priority: | P3 | Keywords: | helpwanted | ||||||
| Version: | 3.0.1 | ||||||||
| Target Milestone: | 3.1 M4 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Mac OS X - Carbon (unsup.) | ||||||||
| Whiteboard: | |||||||||
| Bug Depends on: | |||||||||
| Bug Blocks: | 251531 | ||||||||
| Attachments: |
|
||||||||
|
Description
Greg Watson
Greg - since you folks seem to have an environment which exposes the issue, could you try coming up with a patch and a unit test? Anna - assigning to you since this is your area of expertise, it should be pretty simple to write a unittest for this, and you started creating the ShellServiceUnitTests. Created attachment 120183 [details]
junit test for this bug
Here is a junit test. The issue is reproduced on my Linux machine with both local and ssh connection types.
Comment on attachment 120183 [details]
junit test for this bug
Can you please commit the test? There's no need attaching unittests. Having them in CVS right away saves us all the time with bugzilla, creating/applying/reviewing the patch etc.
Testcases can be committed by anybody at any time.
(In reply to comment #3) > (From update of attachment 120183 [details]) > Can you please commit the test? There's no need attaching unittests. Having > them in CVS right away saves us all the time with bugzilla, > creating/applying/reviewing the patch etc. > > Testcases can be committed by anybody at any time. Done. Note that it constantly fails now because of that broken pipe exception. Here is the patch I use:
### Eclipse Workspace Patch 1.0
#P org.eclipse.rse.services
Index: src/org/eclipse/rse/services/shells/HostShellProcessAdapter.java
===================================================================
RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/HostShellProcessAdapter.java,v
retrieving revision 1.3
diff -u -r1.3 HostShellProcessAdapter.java
--- src/org/eclipse/rse/services/shells/HostShellProcessAdapter.java 16 Nov 2006 10:17:05 -0000 1.3
+++ src/org/eclipse/rse/services/shells/HostShellProcessAdapter.java 11 Dec 2008 14:44:13 -0000
@@ -155,12 +155,19 @@
public void shellOutputChanged(IHostShellChangeEvent event) {
IHostOutput[] input = event.getLines();
OutputStream outputStream = event.isError() ? hostShellError : hostShellInput;
- try {
- for(int i = 0; i < input.length; i++) {
- outputStream.write(input[i].getString().getBytes());
- outputStream.write('\n');
- outputStream.flush();
+ if (input.length == 0) {
+ try {
+ outputStream.close();
+ } catch (IOException e) {
+ }
+ return;
}
+ try {
+ for(int i = 0; i < input.length; i++) {
+ outputStream.write(input[i].getString().getBytes());
+ outputStream.write('\n');
+ outputStream.flush();
+ }
} catch(IOException e) {
// Ignore
}
Works for me as well. (In reply to comment #5) > Here is the patch I use: > > ### Eclipse Workspace Patch 1.0 > #P org.eclipse.rse.services > Index: src/org/eclipse/rse/services/shells/HostShellProcessAdapter.java > =================================================================== > RCS file: > /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/HostShellProcessAdapter.java,v > retrieving revision 1.3 > diff -u -r1.3 HostShellProcessAdapter.java > --- src/org/eclipse/rse/services/shells/HostShellProcessAdapter.java 16 Nov > 2006 10:17:05 -0000 1.3 > +++ src/org/eclipse/rse/services/shells/HostShellProcessAdapter.java 11 Dec > 2008 14:44:13 -0000 > @@ -155,12 +155,19 @@ > public void shellOutputChanged(IHostShellChangeEvent event) { > IHostOutput[] input = event.getLines(); > OutputStream outputStream = event.isError() ? hostShellError : > hostShellInput; > - try { > - for(int i = 0; i < input.length; i++) { > - outputStream.write(input[i].getString().getBytes()); > - outputStream.write('\n'); > - outputStream.flush(); > + if (input.length == 0) { > + try { > + outputStream.close(); > + } catch (IOException e) { > + } > + return; > } > + try { > + for(int i = 0; i < input.length; i++) { > + > outputStream.write(input[i].getString().getBytes()); > + outputStream.write('\n'); > + outputStream.flush(); > + } > } catch(IOException e) { > // Ignore > } > Greg, could you please create a patch with proper copyright, so that we could apply it? Created attachment 120481 [details]
patch to fix problem
Here is a new patch with the copyright updated.
Thanks! We also need a Legal Disclaimer from you indicating that you contribute your work under EPL - see http://www.eclipse.org/dsdp/tm/development/committer_howto.php#external_contrib for details. (In reply to comment #8) > Created an attachment (id=120481) [details] > patch to fix problem > > Here is a new patch with the copyright updated. > I'm already an Eclipse committer, so I don't think I need to do this. (In reply to comment #10) > I'm already an Eclipse committer, so I don't think I need to do this. Greg - you are not a committer on our project, so I respectfully ask you to post the message. While it may seem tiresome and unnecessary, we use this as a constant reminder to ourselves about some extremely important key principles of every contribution. Please do take your time to copy & paste the message from the link that Anna provided. We're treating all our contributors equal in this case. I believe that starting to make exceptions to this policy we have would reduce its usefulness. Thanks! PS More officially, and pointing at the IP Poster: http://www.eclipse.org/legal/EclipseLegalProcessPoster.pdf * Fig 1 - you are not a committer on the same project under supervision of PMC * Fig 2 - you are not an employee of the submitting committer --> Therefore, for you, Fig 3 / Fig 9 applies for you, and we are requested to "confirm that the contribution...." which is exactly what we're doing by requesting you submit that legal statement. Thanks! I, Greg Watson, declare that I developed attached code from scratch, without referencing any 3rd party materials except material licensed under the EPL. I am authorized by my employer to make this contribution under the EPL. Patch is checked in, thanks! |