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

Error thrown by Worker: "changing log factory" #110

Open
autonomousapps opened this issue Jul 22, 2019 · 10 comments
Open

Error thrown by Worker: "changing log factory" #110

autonomousapps opened this issue Jul 22, 2019 · 10 comments

Comments

@autonomousapps
Copy link
Contributor

autonomousapps commented Jul 22, 2019

Version 2.0.0, Gradle 5.4.1.

Just got this stacktrace while testing some changes. Not sure what to make of it. Build still passed.

> Task :lintKotlinAll
Changing log factory
java.lang.Throwable
        at org.jetbrains.kotlin.com.intellij.openapi.diagnostic.Logger.setFactory(Logger.java:49)
        at com.pinterest.ktlint.core.KtLint.<clinit>(KtLint.kt:80)
        at org.jmailen.gradle.kotlinter.tasks.lint.LintWorkerRunnable.lint(LintWorkerRunnable.kt:64)
        at org.jmailen.gradle.kotlinter.tasks.lint.LintWorkerRunnable.lintKt(LintWorkerRunnable.kt:58)
        at org.jmailen.gradle.kotlinter.tasks.lint.LintWorkerRunnable.access$lintKt(LintWorkerRunnable.kt:17)
        at org.jmailen.gradle.kotlinter.tasks.lint.LintWorkerRunnable$run$1$lintFunc$1.invoke(LintWorkerRunnable.kt:37)
        at org.jmailen.gradle.kotlinter.tasks.lint.LintWorkerRunnable$run$1$lintFunc$1.invoke(LintWorkerRunnable.kt:17)
        at org.jmailen.gradle.kotlinter.tasks.lint.LintWorkerRunnable.run(LintWorkerRunnable.kt:46)
        at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:41)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.execute(NoIsolationWorkerFactory.java:58)
        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
        at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:51)
        at org.gradle.workers.internal.DefaultWorkerExecutor$1.call(DefaultWorkerExecutor.java:107)
        at org.gradle.workers.internal.DefaultWorkerExecutor$1.call(DefaultWorkerExecutor.java:101)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Thread.java:748)
@jeremymailen
Copy link
Owner

That's weird, does it always happen? I haven't seen it.

It comes from here: https://github.com/pinterest/ktlint/blob/master/ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/KtLint.kt#L81

Since KtLint is an object, I'd assume that init block would only run once. It looks like that error is printed to stdout when some tries to set the logger twice.

@autonomousapps
Copy link
Contributor Author

Only happened once. If it does again, I'll update. I've seen weird stuff before with the Worker API that makes me think things aren't quite synchronized correctly.

@Naitbit
Copy link

Naitbit commented Jan 27, 2020

I did just experience it after upgrade to 2.3.0
(Gradle 5.6.4)

java.lang.Throwable
	at org.jetbrains.kotlin.com.intellij.openapi.diagnostic.Logger.setFactory(Logger.java:49)
	at com.pinterest.ktlint.core.KtLint.<clinit>(KtLint.kt:86)
	at org.jmailen.gradle.kotlinter.tasks.lint.LintWorkerRunnable.lint(LintWorkerRunnable.kt:64)
	at org.jmailen.gradle.kotlinter.tasks.lint.LintWorkerRunnable.lintKt(LintWorkerRunnable.kt:58)
	at org.jmailen.gradle.kotlinter.tasks.lint.LintWorkerRunnable.access$lintKt(LintWorkerRunnable.kt:17)
	at org.jmailen.gradle.kotlinter.tasks.lint.LintWorkerRunnable$run$1$lintFunc$1.invoke(LintWorkerRunnable.kt:37)
	at org.jmailen.gradle.kotlinter.tasks.lint.LintWorkerRunnable$run$1$lintFunc$1.invoke(LintWorkerRunnable.kt:17)
	at org.jmailen.gradle.kotlinter.tasks.lint.LintWorkerRunnable.run(LintWorkerRunnable.kt:46)
	at org.gradle.workers.internal.AdapterWorkAction.execute(AdapterWorkAction.java:50)
	at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:47)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1$1.create(NoIsolationWorkerFactory.java:65)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1$1.create(NoIsolationWorkerFactory.java:61)
	at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:98)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.execute(NoIsolationWorkerFactory.java:61)
	at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
	at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
	at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:56)
	at org.gradle.workers.internal.DefaultWorkerExecutor$3.call(DefaultWorkerExecutor.java:215)
	at org.gradle.workers.internal.DefaultWorkerExecutor$3.call(DefaultWorkerExecutor.java:210)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
	at java.lang.Thread.run(Thread.java:748)

It did not happen on subsequent runs though.
Makes me wonder if it is related to updating dependency.

@jeremymailen
Copy link
Owner

Ok, that's good to know. Still a bug, but if it happens once on a version update it's not as severe.

@jeremymailen
Copy link
Owner

Closing for now, hopefully we don't run into it ever again in the new design.

@fluxxion82
Copy link

I'm getting this error consistently. Currently using 3.6.0 but saw seeing it consistently on earlier versions too. My build is still passing so I'm not too concerned about it. I can post this project later so you can check it out and debug it if you're interested.

@jeremymailen jeremymailen reopened this Oct 2, 2021
@jeremymailen
Copy link
Owner

I'm getting this error consistently. Currently using 3.6.0 but saw seeing it consistently on earlier versions too. My build is still passing so I'm not too concerned about it. I can post this project later so you can check it out and debug it if you're interested.

Yes, please do, thanks! Having a project that can repro the issue will go a long ways towards figuring out how to fix it.

I assume the lint task still runs successfully?

@fluxxion82
Copy link

Sorry for the delay responding. So I've been working on this project and I'm not getting the error consistently anymore. I'm actually getting other non fatal lint type errors, basically a ClassNotFoundException: com.android.tools.lint.client.api.Vendor exception, but I think it's because of some libraries using agp 7.0, while in my project I'm using 4.2.2 (maybe?).
I started trying to go through the project history to see if I could get the error again, but in the process I was also trying to figure out how to not get this ClassNotFoundException, and so I added classpath("com.android.tools.lint:lint:30.0.2") to the root build script hoping it might help, and I actually got the 'Changing log factory' exception again, but only on the first build run. I'm not seeing it in subsequent build runs . It show up the first run if I remove it or add it.
Additionally, I'm using compose in my project but I'm only seeing the log factory error now when I remove it from the project, so adding it seems to maybe have some influence on the error somehow...?
Anyways, I'm going to package this project up for you before I change things again and loose the configuration for the error. Hopefully you'll be able to make use of it to get some insight on the log factory error. You'll have to uncomment the classpath line in the build script and run ./gradlew build at the command line.
Let me know when you download the project so I can take it down.
https://drive.google.com/file/d/1GFwOdFDqUnrQDDp9BVOZnpFg9gaDPfd_/view?usp=sharing

@jeremymailen
Copy link
Owner

Thank you @fluxxion82, I've got your file. I'll let you know if I can determine a cause, but it does sound like a somewhat innocuous error.

@fluxxion82
Copy link

Cool, hope it helps! Let me know if you have any questions about the project.

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

4 participants