Bug 227572 - [rseterminal] RSE Terminal doesn't reset the "connected" state when the shell exits
Summary: [rseterminal] RSE Terminal doesn't reset the "connected" state when the shell...
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.0 M7   Edit
Assignee: Anna Dushistova CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: contributed
Depends on: 226764
Blocks: 228577
  Show dependency tree
 
Reported: 2008-04-17 11:23 EDT by Martin Oberhuber CLA
Modified: 2011-05-25 07:39 EDT (History)
7 users (show)

See Also:
mober.at+eclipse: review+


Attachments
patch to reset the connection state when shell exits (19.27 KB, patch)
2008-04-18 18:29 EDT, Yufen Kuo CLA
no flags Details | Diff
patch to reset the connection state when shell exits (25.33 KB, patch)
2008-04-21 15:40 EDT, Yufen Kuo CLA
no flags Details | Diff
patch to reset the connection state when shell exits (23.90 KB, patch)
2008-04-22 15:43 EDT, Yufen Kuo 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 2008-04-17 11:23:20 EDT
Open an RSE Terminal. Type exit in the shell. 
Connected status on the Terminal node below the subsystem is not reset.
Comment 1 Yufen Kuo CLA 2008-04-18 18:29:53 EDT
Created attachment 96675 [details]
patch to reset the connection state when shell exits
Comment 2 Yufen Kuo CLA 2008-04-18 18:31:49 EDT
I, Yu-Fen Kuo, declare that I developed attached code from scratch, without referencing any 3rd party materials except material licensed under the EPL. We are authorized by our employer to make this contribution under the EPL.
Comment 3 Yufen Kuo CLA 2008-04-21 15:40:20 EDT
Created attachment 96916 [details]
patch to reset the connection state when shell exits

updated patch which also handles the case when user try to disconnect from connection or subsystem. When the connection is no longer present, the terminal tab will be closed.
Comment 4 Martin Oberhuber CLA 2008-04-22 15:03:41 EDT
We shouldn't make an API change by adding a new event type to ISystemResourceChangeEvents for this. Can't you re-use any existing event? By looking at the event.source field you should know whether it's your subsystem or something else that fired the event.
Comment 5 Yufen Kuo CLA 2008-04-22 15:16:28 EDT
(In reply to comment #4)
> We shouldn't make an API change by adding a new event type to
> ISystemResourceChangeEvents for this. Can't you re-use any existing event? By
> looking at the event.source field you should know whether it's your subsystem
> or something else that fired the event.
> 

I could reuse the EVENT_COMMAND_SHELL_REMOVED event, but I thought it is just a bit cleaner to define a new event since this event is only fired from terminal.core plugin when a terminal is forced to be closed because of the connection lost. Let me know what you think. What I really like is some kind of event fired when connection is disconnected, but I couldn't find an event for it.
Comment 6 Martin Oberhuber CLA 2008-04-22 15:23:17 EDT
We should keep the API as small as possible.

Looking at the implementers of IConnectorService#internalDisconnect() you could try these:

fireCommunicationsEvent(CommunicationsEvent.BEFORE_DISCONNECT);
fireCommunicationsEvent(CommunicationsEvent.AFTER_DISCONNECT);

unfortunately I'm not 100% sure whether all connector services send these events under all circumstances (such as lost communications due to socket disconnect, or IOStream EOF for instance). It would be a bug if they don't send the event, and actually the code should be improved to make the event sending in the AbstractConnectorService already, but it's currently not the case... and changing that behavior would yet be another API change since we might end up with duplicate events being sent by extenders of AbstractConnectorService...

Have a look at it and decide whether you like it.
Comment 7 Yufen Kuo CLA 2008-04-22 15:43:09 EDT
Created attachment 97084 [details]
patch to reset the connection state when shell exits

changed the code to use EVENT_COMMAND_SHELL_REMOVED instead. TerminalServiceSubSystem already implements ICommunicationsListener.
Comment 8 Martin Oberhuber CLA 2008-04-23 21:33:31 EDT
Patch applied, 151 lines of code. Thanks!

I only improved the hashCode() method in TerminalElement. What I'd like to see now is get rid of unnecessary public API from subsystems.terminals.core and add Javadoc for the remaining public API classes as well as the API package.html.

In TerminalServiceSubSystem#addChild() and removeChild() it looks to me like some "synchronized" is missing. Right now, when two threads call the remove() method at almost the same time, it can happen that the communications listener is added twice; and in the removeChild() method, it looks like the communications listener cannot ever be removed because children is never going to be null. I also don't understand why adding the comm listener is necessary here, since it's already done in the initializeSubSystem() / uninitializeSubSystem() methods.

In general, I cannot see why you instantiate the "children" list lazily. Code gets much simpler if you just create an empty ArrayList in the constructor, and then test for children.size()==0.

cancelAllTerminals() has a e.printStackTrace(); which I don't like -- better log any errors to Eclipse rather than printing to stdout. RSETerminalConnectionThread also has one that should be removed.

subsystems.terminals.ssh could also live without an Activator, I'd think, since there is no dynamic activation required.

In TerminalViewer, you set a context help ID ("ucmd0000") but where is the associated context help in the user docs?

Apart from those things, the patch seems to work fine. I'm missing a "Launch Terminal" on the files tree but that's a different separate bug, right?