User of my Plugin gets Exception on start while trying to load state
已回答
Out of nowhere user get now this exception. I am not sure what i could do better here since it seems to be a security issue from java itself? please help:
java.lang.IllegalArgumentException: Argument for @NotNull parameter 'value' of state/MyModelConverter.fromString must not be null
at state.MyModelConverter.$$$reportNull$$$0(MyModelConverter.java)
at state.MyModelConverter.fromString(MyModelConverter.java)
at state.State.load(State.java:92)
at service.ViewService.load(ViewService.java:78)
at service.ViewService.initLater(ViewService.java:129)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:789)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:740)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:734)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:759)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:685)
at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$10(IdeEventQueue.kt:589)
at com.intellij.openapi.application.impl.ApplicationImpl.runWithoutImplicitRead(ApplicationImpl.java:1485)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:589)
at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:67)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:369)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:368)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:368)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:363)
at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:992)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:992)
at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:363)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:861)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:405)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
请先登录再写评论。
Hi Michael,
The exception is thrown by an instrumented code generated for the
@NotNull
annotation on thevalue
parameter inMyModelConverter.fromString()
.Is the code passing the
value
parameter under your control? If yes, then make sure not to pass null.No this is not under my control and it happens not often. sometime if you switch the project than it can happen. the value is coming from PersistentStateComponent:
i thought the issue was fixed by annotate the function which receives the value with @notnull, but this is not the case. I dont know what i can do to fix this. The problem is that the whole Plugin doesnt work after that happens. unfortunately It can not really reproduced :-(.
Hi Michael,
Please share your code (classes from the top of the stacktrace). I cannot help more without the actual code.
2023_08_30_ce1MKnkFVdeBqYrs5fQFhS
Hi Michael,
The code is out of sync with the stacktrace, so I'm not 100% sure about my conclusions.
The code is under your control, and it seems you pass null to the method.
I don't understand why do you call load on State class and call the converter, etc. manually. All the state data is loaded under the hood when you call getService. You don't have to handle it manually. I suggest checking https://plugins.jetbrains.com/docs/intellij/persisting-state-of-components.html and examples in the intellij-community sources on how to implement persistent state component.
BTW, please always use the latest Gradle IntelliJ Plugin (update from 1.12.0 to 1.15.0).
Also, always provide precise steps to reproduce the issue and make the plugin working for us without any additional actions or changes. Your plugin is a paid plugin and I don't have a license, so I had to manually amend plugin.xml and license checker to be able to run it.
i previously didnt understand how to use a converter if it is a List of Objects. With the help of AI i finally solved this with
@OptionTag(converter = MyModelConverter.class)
now i do access the state like it is supposed to do. maybe this helps to avoid the issue.
i updated gradle plugin. i will be more precise with my questions.
let me turn your last point into a question: how can i activate this line in plugin.xml while developing without manual commenting it out, because i dont have a license for me either
Thanks for your support!
I did exactly what you mentioned, so commented it out in plugin.xml, and commented out the license checking logic.
I mean conditionally activate or deactivate lines in `plugin.xml` to improve this process while development. Is this possible somehow?
No, it is not possible.