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

More Converter null fun #52

Closed
ctrueden opened this issue Jun 1, 2015 · 1 comment
Closed

More Converter null fun #52

ctrueden opened this issue Jun 1, 2015 · 1 comment
Assignees

Comments

@ctrueden
Copy link
Member

ctrueden commented Jun 1, 2015

java.lang.NullPointerException
    at net.imagej.convert.ConvertIntArrayToFinalInterval.convert(ConvertIntArrayToFinalInterval.java:53)
    at org.scijava.convert.AbstractConvertService.convert(AbstractConvertService.java:62)
    at org.scijava.script.ScriptModule.run(ScriptModule.java:196)
    at org.scijava.module.ModuleRunner.run(ModuleRunner.java:167)
    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:181)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
    at java.util.concurrent.FutureTask.get(FutureTask.java:83)
    at net.imagej.ui.swing.script.TextEditor.evalScript(TextEditor.java:2476)
    at net.imagej.ui.swing.script.TextEditor.access$400(TextEditor.java:158)
    at net.imagej.ui.swing.script.TextEditor$Tab$6.execute(TextEditor.java:1488)
    at net.imagej.ui.swing.script.TextEditor$Executer$1.run(TextEditor.java:1977)
Caused by: java.lang.NullPointerException
    at net.imagej.convert.ConvertIntArrayToFinalInterval.convert(ConvertIntArrayToFinalInterval.java:53)
    at org.scijava.convert.AbstractConvertService.convert(AbstractConvertService.java:62)
    at org.scijava.script.ScriptModule.run(ScriptModule.java:196)
    at org.scijava.module.ModuleRunner.run(ModuleRunner.java:167)
    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:181)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)

And here's the script that caused it:

# @DatasetService data
# @DisplayService display
# @OpService ops
# @net.imagej.Dataset inputData

from net.imglib2.meta import ImgPlus
from net.imglib2.img.display.imagej import ImageJFunctions

from jarray import array
from ij import IJ

# create a log kernel
logKernel=ops.logKernel(2, 1.0)

# convolve with log kernel
logFiltered=ops.convolve(inputData, logKernel)

# display log filter result
display.createDisplay("log", ImgPlus(logFiltered))

# otsu threshold and display
thresholded = ops.run("otsu", logFiltered)
display.createDisplay("thresholded", ImgPlus(thresholded))

# convert to imagej1 imageplus so we can run analyze particles
impThresholded=ImageJFunctions.wrap(thresholded, "wrapped")

# convert to mask and analyze particles
IJ.run(impThresholded, "Convert to Mask", "")
IJ.run(impThresholded, "Analyze Particles...", "display add")
IJ.run("Close")

@hinerm Can you take a look? On cursory inspection it seems that AbstractConverter accepts null sources in canConvert now (maybe due to my recent changes to ConversionUtils?), but downstream converters are not expecting this and their convert method blows up in that scenario. We'll need to be more consistent about this...

hinerm added a commit to scijava/scijava-common that referenced this issue Jun 1, 2015
The default converter contract is that inputs can not be null, with the
intent that individual converters can otherwise override this behavior.

This contract is now consistent between all canConvert signatures, and
has been clarified in the javadoc.

See imagej/imagej-common#52
@hinerm
Copy link
Member

hinerm commented Jun 1, 2015

@ctrueden yep you were right, there was an inconsistency. scijava/scijava-common@d5575ac fixes the NPE in your example and I believe is correct for the current state of affairs - twisted as it may be..

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