Bug 400062 - [hovering][javadoc] Failure to access attached Javadoc should be shown to the user
Summary: [hovering][javadoc] Failure to access attached Javadoc should be shown to the...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.3 M6   Edit
Assignee: Martin Mathew CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 400060
  Show dependency tree
 
Reported: 2013-02-06 03:27 EST by Dani Megert CLA
Modified: 2013-03-12 11:41 EDT (History)
1 user (show)

See Also:
daniel_megert: review+


Attachments
Fix. (9.35 KB, patch)
2013-02-22 07:52 EST, Martin Mathew CLA
no flags Details | Diff
Fix and Testcase. (13.39 KB, patch)
2013-02-25 01:37 EST, Martin Mathew CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2013-02-06 03:27:57 EST
4.3 M5a.

Currently JDT Core ignores some exceptions and returns 'null'. This violates the API/Javadoc. Bug 400060 tracks that part. Once this is fixed we need to adjust our code to handle those exceptions and show them to the user without logging them.
Comment 1 Martin Mathew CLA 2013-02-22 03:54:26 EST
The exceptions ignored by JDT Core are
1. FileNotFoundException => thrown when the url provided is wrong,
2. UnKnownHostException => thrown when the network is down
3. SocketException => thrown when the site we are trying to access is down.
4. ProtocolException => similar to SocketException, thrown when there is some problem with the network.

Except the first exception the remaining are network related failure. So would the below be an appropriate message to be shown to the user requesting for the corresponding Javadoc:
"Note:The attached Javadoc could not be retrieved either due to network error or due to incorrect Javadoc URL."

If two possible reason for failure should not be shown in a single message, then we can filter the FNF and show message:
"Note:The attached Javadoc could not be retrieved due to incorrect Javadoc URL. Verify the Javadoc URL provided." and for others
"Note:The attached Javadoc could not be retrieved due to network error."

Dani kindly share your thoughts.
Comment 2 Dani Megert CLA 2013-02-22 06:41:46 EST
> Except the first exception the remaining are network related failure.

The first could have a similar symptom, e.g. when a mounted drive is not present.


> So would > the below be an appropriate message to be shown to the user 
> requesting for the corresponding Javadoc:
> "Note:The attached Javadoc could not be retrieved either due to network error 
> or due to incorrect Javadoc URL."

I would use a more generic wording:

The specified Javadoc location is either wrong or currently not accessible.
Comment 3 Martin Mathew CLA 2013-02-22 07:52:13 EST
Created attachment 227457 [details]
Fix.

If the attached Javadoc cannot be retrieved, then user is informed it via the Javadoc Hover and the Javadoc View. The message shown will be 
"Note: The attached Javadoc could not be retrieved as the specified Javadoc location is either wrong or currently not accessible.". 
The exception is not logged.
Comment 4 Dani Megert CLA 2013-02-22 12:40:27 EST
Patch is almost good. Just two issues:

- #handleFailedJavadocFetch does not belong into JavadocContentAccess2 but into 
  the same class where we already have the explanation helper method

- #handleFailedJavadocFetch should have CoreException as parameter type. If
  so, you don't need to check/cast to JME, but instead only check the code
  and the exception.
Comment 5 Dani Megert CLA 2013-02-23 02:01:37 EST
(In reply to comment #4)
> - #handleFailedJavadocFetch should have CoreException as parameter type. If
>   so, you don't need to check/cast to JME, but instead only check the code
>   and the exception.

One more thing: we must also check the plug-in ID, since the codes are not global but per plug-in. In addition, please add Javadoc to the new method.
Comment 6 Martin Mathew CLA 2013-02-25 01:37:15 EST
Created attachment 227521 [details]
Fix and Testcase.

1. #handleFailedJavadocFetch is moved to JavadocLocations and added Javadoc for this method.
2. #handleFailedJavadocFetch takes CoreException as the parameter and inside this method we check whether the exception is thrown from org.eclipse.jdt.core plugin.
3. Added a testcase in PackageJavadocTests to test the case when the Javadoc loctaion URL is wrong.

Dani, kindly verify.
Comment 7 Dani Megert CLA 2013-02-26 12:07:25 EST
There are still some issues:

1) missing @since tag
2) we write "Java element" not any other variant
3) the name of the new test has a typo
4) the new test fails until JDT Core has committed their change

In addition, we should not catch all IOExceptions (this was an oversight in my first review), but just those which we no longer silently catch.

I've committed your patch and then fixed those issues with http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=8113b4866b38554c893cd820c6ff60dbffcf9379
Comment 8 Dani Megert CLA 2013-03-12 11:41:46 EDT
Verified in I20130311-2000.
There was on regression, see bug 403036 for details.