Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 548636

Summary: NPE in org.eclipse.rap.rwt.internal.protocol.ControlOperationHandler.createMouseEvent()
Product: [RT] RAP Reporter: Thomas Hendel <hendel>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ivan
Version: 3.9   
Target Milestone: 3.10   
Hardware: PC   
OS: Windows NT   
See Also: https://git.eclipse.org/r/144855
https://git.eclipse.org/c/rap/org.eclipse.rap.git/commit/?id=040b9851ecbfe009c2b013f55ba6d8810e2e3588
Whiteboard:

Description Thomas Hendel CLA 2019-06-25 10:14:13 EDT
org.eclipse.rap.rwt.internal.protocol.ControlOperationHandler.createMouseEvent() throws a NPE under following conditions:

- pointing device with more than the three common buttons (left, right and middle/wheel)
- user clicks such an additional button for example in a table widget
- Chromium-based browser (FF does not trigger a "mousedown" DOM event for additional buttons as it seems)

In this case rwt.remote.EventUtil.addButtonToProperties() has no matching switch-case (the button is "none") and thus it does not not set the "button" property at all.

When this event info reaches the server code, then ControlOperationHandler.createMouseEvent() expects that this property "button" is a) set and b) is an integer:
event.button = properties.get( EVENT_PARAM_BUTTON ).asInt();

Neither conditions are met.

This bug is not specific to RAP 3.9. Older versions show the same behavior.
Comment 1 Thomas Hendel CLA 2019-06-25 10:35:37 EDT
It seems that 

default:
  properties.button = 0;
  break;

in rwt.remote.EventUtil.addButtonToProperties() would do the trick - the Java-side can apparently deal with "button" set to 0
Comment 2 Ivan Furnadjiev CLA 2019-06-25 11:19:42 EDT
(In reply to Thomas Hendel from comment #1)
> It seems that 
> 
> default:
>   properties.button = 0;
>   break;
> 
> in rwt.remote.EventUtil.addButtonToProperties() would do the trick - the
> Java-side can apparently deal with "button" set to 0

Yes... Exactly.
Comment 3 Eclipse Genie CLA 2019-06-25 11:29:56 EDT
New Gerrit change created: https://git.eclipse.org/r/144855