scijava / scijava-common

A plugin framework and application container with built-in extensibility mechanism :electric_plug:
BSD 2-Clause "Simplified" License
91 stars 52 forks source link

Null Array Parameter is persisted as an Array containing a single element, which is null #466

Open NicoKiaru opened 1 year ago

NicoKiaru commented 1 year ago

I have a command with a non-required array parameter:

    @Parameter(label = "Select Bvv Windows to synchronize", required = false)
    BvvHandle[] bvvhs;

Before, when nothing was set, bvvhs was returned as a null object. Now, when bvvhs is not set, the parameter is set to an array of size 1, with the element being a null object.

It's a change of behaviour which breaks a few things in my code. It's probably manageable, but the current behaviour needs to be changed:

return null is fine, returning an empty array is probably also fine, but returning a one-element array with null inside do not look good.

FYI, I checked in the prefs how the parameter is remembered, and this is how it looks:

image

I think it should be:

image

Related as mentioned by @ctrueden:

https://github.com/scijava/scijava-common/issues/450 https://github.com/scijava/scijava-common/commit/ce135b7c9e3197a87423e9ef0e8fc58f5d400387

Original forum thread: https://forum.image.sc/t/change-of-behaviour-in-scijava-parameter-table-of-size-one-with-null-object-inside-instead-of-null-object/83625/2


It does not look like a critical issue, but it might pop here and there

imagesc-bot commented 1 year ago

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/change-of-behaviour-in-scijava-parameter-table-of-size-one-with-null-object-inside-instead-of-null-object/83625/4