Lesson #1: InvalidDnDOperationException Ruins Sanity

×

This post was originally published in 2009
It may contain stale & outdated information. Or it may have grown more awesome with age, like the author.

A friend with whom I am currently working on a programming contract called me today to tell me that the latest build wasn’t working. At all.

This irritated and confused me, as I hadn’t worked on that particular project for a week or so, and couldn’t remember having any issues with it.

I booted into Windows (I use Linux mostly), downloaded Eclipse and imported the project.

Sure enough:

java.awt.dnd.InvalidDnDOperationException: Drag and drop in progress
	at sun.awt.dnd.SunDragSourceContextPeer.setDragDropInProgress(Unknown Source)
	at java.awt.dnd.DragSource.startDrag(Unknown Source)

This error had attacked me before, but a quick investigation revealed that the issue was different this time. Joyous news.

I poked about in the (too many) classes that make up this project, but discovered nothing of use.

After some fruitless Googling, it occurred to me that during the great Refactoring Storm of August, I may have changed some of the DragGestureRecognizers’ DnDConstants to ACTION_COPY instead of ACTION_COPY_OR_MOVE.

A short, smaller storm of refactoring esued, during which all ACTION_COPY_OR_MOVE DnDConstants were changed to ACTION_COPY.

Why was this an issue at all? I was using evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); to accept the drops, which I guess I must have assumed would accept an ACTION_COPY drop. Seemed to in Ubuntu, anyway. Maybe the Windows JRE is more strict (re: mental)?

Why this issue hid itself until now, I don’t know. Perhaps Ubuntu just likes me more.

Lesson: test software on the target system BEFORE giving it to your team-members.

No comments | Trackback