Link to home
Start Free TrialLog in
Avatar of gpman65
gpman65

asked on

StackOverflowError

A customer is receiving a StackOverflowError with a 1024 lines of the following:
at java.awt.AWTEventMulticaster.mouseMoved(AWTEventMulticaster.java:312)

This happens over and over.

This is being reported by a customer and I am at a loss as to which component is causing it and I can't seem to duplicate it myself.  What might be causing this or what should I be looking for?

Thanks.
Avatar of stachenov
stachenov

Usually this happens because of infinite recursion, but I can't think of any possible way to cause infinite recursion with this class. Well, except for subclassing it and passing "this" to the superclass constructor, but that's not something easily done by mistake. When used in normal way, add() functions create nodes at the root of the listener tree, and there is no way to change deeper nodes to point above themselves, thus creating an event loop.

Perhaps it is not an infinite recursion, but just too much listeners in the tree? Although it is quite hard to imagine having that many listeners.

Or it could be that one of the listeners calls the root listener recursively. But then that particular listener would turn up in the stack trace as well, which apparently isn't happening. Of course it is possible that it also adds another listener at the top of the tree and only then calls the (new) top listener. This sounds too crazy to be true, but it would lead to the tree constantly growing until it gets too large.

Sorry for being so vague, but it is hard to say more without more details about how multicasters are used.
ASKER CERTIFIED SOLUTION
Avatar of stachenov
stachenov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Are you running it in the same version of Java as your customer?
Regarding my last comment: even if the order of the listeners is reversed, you'll only see the listener that was called last, and only if you're lucky enough. Still, it is better than nothing I guess.
Avatar of gpman65

ASKER

I found where I was adding the same listener over and over again.  I would not have expected a stackoverflow from this, but that does seem to be the cause.  Thanks.