imagej / imagej/imagej-common

DefaultPrefService can throw NPE

Open
#48 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
12
Forks
15
PR merge metrics
No merged PRs in 30d

Description

The following exception can be thrown by the `DefaultPrefService` when persisting values:

```
java.lang.NullPointerException
at java.util.prefs.AbstractPreferences.put(AbstractPreferences.java:241)
at org.scijava.prefs.DefaultPrefService.put(DefaultPrefService.java:183)
at org.scijava.module.DefaultModuleService.save(DefaultModuleService.java:280)
at org.scijava.module.process.SaveInputsPreprocessor.saveValue(SaveInputsPreprocessor.java:74)
at org.scijava.module.process.SaveInputsPreprocessor.process(SaveInputsPreprocessor.java:65)
at org.scijava.module.ModuleRunner.preProcess(ModuleRunner.java:104)
at org.scijava.module.ModuleRunner.run(ModuleRunner.java:156)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
at org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:164)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
```

To reproduce, open the `SingleInputPreprocessorTest`, remove the `persist = false` attribute from the `private T thing` parameter of `HasASingleInput`, and run the tests.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with SingleInputPreprocessorTest and reproduce the failure by removing persist = false from HasASingleInput. Trace the stack into DefaultPrefService.java, especially put at line 183, and inspect the persistence path. Done means the test scenario no longer throws a NullPointerException and the relevant tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.