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

java.util.ConcurrentModificationException (no error message) #626

Closed
Reedyuk opened this issue Jan 7, 2022 · 11 comments · Fixed by #669
Closed

java.util.ConcurrentModificationException (no error message) #626

Reedyuk opened this issue Jan 7, 2022 · 11 comments · Fixed by #669

Comments

@Reedyuk
Copy link

Reedyuk commented Jan 7, 2022

I think there is a bug with the realm plugin, when task: :compileKotlinIosSimulatorArm64 is running, i am getting the following:

* What went wrong:
Execution failed for task ':compileKotlinIosSimulatorArm64'.
> java.util.ConcurrentModificationException (no error message)

Sometimes it works and sometimes it doesn't, i guess due to the concurrency.

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.830916Z Processing class Alias

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.831753Z String property named stringValue is nullable false

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.836332Z Processing class Category

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.836418Z Object property named wallpaper is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.836575Z String property named title is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.836598Z String property named trackingName is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.836614Z String property named path is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.836630Z Boolean property named isHidden is nullable false

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.836649Z RealmList property named cells is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.836971Z RealmList property named showcases is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.836995Z RealmList property named sections is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.837015Z RealmList property named aliases is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.837032Z Int property named rawCategoryType is nullable false

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.837587Z Processing class Cell

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.837606Z String property named id is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.837627Z Int property named rawType is nullable false

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.837910Z Processing class Section

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.837930Z Int property named size is nullable false

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.837959Z Boolean property named showTitle is nullable false

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.837978Z String property named title is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.837991Z String property named viewAllUrl is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.838002Z String property named trackingName is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.838029Z RealmList property named cells is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.838349Z Processing class Wallpaper

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.838378Z String property named rawHighlightColour is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.838399Z String property named rawBackgroundColour is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.838419Z Int property named rawTheme is nullable false

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.838443Z String property named topImage is nullable true

i: [Realm Compiler Plugin] 2022-01-07T09:43:13.838455Z String property named bottomImage is nullable true

Here is the same with --stacktrace

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileKotlinIos'.
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:94)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:74)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:402)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:389)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:382)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:368)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
Caused by: java.util.ConcurrentModificationException
	at org.gradle.api.internal.DefaultDomainObjectCollection$IteratorImpl.next(DefaultDomainObjectCollection.java:475)
	at io.realm.gradle.RealmAnalytics.jsonPayload(RealmAnalytics.kt:112)
	at io.realm.gradle.RealmAnalytics.sendMetricIfNeeded(RealmAnalytics.kt:90)
	at io.realm.gradle.RealmAnalytics.afterExecute(RealmAnalytics.kt:82)
	at jdk.internal.reflect.GeneratedMethodAccessor184.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:464)
	at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:446)
	at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:61)
	at org.gradle.internal.event.DefaultListenerManager$EventBroadcast$ListenerDispatch.dispatch(DefaultListenerManager.java:434)
	at org.gradle.internal.event.DefaultListenerManager$EventBroadcast$ListenerDispatch.dispatch(DefaultListenerManager.java:421)
	at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:43)
	at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:245)
	at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:157)
	at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:141)
	at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
	at com.sun.proxy.$Proxy89.afterExecute(Unknown Source)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:91)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:74)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:402)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:389)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:382)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:368)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
@Reedyuk
Copy link
Author

Reedyuk commented Jan 7, 2022

Also seems to happen more often, the more models/schemas i have.

@edualonso
Copy link
Contributor

edualonso commented Jan 10, 2022

Hi @Reedyuk. There seems to be a problem while processing the project linked to a specific Gradle task. Unfortunately, we cannot point to the source with the stacktrace above. How do your project setup and Gradle scripts look like? Would it be possible for you to provide us with a repro case or a repository we could check out?

@edualonso edualonso added Reproduction-Required Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Jan 10, 2022
@Reedyuk
Copy link
Author

Reedyuk commented Jan 10, 2022

I have just tried with another project but it seems to be ok, which is wierd.
Could you make sure you have this property in your gradle.properties:

org.gradle.parallel=true

I assume its some sort of wierd gradle issue running tasks parallel.

Its also important to have support for ios sim and arm64:

    iosSimulatorArm64 {
        binaries.framework("coolframework")
    }
    iosArm64("ios") {
        binaries.framework("coolframework")
    }

So i think its something to do with when gradle runs in parallel the ios sim target and iosarm target compile task?

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Jan 10, 2022
@edualonso
Copy link
Contributor

We don't parallelize our builds at the moment due to project constraints. We are planning on turning that feature on in the future though.

In any case, the issue you are experiencing points to a problem with our analytics implementation and parallel builds. For the time being, I would recommend you don't use parallel builds until we have investigated the issue further.

@edualonso
Copy link
Contributor

We will add a quick fix for accessing the different project configurations synchronously to avoid concurrency exceptions.

This doesn't fix the issue per se but at least will give us time until we have a fix for #498 which will likely solve the problem. Please refer to said issue to follow up on the problem if you keep experiencing problems while using parallel builds.

@edualonso edualonso self-assigned this Jan 12, 2022
@edualonso edualonso added Waiting-For-Reporter Waiting for more information from the reporter before we can proceed and removed Needs-Attention Reporter has responded. Review comment. labels Jan 12, 2022
@nhachicha
Copy link
Collaborator

Fixed in 0.8.2

@Reedyuk
Copy link
Author

Reedyuk commented Feb 1, 2022

Actually still happening but i think i know why.
You need to make sure you use:

com.android.tools.build:gradle:7.1.0")

And gradle

distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Feb 1, 2022
@iamsteveholmes
Copy link

I seem to be getting the same issue. It's happening for me when I run:
./gradlew :shared:cleanIosTest :shared:iosTest

In my case it's totally consistent. I can't run any of my shared ios tests without the failure. It seemed to start when I upgraded to 0.9.0. I'm using the gradle versions above (7.1.0 and 7.3.2) and have org.gradle.parallel=true in my settings.

@nhachicha nhachicha reopened this Feb 3, 2022
@nhachicha
Copy link
Collaborator

@iamsteveholmes could you please post your Gradles configurations so we can try to reproduce?

@cmelchior cmelchior assigned cmelchior and unassigned edualonso Feb 3, 2022
@iamsteveholmes
Copy link

@nhachicha I think I figured out what was causing the problem in my case. One of my properties in a RealmObject class was untyped (implicit typing instead of explicit). So something like this:

class Background : RealmObject {
    @PrimaryKey
    var _id: String = Random.nextLong().toString()
    var _partition = "public"
    var name: String = ""
    var description: String = ""
}

So notice the _partition property is using implicit typing in this case. That seemed to cause the error for me.

@nhachicha
Copy link
Collaborator

@iamsteveholmes I'm not sure this is the root cause since the generated IR when you use typed property or implicit type is the same. @cmelchior Is working on a PR that should enable Gradle cache configuration that should improve things

@sync-by-unito sync-by-unito bot removed the Needs-Attention Reporter has responded. Review comment. label Feb 22, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.