Bug 210555 - [regression][api] NPE when deleting a file on SSH
Summary: [regression][api] NPE when deleting a file on SSH
Status: CLOSED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 3.0 M4   Edit
Assignee: Xuan Chen CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: api
Depends on: 199871
Blocks:
  Show dependency tree
 
Reported: 2007-11-21 12:23 EST by Martin Oberhuber CLA
Modified: 2009-06-17 13:28 EDT (History)
0 users

See Also:


Attachments
Fix for the NPE (3.65 KB, patch)
2007-11-27 10:03 EST, Xuan Chen 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-11-21 12:23:30 EST
Connect to remote SSH Only host.
Select a file, right-click > delete
--> Delete fails due to an NPE in AbstractFileService.deleteBatch()

The problem is that in the course of changes for TM 3.0, deleteBatch() was changed and now includes this code:
    SystemMessage msg = getMessage("RSEF1315");   //$NON-NLS-1$

but the default implementation of getMessage() just returns null, so this code is bound to fail.

I think the right solution is to add the following method to IFileService and AbstractFileService:
    setMessageProvider(IMessageProvider m)
and have this method called right after creating the service. Store the provider in AbstractFileService just like for Local. Same should be done for the Process service -- see also bug 199871 where this came up originally for Local.

This change is backward compatible because IFileService class Javadoc says that clients must extend AbstractFileService rather than implementing IFileService directly.


-----------Enter bugs above this line-----------
TM 3.0M3 Testing
installation : eclipse-SDK-3.4M3-win32, cdt-5.0.0M3, emf-sdo-xsd-2.4.0M3
     Download RSE-I20071108-0100: RSE-SDK,tests,discovery,terminal,remotecdt
java.runtime : Sun 1.5.0_11-b03, mixed mode
os.name:     : Windows XP 5.1, Service Pack 1
------------------------------------------------
systemtype   : SSH Only
targetos1    : Linux RHEL4, Sun 1.5.0_11
------------------------------------------------
Comment 1 Martin Oberhuber CLA 2007-11-21 12:24:39 EST
Here is the NPE for reference:

java.lang.NullPointerException
	at org.eclipse.rse.services.files.AbstractFileService.deleteBatch(AbstractFileService.java:134)
	at org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem.deleteBatch(FileServiceSubSystem.java:831)
	at org.eclipse.rse.internal.files.ui.view.SystemViewRemoteFileAdapter.doDeleteBatch(SystemViewRemoteFileAdapter.java:2556)
	at org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction$DeleteJob.run(SystemCommonDeleteAction.java:148)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Comment 2 David McKnight CLA 2007-11-26 13:15:13 EST
Xuan, I see that you added the getMessage("RSEF1315") call in when you worked on bug 160775.  Looking at the IBM RSE code, we used to call getPluginMessage(ISystemMessages.FILEMSG_DELETING) so I can see you were attempting to port that.  I think, for this defect, we need to get rid of this getMessage() call so that we don't have a major bug on our hands.

Regarding the IMessageProvider idea, I think we're looking at an enhancement along with some more refactoring that ought to be carried out via a different defect.  If we tried to fix this defect by introducing the suggested approach, there are a number of issues we would face.

The message required here is stored in systemmessages.xml which is part of the rse.ui plugin.  Rse.ui is certainly not the right place to be storing file-specific messages so we would need to consider dividing up these messages to go in the appropriate plugins.  We could still get the job done, without dividing up the messages, however, that leaves stuck with a service that uses message ids for messages that are defined outside of the service's plugin and it's dependencies.  

As an aside, the use of SystemMessage versus other types of messages is still, in my mind, a bit questionable - at some point, are we going to  try to change to a more standard message format?
   
Comment 3 Xuan Chen CLA 2007-11-26 17:11:21 EST
To fix this particular problem (NPE), I think we probably need to provide the deleteBatch() method in LocalFileService to override the default implementation of deleteBatch() in AbstractFileService. 
We may need to open a separate bug to discuss the message processing change mentioned in this bug.
Comment 4 Martin Oberhuber CLA 2007-11-27 07:20:53 EST
I've always wanted to get rid of SystemMessages since nobody in Open Source really understands them. A separate bug for this task seems a good idea.

In the short term, I need this NPE regression fixed soon, best for the next I-build. The suggestion outlined in the bug description seemed a proper short-term workaround for me.
Comment 5 Xuan Chen CLA 2007-11-27 10:03:53 EST
Created attachment 83866 [details]
Fix for the NPE
Comment 6 Xuan Chen CLA 2007-11-27 10:04:57 EST
I've committed the changes to cvs.
Comment 7 Xuan Chen CLA 2007-11-27 10:12:35 EST
Bug #211067 has been opened for message retrieving enhancement.
Comment 8 Xuan Chen CLA 2008-01-03 12:02:47 EST
Verified in M4 I20080103-0700 driver.
Comment 9 Xuan Chen CLA 2009-06-17 13:28:05 EDT
Close since it is fixed.