Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 333613 - [terminal] "Job found still running" message on stdout console after terminating Eclipse
Summary: [terminal] "Job found still running" message on stdout console after terminat...
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: Terminal (show other bugs)
Version: 3.3   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 3.3 RC2   Edit
Assignee: Martin Oberhuber CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 346968 348700
  Show dependency tree
 
Reported: 2011-01-05 19:40 EST by Martin Oberhuber CLA
Modified: 2011-06-08 06:05 EDT (History)
2 users (show)

See Also:


Attachments
Patch with fix. (2.46 KB, patch)
2011-01-21 00:52 EST, Pawel Piech CLA
no flags Details | Diff
Patch with fInputStream.close() (3.50 KB, patch)
2011-02-28 18:11 EST, Pawel Piech CLA
no flags Details | Diff
Updated fix. (4.31 KB, patch)
2011-03-02 12:47 EST, Pawel Piech CLA
mober.at+eclipse: iplog-
Details | Diff
Patch without available() api change. (4.32 KB, patch)
2011-03-15 00:15 EDT, Pawel Piech CLA
mober.at+eclipse: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Oberhuber CLA 2011-01-05 19:40:21 EST
Build ID: TM 3.3m4 on Eclipse 3.6.1, on RHEL4 (szg-qa-lx1)
Likely also an issue with TM 3.2.1

To reproduce:
Create an RSE "SSH Only" connection. Connect "My Home". Launch a Terminal from RSE. In the terminal, type "exit". Right-click disconnect. Quit Eclipse.

On the stdout console where Eclipse had been launched, I see this:

looking for type: got text/plain
                                                         
Job found still running after platform shutdown.  Jobs should be canceled by the plugin that scheduled them during shutdown: org.eclipse.tm.internal.terminal.emulator.VT100TerminalControl$1
Comment 1 Pawel Piech CLA 2011-01-21 00:52:32 EST
Created attachment 187257 [details]
Patch with fix.

I saw the same problem with the process connector (getting a lot of error messages printed to the terminal when launching from command line).  I think this patch should do the trick.
Comment 2 Martin Oberhuber CLA 2011-01-21 06:08:00 EST
The patch looks reasonable, but what happens if you interrupt the Thread while the "Terminal data reader" job is inside its fTerminalText.processText() ?

Is there a risk of disconnecting twice, getting into a loop, or logging the InterruptedException unnecessarily?

It would seem cleaner to me to just do an fInputStream.close() -- the PipedInputStream that we use will set a closed status and notifyAll() so it should come out of the wait() while reading data. Effect should be the same of terminating the job more quickly, but also more cleanly.

I didn't try this out, though.
Comment 3 Martin Oberhuber CLA 2011-01-25 12:20:49 EST
Pawel, I have released a different change in the file that you patch.

Could you update to HEAD, consider my comment #2, and upload a new patch?
Comment 4 Pawel Piech CLA 2011-02-28 18:11:22 EST
Created attachment 190008 [details]
Patch with fInputStream.close()

I'm sorry I didn't reply earlier but I somehow missed your updates to the bug.  

(In reply to comment #2)
> The patch looks reasonable, but what happens if you interrupt the Thread while
> the "Terminal data reader" job is inside its fTerminalText.processText() ?
> 
> Is there a risk of disconnecting twice, getting into a loop, or logging the
> InterruptedException unnecessarily?
Yes, no, yes.  

> It would seem cleaner to me to just do an fInputStream.close() -- the
> PipedInputStream that we use will set a closed status and notifyAll() so it
> should come out of the wait() while reading data. Effect should be the same of
> terminating the job more quickly, but also more cleanly.

I agree that using interrupt is rather heavy handed and closing the input stream is more appropriate.  I guess my patch was more of a throw it over the fence approach ;-)

