Bug 495064 - Wrong use of defaultHandler in EGit UI plugin.xml leading to CCE and other exceptions.
Summary: Wrong use of defaultHandler in EGit UI plugin.xml leading to CCE and other ex...
Status: NEW
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 394365 511636 511637 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-05-31 15:26 EDT by EPP Error Reports CLA
Modified: 2019-11-16 11:36 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description EPP Error Reports CLA 2016-05-31 15:26:19 EDT
The following problem was reported via the automated error reporting:

Message: Unhandled event loop exception
java.lang.ClassCastException: org.eclipse.wst.sse.ui.StructuredTextEditor cannot be cast to org.eclipse.egit.ui.internal.repository.RepositoriesView
    at org.eclipse.egit.ui.internal.repository.tree.command.RepositoriesViewCommandHandler.getView(RepositoriesViewCommandHandler.java:54)
    at org.eclipse.egit.ui.internal.repository.tree.command.LinkWithSelectionCommand.execute(LinkWithSelectionCommand.java:30)
    at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:295)
    at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
    at sun.reflect.GeneratedMethodAccessor.invoke(null:-1)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(null:-1)
    at java.lang.reflect.Method.invoke(null:-1)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)



Bundles:
| org.eclipse.e4.core.di | 1.5.0.v20150421-2214 | 1.6.0.v20160319-0612 |
| org.eclipse.egit.ui | 4.0.0.201505260635-rc2 | 4.4.0.201605041135-m1 |
| org.eclipse.ui | 3.107.0.v20150507-1945 | 3.108.0.v20160505-1310 |

Operating Systems:
| Linux | 3.13.0 | 3.19.0 |
| MacOSX | 10.10.5 | 10.11.4 |
| Windows | 5.1.0 | 10.0.0 |


The above information is a snapshot of the collected data. Visit https://dev.eclipse.org/recommenders/committers/aeri/v2/#!/problems/551bf2ace4b026254ee000c6 for the latest data.
Comment 1 Thomas Wolf CLA 2016-05-31 15:51:47 EDT
Many of the EGit commands specify a default handler. This can be invoked via QuickAccess even when the handler is not active or when the view it belongs to is not active.

This leads to a variety of exceptions: have some git views open (for instance, repositories view, project/package explorer with EGit-managed projects, ...) an have an editor with some file open. Set focus/activate the editor (place the text caret somewhere in the file). Now let's have some fun with Quick Access:

* choose "Link with Selection" in Quick Access: that'll give you the CCE in the original bug description, possibly with another editor class).
* choose "Refresh" in Quick Access: ditto

"Open in Editor":

java.lang.IndexOutOfBoundsException: Index: 0
	at java.util.Collections$EmptyList.get(Collections.java:4454)
	at org.eclipse.egit.ui.internal.repository.tree.command.OpenInEditorCommand.execute(OpenInEditorCommand.java:27)

"Change Credentials":

java.lang.IndexOutOfBoundsException: Index: 0
	at java.util.Collections$EmptyList.get(Collections.java:4454)
	at org.eclipse.egit.ui.internal.repository.tree.command.ChangeCredentialsCommand.execute(ChangeCredentialsCommand.java:31)

"Compare with HEAD Revision":

org.eclipse.core.commands.NotEnabledException: Trying to execute the disabled command org.eclipse.egit.ui.team.CompareWithHead
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:484)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:486)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommand(LegacyHandlerService.java:343)
	at org.eclipse.ui.internal.quickaccess.CommandElement.execute(CommandElement.java:72)

"Remove from index": ditto

and so on...

This needs to be cleaned up:

