Bug 194898 - NPE when trying to do F5 Refresh on a Shell
Summary: NPE when trying to do F5 Refresh on a Shell
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 2.0.1   Edit
Assignee: Martin Oberhuber CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-29 07:09 EDT by Martin Oberhuber CLA
Modified: 2007-08-03 11:00 EDT (History)
0 users

See Also:


Attachments
Refresh shell without NPE (248.27 KB, image/jpeg)
2007-07-11 10:42 EDT, Rupen Mardirossian CLA
no flags Details
Patch fixing the issue (1.61 KB, patch)
2007-08-03 10:59 EDT, Martin Oberhuber CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Oberhuber CLA 2007-06-29 07:09:16 EDT
Local Shells > Launch Shell
Select the launched shell, press F5 (Refresh)

--> An error dialog pops up saying "Problem Occurred: Resource Changed... (Time of error: [...] Reason: Check the details

Error log shows an "Unhandled Event Loop Exception" with following cause:
Caused by: java.lang.NullPointerException
	at org.eclipse.rse.ui.internal.model.SystemRegistry.findFilterReferencesFor(SystemRegistry.java:2751)
	at org.eclipse.rse.internal.ui.view.SystemView$ResourceChangedJob.runInUIThread(SystemView.java:2109)
	at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:94)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)


-----------Enter bugs above this line-----------
TM 2.0 Testing
installation : eclipse-SDK-3.3
RSE install  : workspace FREEZE R2_0
java.runtime : Sun 1.6.0_01-b06
os.name:     : Windows XP 5.1, Service Pack 1
------------------------------------------------
systemtype   : Windows-local
------------------------------------------------
Comment 1 Rupen Mardirossian CLA 2007-07-11 10:42:52 EDT
Created attachment 73545 [details]
Refresh shell without NPE

After some investigation.  When hitting F5 on the shell to refresh a null value is returned for the filterpoolreferencemanager as seen below:

line of code where exception is found; SystemRegistry [line: 2843] - findFilterReferencesFor(Object, ISubSystem, boolean):

ISystemFilterReference[] refs = subsystem.getFilterPoolReferenceManager().getSystemFilterReferences(subsystem);

Now after checking to see if the value is null before executing the line above, simply has the method return an empty array.  No NPE is thrown but I have experimented with the shell and executed some simple bash commands then refreshed again.  What I got as a result is the attachment.

Another point I would like to add, what should happen when the F5 key is hit on the shell?  Would it be better if the key was disabled to the user?
Comment 2 Martin Oberhuber CLA 2007-07-11 10:56:09 EDT
I cannot see how you would disable a key? - In the context menu for shells, F5 is not there. Or did you think that the Refresh key would just not do anything in case the selection is a local shell?
Comment 3 Rupen Mardirossian CLA 2007-07-16 17:09:38 EDT
Sorry... when I mentioned disabling I meant that the functionality of the F5 key would just do nothing.  At this point it seems to be firing of the wrong event if I am not mistaken in which it is attempting to retrieve a filterPoolReferenceManager for a shell throwing a NPE.
Comment 4 Martin Oberhuber CLA 2007-07-18 09:42:39 EDT
Yes the expected result of hitting F5 on a shell node in the RSE Tree is unclear -- what should be refreshed anyways? There is nothing to refresh.

Personally I'm not sure how you could hook in a handler for the F5 key that would do nothing for shells specifically, especially if you have a multiselect that happens to include a shell.

I think that both should be fixed:
  * The symptom - since by our API we cannot avoid any external plugin firing 
    a refresh event against a shell, we should not NPE in that case.
  * The root cause - avoiding the refresh event in our own code seems a good
    idea.

If we cannot avoid the event for whatever reasons (e.g. as I mentioned above) it will not be a problem if the NPE is avoided in the event handler.
Comment 5 Martin Oberhuber CLA 2007-08-03 08:51:03 EDT
Seen the same problem when doing F5 on a dstore or ssh shell.

It's not just an NPE being logged to the log, but an actual dialog shows up. It's annoying because when I type "exit" in the shell, the "running shell" overlay in the SystemView is not updated; so I pressed F5 but ended up in the NPE.
Comment 6 Martin Oberhuber CLA 2007-08-03 10:33:02 EDT
The problem must be the way how the refresh event is created.

Because the fix for bug 197848 also sends an EVENT_REFRESH with the IServiceCommandShell as source, and the NPE is not seen with that one. 
So the event handling in SystemView seems ok, but an incorrect event 
appears to be sent.
Comment 7 Martin Oberhuber CLA 2007-08-03 10:59:47 EDT
Created attachment 75339 [details]
Patch fixing the issue

Attached patch fixes the issue.

Problem was that when a subsystemConfiguration does not support filters, it has no FilterReferenceManager.  Consequently, when SystemRegistryis asked for the filterReferences, it must not try finding them if the subsystemConfiguration is known not to have filters.

The fix is a simple one-liner; I'm not sure why Rupen got the remote output printed into the SystemView on his version of the fix, but mine version works fine.
Comment 8 Martin Oberhuber CLA 2007-08-03 11:00:40 EDT
Patch committed:

[194898] Avoid NPE when doing EVENT_REFRESH_REMOTE on a subsys without filters
   SystemRegistry.java