Unfortunately calling PipedInputStream.close() does not cause the waitForAvaiable() to return immediately.  So to make it work, I had to introduce a BufferedInputStream and call mark, read, reset, on it.  I tested the patch and it appears to work, but it I'm not crazy about it.
Comment 5 Pawel Piech CLA 2011-03-02 12:47:28 EST
Created attachment 190183 [details]
Updated fix.

This is an improved patch in that it doesn't add BufferedInputStream.  Until I looked again now, I didnt' realize that the terminal implemented its own PipedInputStream.  Given this I was able to modify the waitForAvailable() method to return immediately when stream is closed.

(In reply to comment #4)
> I tested the patch and it appears to work, but it I'm not crazy about it.

I should qualify my statement a bit.  The mark, read, reset is a valid paradigm and it's used here as the API intended.  I'm not crazy about the previous patch because I had to introduce a BufferedInputStream into a solution where I don't fully understand the intent of the larger architecture. 

I still don't fully understand the intent of the architecture.  For example I don't see why there is a custom PipedInputStream implementation and its javadoc doesn't help since it seems to be for a different module.  I also couldn't find any unit tests which exercise the VT100TerminalControl, so I'm not fully confident that my changes won't break some use case that I'm not familiar with.
So please review the patch with this context in mind.
Comment 6 Martin Oberhuber CLA 2011-03-11 08:15:59 EST
CQ:WIND00260518
Comment 7 Martin Oberhuber CLA 2011-03-14 20:02:07 EDT
I found it unusual to have PipedInputStream#BoundedByteBuffer#available() return -1 if the Stream is closed, forcing the related small API change in line 246.

It might be more correct to have PipedInputStream#BoundedByteBuffer#read() return -1 in line 144, and to modify PipedInputStream#waitForAvailable() to stop waiting if the Queue is closed in line 239.

But I didn't have time to test or debug this, so I'm taking your word that this is OK.

Released into 3.3m6 - I would appreciate your reviewing the committed change again based on above observations. Thanks for the patch.
Comment 8 Martin Oberhuber CLA 2011-03-14 20:12:14 EDT
BTW I ran the 209 unittests and 15 plugin-tests in o.e.tm.terminal.test and they all passed on my Win7 / J2SE-1.6.0_21 environment. I'm afraid though that none of those tests test the PipedInputStream
Comment 9 Martin Oberhuber CLA 2011-03-14 20:24:11 EDT
I'm actually reverting the release, since the PipedInputStreamPerformanceTest doesn't terminate any more (it looks like its "wt" writerThread doesn't like your change), and the PipedStreamTest doesn't continuously repeat.

Both these tests are located in the o.e.tm.terminal.test project.
Both are simple "Java Applications" that you can run in your workspace.
Both work as expected again after reverting your change.

Please revise.
Comment 10 Pawel Piech CLA 2011-03-15 00:15:50 EDT
Created attachment 191186 [details]
Patch without available() api change.

(In reply to comment #7)
> I found it unusual to have PipedInputStream#BoundedByteBuffer#available()
> return -1 if the Stream is closed, forcing the related small API change in 
> line 246.
> 
> It might be more correct to have PipedInputStream#BoundedByteBuffer#read()
> return -1 in line 144, and to modify PipedInputStream#waitForAvailable() to
> stop waiting if the Queue is closed in line 239.

Sure this works, and avoiding the API change also avoid breaking the performance tests.  I tested this patch with a terminal connected to a process and with the performance test.  IMO it would be more correct still to close the input stream immediately (instead of closing the queue), but I don't know whether the comment below on PipedInputStream.close() was deliberate or for convenience.

    /**
     * Closing a <tt>PipedInputStream</tt> has no effect. The methods in
     * this class can be called after the stream has been closed without
     * generating an <tt>IOException</tt>.
     * <p>
     */
Comment 11 Martin Oberhuber CLA 2011-05-23 08:21:57 EDT
Released the new patch for 3.3rc2 - thanks for the patch!