Sunday, February 5, 2017

Re: ConcurrentModificationException while debugging server-side code while client is making RPC calls

The exception says it all. Something is modifying the lst map while your clean method is pruning outdated objects.
You should learn about multithreading in Java. Use synchronized blocks or move to a synchronized map or a different structure to avoid these kind of problems, depending on the performance requirements of your application.
On Mon, 6 Feb 2017 at 05:35, Magnus <alpineblaster@gmail.com> wrote:
Hello,

when debugging my server-side code - and only when debugging it - I receive a ConcurrentModificationException during this method:

 private void clean ()
 {
  Set<Map.Entry<String,Observator>> set = lst.entrySet();
  Iterator<Map.Entry<String,Observator>> itr = set.iterator ();

  while (itr.hasNext ())
  {
   Map.Entry<String,Observator> e = itr.next();
   
   Observator o = e.getValue();
  
   if (o.isOutdated())
    itr.remove();
  }
 }

Note that this server-side code is called repeatedly by the client inside as an RPC call a Timer.

When I run the application inside eclipse with Project -> Run As -> Web Application (Super Dev Mode), no exception occurrs.
When I debug it inside eclipse with Project -> Debug As -> Web Application (Super Dev Mode) without any breakpoints, no exception occurrs.
But when I debug while having breakpoints, the exception is thrown...

It seems to have something to do with stepping through server-side code while the client is making RPC calls...

How do you deal with such problems?

Thanks
Magnus

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment