Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConcurrentModificationException #1168

Closed
ben-manes opened this issue Sep 23, 2016 · 49 comments
Closed

ConcurrentModificationException #1168

ben-manes opened this issue Sep 23, 2016 · 49 comments

Comments

@ben-manes
Copy link
Contributor

When running a test class using 6.9.13.8 the tests pass, but the following error is printed. This does not occur in 6.9.12. (Running via Eclipse)

[TestNG] Reporter org.testng.reporters.JUnitReportReporter@2b552920 failed
java.util.ConcurrentModificationException
    at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
    at java.util.ArrayList$Itr.next(ArrayList.java:851)
    at org.testng.reporters.JUnitReportReporter.getNextConfiguration(JUnitReportReporter.java:220)
    at org.testng.reporters.JUnitReportReporter.generateReport(JUnitReportReporter.java:105)
    at org.testng.TestNG.generateReports(TestNG.java:1175)
    at org.testng.TestNG.run(TestNG.java:1102)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)
@ben-manes
Copy link
Contributor Author

The problem is that the removeAll is accidentally within the loop body.

for (ITestResult r : confResults) {
  if (! seen.containsKey(r.getMethod())) {
    result += r.getEndMillis() - r.getStartMillis();
    seen.put(r.getMethod(), r);
  }
  confResults.removeAll(seen.values());
}

@cbeust
Copy link
Collaborator

cbeust commented Sep 23, 2016

Good catch. Would you be willing to send a PR?

Cédric

On Fri, Sep 23, 2016 at 3:51 PM, Ben Manes [email protected] wrote:

The problem is that the removeAll is accidentally within the loop body.

for (ITestResult r : confResults) {
if (! seen.containsKey(r.getMethod())) {
result += r.getEndMillis() - r.getStartMillis();
seen.put(r.getMethod(), r);
}
confResults.removeAll(seen.values());
}


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#1168 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAFoogjcy_B02Xw2Ctev-UfjVm-cQ8K0ks5qtFfZgaJpZM4KFdZo
.

@cbeust cbeust closed this as completed in ee78cc3 Sep 23, 2016
cbeust added a commit that referenced this issue Sep 23, 2016
ConcurrentModificationException during iteration (fixes #1168)
@shabana-parveen
Copy link

when will we expect the issue fixed release? as I am also getting the same issue.

@missedone
Copy link
Contributor

hi @shabana-parveen
the fix is available in 6.9.13.8 on jCenter.

@shabana-parveen
Copy link

Thanks @missedone

@azell
Copy link

azell commented Oct 11, 2016

Still seeing the error with 6.9.13.8 and u102:

Running TestSuite
[TestNG] Reporter org.testng.reporters.JUnitReportReporter@6e4de19b failed
java.util.ConcurrentModificationException
    at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
    at java.util.ArrayList$Itr.next(ArrayList.java:851)
    at org.testng.reporters.JUnitReportReporter.getNextConfiguration(JUnitReportReporter.java:220)
    at org.testng.reporters.JUnitReportReporter.generateReport(JUnitReportReporter.java:105)
    at org.testng.TestNG.generateReports(TestNG.java:1175)
    at org.testng.TestNG.run(TestNG.java:1102)
    at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:132)
    at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:193)
    at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:94)
    at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:147)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)

POM:

      <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.9.13.8</version>
      </dependency>

@ben-manes
Copy link
Contributor Author

I don't see my fix in 6.9.13.8 (viewed from source jar). So while .8 was released that day, its probably from an earlier commit.

@gdemecki
Copy link

Exactly. This issue is still present in the version 6.9.13.8.

@shabana-parveen
Copy link

shabana-parveen commented Oct 21, 2016

Yes, I can also see the same

@jeffnyman
Copy link

This issue appears to be closed but I, like others, are still seeing the issue. Just making sure that folks area aware this is still a problem, including with the 6.9.13.8 release.

@juherr
Copy link
Member

juherr commented Oct 24, 2016

The fix should be available in the next release.

@randy-li
Copy link

When shall we release next version. See the problem on 6.9.13.8 with Eclipse. Thanks!

@kodayashi
Copy link

Hi there. Any ETA on a release vehicle that contains this fix? I'm stuck on this release due to a fix that I need in 6.9.13.x :)

@krmahadevan
Copy link
Member

krmahadevan commented Nov 30, 2016

@kodayashi - The latest version of TestNG viz., 6.10 is already available in bintray.

You can just add the following and you should be able to consume it

<repositories>
    <repository>
        <id>bintray-cbeust-maven</id>
        <name>bintray</name>
        <url>http://dl.bintray.com/cbeust/maven</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.10</version>
    </dependency>
</dependencies>

@forresthopkinsa
Copy link

Is 6.10 stable? Production ready?

@krmahadevan
Copy link
Member

Not sure what you mean by "Production ready" ? A released product is meant to be stable consumable no ?

@forresthopkinsa
Copy link

I'm asking if this is a Beta you're suggesting

@krmahadevan
Copy link
Member

No this is not a beta. This is a released version of TestNG.

@forresthopkinsa
Copy link

Cool, thanks. Is there a timeline for when it will be in Eclipse's repositories?

@krmahadevan
Copy link
Member

@cbeust should be able to answer that. I know he mentioned he is going to be pushing the changes to Maven Central as well.

@forresthopkinsa
Copy link

Lol, so is it a Beta after all? Someone enlighten me

@missedone
Copy link
Contributor

TestNG 6.10 is released.
TestNG Eclipse Plugin 6.10.x is still in beta, will be released in any seconds.

@kodayashi
Copy link

Sweet, thanks everyone!

@forresthopkinsa
Copy link

Neat. Good work folks

Vla8islav pushed a commit to Vla8islav/software-testing-lessons-java that referenced this issue Dec 4, 2016
…NG to the version 6.10.

It seems to be working: the java.util.ConcurrentModificationException when performing 'mvn test' is no more.
@missedone
Copy link
Contributor

TestNG Eclipse Plugin 6.10.0.201612030230 is released.

@galan
Copy link

galan commented Dec 6, 2016

When will 6.10.x be available from the Maven Central?
http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.testng%22%20AND%20a%3A%22testng%22

@juherr
Copy link
Member

juherr commented Dec 6, 2016

@galan #1261

@sbabcoc
Copy link
Contributor

sbabcoc commented Dec 10, 2016

The 6.10.x release that will contain the fix for this issue has still not been posted yet. When can we expect this to be available?

@missedone
Copy link
Contributor

@sbabcoc
TestNG 6.10 is available both on Maven Central and jCenter.
TestNG Eclipse Plugin 6.10.0.201612030230 is available on the release update site

@sbabcoc
Copy link
Contributor

sbabcoc commented Dec 10, 2016

I upgraded to TestNG 6.10.0.201612030230, and this issue still exists.

@missedone
Copy link
Contributor

@sbabcoc , Eclipse Plugin simply respects the testng jar version of your project, so could you check the testng version on your project classpath? make sure that's up to date.

@anand853
Copy link

anand853 commented Feb 9, 2017

still i hit the same problem with testng 6.10. can you please share the workaround on this?

@juherr
Copy link
Member

juherr commented Feb 9, 2017

@anand853 Could you share your stacktrace? I bet the issue is not the same but a similar one.

@anand853
Copy link

anand853 commented Feb 9, 2017

@juherr ,please find the logs

testng.xml configuration:

name="Suite" parallel="methods"

Maven Error logs:
Tests run: 331, Failures: 5, Errors: 0, Skipped: 0, Time elapsed: 1,082.119 sec <<< FAILURE!
test62(test.com.t.test.com.t.AppRoombaHelpTest) Time elapsed: 0.01 sec <<< FAILURE!
java.util.ConcurrentModificationException: null
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
at java.util.ArrayList$Itr.next(ArrayList.java:851)
at com.relevantcodes.extentreports.model.Test.trackLastRunStatus(Test.java:389)
at com.relevantcodes.extentreports.ExtentTest.log(ExtentTest.java:101)
at com.relevantcodes.extentreports.ExtentTest.log(ExtentTest.java:180)
at test.com.t.sitecores.curlHelpRoomba(sitecores.java:1475)
at test.com.t.test.com.t.AppRoombaHelpTest.test62(AppRoombaHelpTest.java:610)

test73(test.com.t.test.com.t.AppBraavaTermsTest) Time elapsed: 0 sec <<< FAILURE!
java.util.ConcurrentModificationException: null
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
at java.util.ArrayList$Itr.next(ArrayList.java:851)
at com.relevantcodes.extentreports.model.Test.trackLastRunStatus(Test.java:389)
at com.relevantcodes.extentreports.ExtentTest.log(ExtentTest.java:101)
at com.relevantcodes.extentreports.ExtentTest.log(ExtentTest.java:180)
at test.com.t.test.com.t.AppBraavaTermsTest.test73(AppBraavaTermsTest.java:604)

test77(test.com.t.test.com.t.AppBraavaTermsTest) Time elapsed: 0.169 sec <<< FAILURE!
org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
at org.json.JSONTokener.syntaxError(JSONTokener.java:451)
at org.json.JSONObject.(JSONObject.java:195)
at org.json.JSONObject.(JSONObject.java:319)
at test.com.t.sitecores.curlBraavaTermsBase(sitecores.java:1222)
at test.com.t.sitecores.curlBraavaTerms(sitecores.java:1187)
at test.com.t.test.com.t.AppBraavaTermsTest.test77(AppBraavaTermsTest.java:632)

test76(test.com.t.test.com.t.AppBraavaTermsTest) Time elapsed: 0.17 sec <<< FAILURE!
java.lang.NullPointerException: null
at com.relevantcodes.extentreports.model.Test.trackLastRunStatus(Test.java:390)
at com.relevantcodes.extentreports.ExtentTest.log(ExtentTest.java:101)
at com.relevantcodes.extentreports.ExtentTest.log(ExtentTest.java:180)
at test.com.t.sitecores.curlBraavaTerms(sitecores.java:1188)
at test.com.t.test.com.t.AppBraavaTermsTest.test76(AppBraavaTermsTest.java:626)

test66(test.com.t.test.com.t.AppBraavaTermsTest) Time elapsed: 0.17 sec <<< FAILURE!
java.lang.NullPointerException: null
at com.relevantcodes.extentreports.model.Test.trackLastRunStatus(Test.java:390)
at com.relevantcodes.extentreports.ExtentTest.log(ExtentTest.java:101)
at com.relevantcodes.extentreports.ExtentTest.log(ExtentTest.java:180)
at test.com.t.sitecores.curlBraavaTerms(sitecores.java:1188)
at test.com.t.test.com.t.AppBraavaTermsTest.test66(AppBraavaTermsTest.java:549)

Results :

Failed tests:
AppRoombaHelpTest.test62:610 » ConcurrentModification
AppBraavaTermsTest.test73:604 » ConcurrentModification
AppBraavaTermsTest.test77:632 » JSON A JSONObject text must begin with '{' at ...
AppBraavaTermsTest.test76:626 » NullPointer
AppBraavaTermsTest.test66:549 » NullPointer

Tests run: 331, Failures: 5, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18:04 min
[INFO] Finished at: 2017-02-09T09:45:25-05:00
[INFO] Final Memory: 20M/316M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14.1:test (default-test) on project com.sitecore.irobot: There are test failures.
[ERROR]

@krmahadevan
Copy link
Member

@anand853 - This is not a problem from TestNG. Looks like you are facing this problem from extent reports, to be specific this method. I would suggest that you please file a bug here

@anand853
Copy link

anand853 commented Feb 9, 2017

@krmahadevan ,
can you please provide me any workaround on this?

@krmahadevan
Copy link
Member

@anand853 - There are no work arounds for this. Extent Reports needs to fix itself so that it doesn't try to modify and iterate a List at the same time without any sort of synchronization mechanism that wraps access to the list. That would ensure that you don't see this exception from extent reports. Not much can be done, apart from fixing the problematic code.

@juherr
Copy link
Member

juherr commented Feb 9, 2017

For reference: anshooarora/extentreports-java#769

@anand853
Copy link

anand853 commented Mar 10, 2017

version : 6.10
with the testng also im getting same error, can you please let us know which version of the jar and how to achieve parallel execution with testNG

error
java.util.ConcurrentModificationException
at test.com.t.social.A.es_(A.java:1049)

Results :

Failed tests:
AA.es_:1049 » ConcurrentModification

Tests run: 260, Failures: 1, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 55:11 min
[INFO] Finished at: 2017-03-10T10:50:25-05:00
[INFO] Final Memory: 22M/370M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project bot: There are test failures.
[ERROR]
[ERROR] Please refer to svalidation/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

@juherr
Copy link
Member

juherr commented Mar 10, 2017

@anand853

java.util.ConcurrentModificationException
at test.com.t.social.A.es_(A.java:1049)

It looks the exception comes from the test itself and not TestNG

@tkk-priya
Copy link

Hi all,

I am using testng-version 7.1.0, getting concurrentModificationException in following line.
My Code: ExtentManager.getTestStep().log(Status.INFO, m);

Error:
java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909)
at java.util.ArrayList$Itr.next(ArrayList.java:859)
at com.aventstack.extentreports.ExtentObservable.collectRunInfo(ExtentObservable.java:465)
at com.aventstack.extentreports.ExtentObservable.addLog(ExtentObservable.java:309)
at com.aventstack.extentreports.ExtentTest.addLog(ExtentTest.java:359)
at com.aventstack.extentreports.ExtentTest.log(ExtentTest.java:308)
at com.aventstack.extentreports.ExtentTest.log(ExtentTest.java:333)
at com.aventstack.extentreports.ExtentTest.log(ExtentTest.java:352)

Note: i use DataProvider, Multithreading.

@juherr
Copy link
Member

juherr commented Sep 30, 2020

@anandhapriyak Your issue comes from com.aventstack.extentreports. You should open an issue there https://github.com/extent-framework/extentreports-java

@forresthopkinsa
Copy link

forresthopkinsa commented Sep 30, 2020

Jeez, talk about necro 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests