Bug 203490 - [ssh] NPE in SftpFileService.getUserHome()
Summary: [ssh] NPE in SftpFileService.getUserHome()
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Linux-GTK
: P3 minor (vote)
Target Milestone: 2.0.1   Edit
Assignee: Martin Oberhuber CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
Depends on: 204710
Blocks: 227135
  Show dependency tree
 
Reported: 2007-09-14 16:35 EDT by Martin Oberhuber CLA
Modified: 2009-03-19 19:19 EDT (History)
4 users (show)

See Also:
xuanchen: review+


Attachments
Patch fixing the issue (2.35 KB, patch)
2007-09-14 16:39 EDT, Martin Oberhuber CLA
no flags Details | Diff
New patch (overriding the old one) (3.93 KB, patch)
2007-09-26 14:44 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-09-14 16:35:14 EDT
Not sure how and why, but Uwe found this NPE in his Log:

!ENTRY org.eclipse.rse.ui 4 0 2007-09-04 18:58:12.443
!MESSAGE Exception resolving filters' strings 
!STACK 0
java.lang.NullPointerException
	at org.eclipse.rse.internal.services.ssh.files.SftpFileService.getUserHome(SftpFileService.java:576)
	at org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem.getUserHome(FileServiceSubSystem.java:263)
	at org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem.getRemoteFileObject(FileServiceSubSystem.java:186)
	at org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem.internalResolveFilterString(RemoteFileSubSystem.java:624)
	at org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem.internalResolveFilterStrings(RemoteFileSubSystem.java:451)
	at org.eclipse.rse.core.subsystems.SubSystem.resolveFilterStrings(SubSystem.java:2067)
	at org.eclipse.rse.internal.ui.view.SystemViewFilterReferenceAdapter.internalGetChildren(SystemViewFilterReferenceAdapter.java:416)
	at org.eclipse.rse.internal.ui.view.SystemViewFilterReferenceAdapter.getChildren(SystemViewFilterReferenceAdapter.java:257)
	at org.eclipse.rse.internal.ui.view.SystemViewFilterReferenceAdapter.getChildren(SystemViewFilterReferenceAdapter.java:265)
	at org.eclipse.rse.ui.operations.SystemFetchOperation.execute(SystemFetchOperation.java:265)
	at org.eclipse.rse.ui.operations.SystemFetchOperation.run(SystemFetchOperation.java:128)
	at org.eclipse.rse.ui.view.AbstractSystemViewAdapter.fetchDeferredChildren(AbstractSystemViewAdapter.java:1970)
	at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:196)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)



-----------Enter bugs above this line-----------
TM 2.0.1 Testing
installation : eclipse-SDK-3.3-linux-gtk-x86_64, emf-sdo-xsd-SDK-2.3.0
     Download RSE-2.0.1RC1: RSE-SDK,examples,tests,discovery,terminal
java.runtime : Sun 1.5.0_12-b04  64-bit Server VM, mixed mode
os.name:     : OpenSUSE 10.2 64-bit
uname        : Linux osgiliath 2.6.18.8-0.5-default x86_64 GNU/Linux
------------------------------------------------
systemtype   : Linux-local / Unix-dstore (RExec) / FTP / Ssh
targetos1    : Linux RHEL4, Sun 1.5.0_11
targetos2    : Windows XP SP1, Sun 1.4.2_13
targetos3    : Solaris-sparc 5.9, Sun 1.4.2_05
targetuname  : SunOS szg-anar 5.9 Generic_118558-06 sun4u sparc SUNW,Sun-Blade-1500
------------------------------------------------
Comment 1 Martin Oberhuber CLA 2007-09-14 16:39:20 EDT
Created attachment 78471 [details]
Patch fixing the issue

Attached patch fixes the issue.
Comment 2 Martin Oberhuber CLA 2007-09-14 16:40:38 EDT
The fix is simple, though I'm not sure why fUserHome is null here -- perhaps pwd() returned null for the given connection. Anyways, returning the root folder in that case seems the right thing to do.

DaveM can you please review this?
Comment 3 David McKnight CLA 2007-09-14 16:48:48 EDT
I'm not sure why pwd would have returned null but at least this resolves the issue.
Comment 4 Martin Oberhuber CLA 2007-09-14 16:52:17 EDT
Patch committed.
Comment 5 Martin Oberhuber CLA 2007-09-26 14:42:48 EDT
Original patch was not good because if user chose "Refresh" on the "My Home" filter while not connected, the fallback (home=="/") would be activated and not changed later. Users would not get access to their real home directory.

As per bug 204710, it is better to return null in case we are not yet connected.
Comment 6 Martin Oberhuber CLA 2007-09-26 14:44:01 EDT
Created attachment 79228 [details]
New patch (overriding the old one)

Attached new patch fixes the issue properly for both Sftp and FTP, and also makes a minor performance improvement to SftpFileService by marking the inner classes used for Streams "static".

Dave can you please review this?
Comment 7 Xuan Chen CLA 2007-09-26 17:09:08 EDT
The fix looks good.

I ran the following scenarios:

Create ssh connection.  Before connect, refresh the My Home filter.  Then expand the My Home filter. Got logon dialog.  Logon.  My home directory displayed correctly.

Repeat it for FTP connection. Things are fine too.
Comment 8 Martin Oberhuber CLA 2007-09-26 17:15:52 EDT
Patch committed:

[203490] Fix NPE in SftpService.getUserHome()
   SftpFileService   1.21
   FTPService 1.39