* Most handlers should be applicable only in a particular view, especially those from the repositoris view.
* EGit sometimes uses command visibility for hiding inapplicable commands without setting a corresponding activeWhen on the handler. Thus the handler is active even when it should not be. Not a problem as long as only menus are used, but through Quick Access such handlers can still be invoked. Handlers should have corresponding "activeWhen" clauses.
* The handlers that indeed might make good candidates for default handlers must not assume that the active part is a particular (EGit) view, or that a selection is of a particular king or even exists.
Comment 2 Eclipse Genie CLA 2016-06-01 17:42:33 EDT
New Gerrit change created: https://git.eclipse.org/r/74327
Comment 3 Eclipse Genie CLA 2016-07-02 14:11:59 EDT
Gerrit change https://git.eclipse.org/r/74327 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=96fe255d7820f6c35177f1c9727d3e2db11e4356
Comment 4 Eclipse Genie CLA 2016-08-15 17:45:45 EDT
New Gerrit change created: https://git.eclipse.org/r/79093
Comment 5 Eclipse Genie CLA 2016-09-05 01:20:50 EDT
Gerrit change https://git.eclipse.org/r/79093 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=2fe0d796fccce3247870a957a78d4e75bac474fa
Comment 6 Eclipse Genie CLA 2016-10-02 17:07:14 EDT
New Gerrit change created: https://git.eclipse.org/r/82338
Comment 7 Eclipse Genie CLA 2016-10-14 03:30:06 EDT
Gerrit change https://git.eclipse.org/r/82338 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=8e7cd94da8d072839eb861e99e76bc49a3c4eeac
Comment 8 Eclipse Genie CLA 2016-10-16 04:34:26 EDT
New Gerrit change created: https://git.eclipse.org/r/83313
Comment 9 Eclipse Genie CLA 2016-10-18 18:50:55 EDT
Gerrit change https://git.eclipse.org/r/83313 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=f9bf65864c70e585bf1bcfa0149195714e4441a4
Comment 10 Eclipse Genie CLA 2016-11-03 15:47:26 EDT
New Gerrit change created: https://git.eclipse.org/r/84439
Comment 11 Eclipse Genie CLA 2016-11-03 15:47:34 EDT
New Gerrit change created: https://git.eclipse.org/r/84438
Comment 12 Eclipse Genie CLA 2016-11-03 15:47:36 EDT
New Gerrit change created: https://git.eclipse.org/r/84437
Comment 13 Eclipse Genie CLA 2016-12-03 17:48:13 EST
Gerrit change https://git.eclipse.org/r/84438 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=a44e7448f1f5a036223b57432d8866c49412dc81
Comment 14 Eclipse Genie CLA 2016-12-03 17:48:19 EST
Gerrit change https://git.eclipse.org/r/84437 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=01bda60c5937b0cfd272f4b21f679be6c45c9a00
Comment 15 Eclipse Genie CLA 2016-12-03 17:48:22 EST
Gerrit change https://git.eclipse.org/r/84439 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=b979970e6d36e7b728f5ca7f39056e8096925d7e
Comment 16 Eclipse Genie CLA 2016-12-28 06:39:53 EST
New Gerrit change created: https://git.eclipse.org/r/87770
Comment 17 Eclipse Genie CLA 2017-01-05 08:50:20 EST
Gerrit change https://git.eclipse.org/r/87770 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=1c85569eb900178ef182dad3ee73aed5ee509db7
Comment 18 Thomas Wolf CLA 2017-02-03 16:47:08 EST
*** Bug 511636 has been marked as a duplicate of this bug. ***
Comment 19 Thomas Wolf CLA 2017-02-03 16:47:30 EST
*** Bug 511637 has been marked as a duplicate of this bug. ***
Comment 20 Eclipse Genie CLA 2017-04-20 09:52:42 EDT
New Gerrit change created: https://git.eclipse.org/r/95382
Comment 21 Eclipse Genie CLA 2017-04-20 18:17:18 EDT
Gerrit change https://git.eclipse.org/r/95382 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=ee406cbdd30b00730ce1aeae42deb735c56cb523
Comment 22 Eclipse Genie CLA 2017-04-21 05:28:11 EDT
New Gerrit change created: https://git.eclipse.org/r/95454
Comment 23 Eclipse Genie CLA 2017-05-05 06:28:18 EDT
Gerrit change https://git.eclipse.org/r/95454 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=55e1dadd03534212e829c6bea6398b8224974784
Comment 24 Eclipse Genie CLA 2017-05-15 15:55:31 EDT
New Gerrit change created: https://git.eclipse.org/r/97142
Comment 25 Eclipse Genie CLA 2017-05-18 04:54:55 EDT
Gerrit change https://git.eclipse.org/r/97142 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=6c1191dbf2da75f92b0d75d7bdb7124956729144
Comment 26 Thomas Wolf CLA 2017-06-21 05:45:55 EDT
*** Bug 394365 has been marked as a duplicate of this bug. ***
Comment 27 Eclipse Genie CLA 2017-08-02 15:16:53 EDT
New Gerrit change created: https://git.eclipse.org/r/102414
Comment 28 Eclipse Genie CLA 2017-10-17 02:04:32 EDT
Gerrit change https://git.eclipse.org/r/102414 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=a0e6c966acaa71713e0557a7a172c75b2197c9f6
Comment 29 Dani Megert CLA 2017-11-02 09:45:43 EDT
(In reply to Eclipse Genie from comment #28)
> Gerrit change https://git.eclipse.org/r/102414 was merged to [master].
> Commit:
> http://git.eclipse.org/c/egit/egit.git/commit/?id=a0e6c966acaa71713e0557a7a172c75b2197c9f6
 

Thomas, this added the following entry to plugin.properties:
    CompareWithHeadCommand.name = Compare commit with HEAD
however, the same key is already used and present as
    CompareWithHeadCommand.name = Compare with HEAD Revision
since 2010.
Comment 30 Eclipse Genie CLA 2017-11-04 08:20:09 EDT
New Gerrit change created: https://git.eclipse.org/r/111008
Comment 31 Thomas Wolf CLA 2017-11-04 08:22:15 EDT
(In reply to Dani Megert from comment #29)
> Thomas, this added the following entry to plugin.properties:
>     CompareWithHeadCommand.name = Compare commit with HEAD
> however, the same key is already used and present as
>     CompareWithHeadCommand.name = Compare with HEAD Revision
> since 2010.

Thanks for pointing this out. That plugin.properties is a mess. One of these days I'll have to sort the entries alphabetically.

https://git.eclipse.org/r/111008 removes the duplicate.
Comment 32 Eclipse Genie CLA 2017-11-04 12:44:24 EDT
Gerrit change https://git.eclipse.org/r/111008 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=ea4b5eebc3e1c8e2699cdbccb33b1c7ec95bc6dc
Comment 33 Dani Megert CLA 2017-11-08 12:19:38 EST
(In reply to Thomas Wolf from comment #31)
> (In reply to Dani Megert from comment #29)
> > Thomas, this added the following entry to plugin.properties:
> >     CompareWithHeadCommand.name = Compare commit with HEAD
> > however, the same key is already used and present as
> >     CompareWithHeadCommand.name = Compare with HEAD Revision
> > since 2010.
> 
> Thanks for pointing this out. That plugin.properties is a mess. One of these
> days I'll have to sort the entries alphabetically.

Maybe your time would be spent more usefully if you provided a Gerrit change for bug 232034 :-).


> https://git.eclipse.org/r/111008 removes the duplicate.

Verified in master.
Comment 34 Eclipse Genie CLA 2019-03-14 15:21:56 EDT
New Gerrit change created: https://git.eclipse.org/r/138779
Comment 35 Eclipse Genie CLA 2019-03-22 09:57:49 EDT
Gerrit change https://git.eclipse.org/r/138779 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=97c96f88eee2178d5205cb27d6a08c6a74683cb6
Comment 36 Eclipse Genie CLA 2019-11-04 05:36:43 EST
New Gerrit change created: https://git.eclipse.org/r/151940
Comment 37 Eclipse Genie CLA 2019-11-16 11:36:54 EST
Gerrit change https://git.eclipse.org/r/151940 was merged to [master].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=0cff7b2540d68ee4d1d54a423993177e5c3e27a4