fredsa / gwt-dnd

Library providing easy to use mouse or touch based drag-and-drop capabilities to GWT
42 stars 41 forks source link

NPE in PickupDragController.dragEnd() with null context.dropController #194

Open cueman opened 8 years ago

cueman commented 8 years ago

In PickupDragController, lots of code is careful to check whether context.dropController is null or not. On dragStart(), context.dropController can be set, but is sometimes left null.

dragMove() should set context.dropController, so it ought to be non-null by the time dragEnd() is called. However, I'm finding in production that there are null pointer exceptions that I've traced back to context.dropController being null when dragEnd() is called.

This happens because PickupDragController.dragEnd() always calls a method on context.dropController, even if it is null.

Looking at the code, it appears to me that context.dropController will always be set to a non-null value by dragMove(). This suggests that sometimes dragMove() isn't being called. I've not been able to replicate this, but I've seen exceptions that show it happens infrequently across my users, but often enough to be a problem. Perhaps this can happen when the computer or browser is under heavy load.

Perhaps the solution is simply to make PickupDragController.dragEnd() check whether context.dropController is null or not before calling methods on it.