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

NPE for cached fields + fix #244

Open
kephale opened this issue Apr 24, 2020 · 1 comment
Open

NPE for cached fields + fix #244

kephale opened this issue Apr 24, 2020 · 1 comment

Comments

@kephale
Copy link

kephale commented Apr 24, 2020

I was working on an InteractiveCommand and testing it on an update site. During this work I added/removed @parameters.

I eventually got stuck with:

[ERROR] java.lang.NullPointerException
	at java.util.ArrayList.addAll(ArrayList.java:581)
	at org.scijava.util.ClassUtils.getAnnotatedFields(ClassUtils.java:196)
	at org.scijava.util.ClassUtils.getAnnotatedFields(ClassUtils.java:166)
	at org.scijava.Context.getParameterFields(Context.java:447)
	at org.scijava.Context.inject(Context.java:384)
	at org.scijava.Context.inject(Context.java:501)
	at org.scijava.Context.inject(Context.java:386)
	at org.scijava.module.DefaultModuleService.createModule(DefaultModuleService.java:171)
	at org.scijava.module.DefaultModuleService.run(DefaultModuleService.java:209)
	at org.scijava.module.DefaultModuleService.run(DefaultModuleService.java:200)
	at org.scijava.module.DefaultModuleService.run(DefaultModuleService.java:185)
	at net.imagej.legacy.LegacyService.runLegacyCompatibleCommand(LegacyService.java:304)
	at net.imagej.legacy.DefaultLegacyHooks.interceptRunPlugIn(DefaultLegacyHooks.java:163)
	at ij.IJ.runPlugIn(IJ.java)
	at ij.Executer.runCommand(Executer.java:137)
	at ij.Executer.run(Executer.java:66)
	at java.lang.Thread.run(Thread.java:748)
java.lang.NullPointerException
	at java.util.ArrayList.addAll(ArrayList.java:581)
	at org.scijava.util.ClassUtils.getAnnotatedFields(ClassUtils.java:196)
	at org.scijava.util.ClassUtils.getAnnotatedFields(ClassUtils.java:166)
	at org.scijava.command.CommandInfo.checkFields(CommandInfo.java:447)
	at org.scijava.command.CommandInfo.initParams(CommandInfo.java:433)
	at org.scijava.command.CommandInfo.parseParams(CommandInfo.java:428)
	at org.scijava.command.CommandInfo.isValid(CommandInfo.java:384)
	at org.scijava.module.process.ValidityPreprocessor.process(ValidityPreprocessor.java:56)
	at org.scijava.module.ModuleRunner.preProcess(ModuleRunner.java:105)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:157)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

This code was working fine in my IDE, but failing when deployed to the update site. The stacktrace/error didn't say which field was failing but I did see that it had something to do with cached values for the annotation.

Fix:
I deleted my .imagej/IJ_prefs.txt and this resolved the issue.

I'm filing this as an issue because I suspect the desired behavior here is not just to throw a NPE, but to either say which fields are failing or to go one step further and clear the cache for those fields.

@imagejan
Copy link
Member

Maybe related: scijava/scijava-common#150 and scijava/scijava-common#193.

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

2 participants