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

EAP 2023.1: Do not use constructor injection #604

Closed
ahus1 opened this issue Feb 24, 2023 · 5 comments
Closed

EAP 2023.1: Do not use constructor injection #604

ahus1 opened this issue Feb 24, 2023 · 5 comments

Comments

@ahus1
Copy link
Contributor

ahus1 commented Feb 24, 2023

On the latest EAP, the IDE reports the following:

java.lang.Throwable: Do not use constructor injection (requestorClass=org.infernus.idea.checkstyle.checker.CheckerFactory)
	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:202)
	at com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:78)
	at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClassWithConstructorInjection(ComponentManagerImpl.kt:1041)
	at com.intellij.serviceContainer.ServiceComponentAdapter.createAndInitialize(ServiceComponentAdapter.kt:43)
	at com.intellij.serviceContainer.ServiceComponentAdapter.doCreateInstance(ServiceComponentAdapter.kt:39)
	at com.intellij.serviceContainer.BaseComponentAdapter.doCreateInstance(BaseComponentAdapter.kt:154)
	at com.intellij.serviceContainer.BaseComponentAdapter.createInstance$lambda$1(BaseComponentAdapter.kt:133)
	at com.intellij.openapi.progress.Cancellation.computeInNonCancelableSection(Cancellation.java:99)
	at com.intellij.serviceContainer.BaseComponentAdapter.createInstance(BaseComponentAdapter.kt:132)
	at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:92)
	at com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:714)
	at com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:670)
	at org.infernus.idea.checkstyle.CheckStyleInspection.checkerFactory(CheckStyleInspection.java:210)
	at org.infernus.idea.checkstyle.CheckStyleInspection.lambda$inspectFile$3(CheckStyleInspection.java:132)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
	at org.infernus.idea.checkstyle.CheckStyleInspection.inspectFile(CheckStyleInspection.java:141)
	at org.infernus.idea.checkstyle.CheckStyleInspection.lambda$checkFile$0(CheckStyleInspection.java:85)
	at com.intellij.openapi.application.impl.ApplicationImpl$2.call(ApplicationImpl.java:283)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
	at java.base/java.lang.Thread.run(Thread.java:833)
IntelliJ IDEA 2023.1 EAP (Ultimate Edition)
Build #IU-231.7515.13, built on February 16, 2023
Expiration date: March 18, 2023
Runtime version: 17.0.6+10-b829.1 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 8
Registry:
    ide.browser.jcef.contextMenu.devTools.enabled=true
    ide.images.show.chessboard=true

Non-Bundled Plugins:
    CheckStyle-IDEA (5.76.0)

Kotlin: 231-1.8.0-release-345-IJ7515.13
@jshiell
Copy link
Owner

jshiell commented Feb 26, 2023

Thanks for the report, I'll have a look when I get a tick.

@jshiell
Copy link
Owner

jshiell commented Feb 26, 2023

I'll be honest, at first glance I'm lost. The docs clearly state that project services can have Project as a constructor arg, even in light services, as long as you don't inject other services. And the only public constructor on that class has only a single Project arg.

The only thing I can think of is if they're picking up the private constructor, which would annoy the fuck out of me, as I don't want to losen the constraints on the class even further by allowing those values to be uninitialised. In any case, it'll have to wait for a day when I have more time.

@theotherp
Copy link

@jshiell
Copy link
Owner

jshiell commented Feb 27, 2023

Thanks. The fix is easy enough if they really don't want constructors, it's just a shitty architectural choice, to enforce initialisation of incomplete services 🤦

@jshiell
Copy link
Owner

jshiell commented Mar 12, 2023

Hopefully fixed - I haven't run it up with the EAP due to time constraints, so that's a hopefully (especially if there are other instances).

@jshiell jshiell closed this as completed Mar 12, 2023
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

3 participants