http://docs.oracle.com/javase/7/docs/api/java/util/ConcurrentModificationException.html
http://stackoverflow.com/questions/5113016/getting-a-concurrentmodificationexception-thrown-when-removing-an-element-from-a

I am no java expert but seems calling remove of iterator safer approach.

But let me know what you want. I have few pull requests in the pipeline :)

Thx

Sent from my iPhone

> On Jan 26, 2014, at 2:11 PM, Vinod Kone <notifications@github.com> wrote:
> 
> In src/main/java/org/jenkinsci/plugins/mesos/JenkinsScheduler.java:
> 
> > @@ -133,8 +134,24 @@ public void terminateJenkinsSlave(String name) {
> >        LOGGER.info("Killing mesos task " + taskId);
> >        driver.killTask(taskId);
> >      } else {
> > -      LOGGER.warning("Asked to kill unknown mesos task " + taskId);
> > +        // This is handling the situation that a slave was provisioned but it never
> > +        // got scheduled because of resource scarcity and jenkins later tries to remove
> > +        // the offline slave but since it was not scheduled we have to remove it from
> > +        // the request queue. The method has been also synchronized because there is a race
> > +        // between this removal request from jenkins and a resource getting freed up in mesos
> > +        // resulting in scheduling the slave and resulting in orphaned task/slave not monitored
> > +        // by Jenkins.
> > +        for(Iterator<Request> li = requests.iterator(); li.hasNext();) {
> I prefer to not use iterators unless absolutely necessary, because it makes the code less readable. Would you mind reverting this?
> 
> —
> Reply to this email directly or view it on GitHub.