[GitHub] ant issue #81: Fix rare ConcurrentModificationException when running with Pa...

2018-12-11 Thread mharmer
Github user mharmer commented on the issue:

https://github.com/apache/ant/pull/81
  
@jaikiran: "Mark Harmer" will work, thanks.


---

-
To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
For additional commands, e-mail: dev-h...@ant.apache.org



[GitHub] ant issue #81: Fix rare ConcurrentModificationException when running with Pa...

2018-12-11 Thread mharmer
Github user mharmer commented on the issue:

https://github.com/apache/ant/pull/81
  
@jaikiran I think the test does exhibit the multithreaded scenario, I ran 
it prior to the `Project` changes to ensure it did fail. My Java is a bit 
rusty, but I believe the 2 separate `ExecutorService`'s created run 
concurrently. My only concern is it's possible it may not catch the issue in 
the future as a regression test due to the non-determinism, as well as the 
somewhat arbitrary loop count and extended time taken to run the test (<100 
milliseconds currently, but overall these types of tests tend to add up).


---

-
To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
For additional commands, e-mail: dev-h...@ant.apache.org



[GitHub] ant issue #81: Fix rare ConcurrentModificationException when running with Pa...

2018-12-11 Thread mharmer
Github user mharmer commented on the issue:

https://github.com/apache/ant/pull/81
  
I have a test case I wrote as well, however I was hesitant on adding it 
since it dealt with non-deterministic behavior of trying to reproduce the race 
condition. If it's desired I can add it, it's basically this:

```
/**
 * This test ensures that when requesting Project.getCopyOfReferences a
 * ConcurrentModificationException isn't thrown.
 *
 * ExecutorService is used so Exceptions are rethrown from their 
executors
 * and caught by JUnit as an error.
 */
@Test
public void testMultithreadedGetReferences() throws Exception {
final ExecutorService es1 = Executors.newSingleThreadExecutor();
final Future getReferencesThread = es1.submit(() -> {
for (int i = 0; i < 1000; i++) {
p.getCopyOfReferences();
}
});

final ExecutorService es2 = Executors.newSingleThreadExecutor();
final Future addReferencesThread = es2.submit(() -> {
for (int i = 0; i < 1000; i++) {
p.addReference("dummy" + i, "dummyValue");
}
});

getReferencesThread.get();
addReferencesThread.get();
}
```


---

-
To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
For additional commands, e-mail: dev-h...@ant.apache.org



[GitHub] ant pull request #81: Fix rare ConcurrentModificationException when running ...

2018-12-11 Thread mharmer
GitHub user mharmer opened a pull request:

https://github.com/apache/ant/pull/81

Fix rare ConcurrentModificationException when running with Parallel-Ant 
executor.

This resolves a rare race condition when running with the 
[Parallel-Ant](https://github.com/codeaholics/parallel-ant) executor.

This seems to be triggered concurrently when a reference was being added to 
the project at the same time the references were being copied through 
Project.getCopyOfReferences(). The stack trace observed in this case was:
```
java.util.ConcurrentModificationException
at java.util.Hashtable$Enumerator.next(Hashtable.java:1387)
at java.util.HashMap.putMapEntries(HashMap.java:512)
at java.util.HashMap.(HashMap.java:490)
at 
org.apache.tools.ant.Project.getCopyOfReferences(Project.java:2038)
at 
org.apache.tools.ant.util.ScriptRunnerBase.bindToComponent(ScriptRunnerBase.java:307)
at 
org.apache.tools.ant.util.ScriptRunnerHelper.getScriptRunner(ScriptRunnerHelper.java:66)
at 
org.apache.tools.ant.taskdefs.optional.Script.execute(Script.java:53)
at 
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at 
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at 
org.codeaholics.tools.build.pant.AntWrapperImpl.executeTarget(Unknown Source)
at 
org.codeaholics.tools.build.pant.DependencyGraphEntry.run(Unknown Source)
at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
```

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/pc-doctor/ant ConcurrentModificationReferences

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/ant/pull/81.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #81


commit 01b9073218c9b2f067539bc9f5b21340bf6abd6f
Author: mharmer 
Date:   2018-12-11T22:02:37Z

Fixing a potential ConcurrentModificationException that could occur when 
running Ant with the Parallel-Ant executor.




---

-
To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
For additional commands, e-mail: dev-h...@ant.apache.org