Bug 204710 - [apidoc] Docs should specify that File service can query home directory even if not connected
Summary: [apidoc] Docs should specify that File service can query home directory even ...
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P5 trivial (vote)
Target Milestone: 2.0.1   Edit
Assignee: Martin Oberhuber CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 203490 227135
  Show dependency tree
 
Reported: 2007-09-26 13:30 EDT by Martin Oberhuber CLA
Modified: 2009-03-19 19:19 EDT (History)
0 users

See Also:
dmcknigh: review+


Attachments
Patch updating IFileService Javadoc (2.00 KB, patch)
2007-09-26 13:43 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-26 13:30:49 EDT
By investigating bug 203490, I found that in the following case, IFileService.getUserHome() is called before the connection is connected, so the home directory is likely to return null:

* Launch RSE, ensure no connection is connected
* Expand an SSH connection
* Select the "My Home" filter
* Right-click > Refresh

Refresh of the filter issues a getUserHome() call even if the connection is
not yet connected -- this was the reason for the NPE in bug 203490.

I'm not sure if fixing this issue is worth it, since returning null as result of getUserHome() seems to do the right thing.

-----------Enter bugs above this line-----------
TM 2.0.1 Testing
installation : eclipse-SDK-3.3 (I20070625-1500), cdt-4.0.0, emf-2.3.0
RSE install  : Download RSE-2.0.1RC1: RSE-SDK,examples,tests,discovery,terminal
java.runtime : Sun 1.6.0_01-b06
os.name:     : Windows XP 5.1, Service Pack 1
------------------------------------------------
systemtype   : Linux SSH-Only
------------------------------------------------
Comment 1 Martin Oberhuber CLA 2007-09-26 13:43:59 EDT
Created attachment 79223 [details]
Patch updating IFileService Javadoc

It turns out that it is hard for IFileService implementers what to return when they are asked for the home directory before they are connected.

* They cannot auto-connect because credentials are not yet known
* They cannot just dream up any default like "/" because it might change after
  being connected, so the results of expanding the "My Home" filter later might
  yield wrong results

It turns out that returning null is the right thing, it will instruct the FileService to try again later.

Returning null should be reserved for this case (there is a concept of a home directory, but it is not yet known). Clients which do not ever have a concept of a home directory should return the root directory or any other "useful" directory handle instead; the only precondition should be that this handle is "stable", so it always refers to the same remote object (which should exist, but does not necessarily need to -- resolving "My Home" would throw an error in that case).

Attached patch updates Javadoc to capture these thoughts. It might be a good idea to come up with another well-known default (e.g. IHostFile with getAbsolutePath()=="") to indicate that an IFileService does not have any concept of a home directory; but that's reserved for the future.
Essentially, returning null should ask the client to try again later. We could also reserve
Comment 2 Martin Oberhuber CLA 2007-09-26 14:04:58 EDT
Dave what do you think - is it normal to query the home directory while not yet connected? Does it seem right to explicitly allow returning null in the Javadoc?
Comment 3 David McKnight CLA 2007-09-26 14:26:21 EDT
Obviously we can't query the home dir while not connected.  Allowing null to be returned seems like the right solution.  At least the consumer of the call would not get an incorrect answer.
Comment 4 Martin Oberhuber CLA 2007-09-26 14:34:18 EDT
Updating Javadoc now seems right for 2.0.1 since we are just documenting what the code already did, so we are clarifying current behavior.

Patch committed:
[204710] Update Javadoc to mention that getUserHome() may return null
   IFileService   1.13
Comment 5 Martin Oberhuber CLA 2007-09-26 14:35:27 EDT
Updated summary to indicate what we did -- old value was:
[refresh][files] File service queries home directory even if not connected