[ome-devel] metadata.getChannelName() throws exception

Melissa Linkert melissa at glencoesoftware.com
Mon Mar 31 22:35:28 BST 2014


Hi Ghislain,

> In the process of working with the Flex reader and finding a temporary solution, I have found what may be a bug:
> 
> java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
>        at java.util.ArrayList.rangeCheck(Unknown Source)
>        at java.util.ArrayList.get(Unknown Source)
>        at ome.xml.model.Pixels.getChannel(Pixels.java:573)
>        at ome.xml.meta.OMEXMLMetadataImpl.getChannelName(OMEXMLMetadataImpl.java:1053)
>        at org.gnf.HCIReaders.HCIReaderOpera.setWellImagesProps(HCIReaderOpera.java:161)
> 
> In the past the  ome.xml.model.Pixels.getChannel() returned null if it did not exist. I have figured out that in my case, I need to invert int imageIndex, int channelIndex, which is probably caused by the bug in handling the flex format from v2.0.  However, I think that either the out-of bound exception should be handled internally and that the value null should be returned (I think this was the default behavior), or that the method should throw an error of its own, which a programmer would know to handle externally.

This exception is expected when requesting the name of a channel that
does not exist.  It is implicitly expected (though admittedly not well
documented) that the caller should verify that the channel index is less than
getChannelCount(imageIndex) before calling getChannelName(imageIndex, channelIndex).

Our feeling was that throwing an IndexOutOfBoundsException when an invalid
index was passed in was more informative than returning null, as that enables
the caller to differentiate between the parent metadata object not existing
and the specific metadata value being unset.  Hopefully that makes
sense, but if there are cases where checking getChannelCount or catching
IndexOutOfBoundsException aren't sufficient then please let us know.

Regards,
-Melissa

On Mon, Mar 31, 2014 at 05:40:32AM +0000, Bonamy, Ghislain wrote:
> In the process of working with the Flex reader and finding a temporary solution, I have found what may be a bug:
> 
> java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
>        at java.util.ArrayList.rangeCheck(Unknown Source)
>        at java.util.ArrayList.get(Unknown Source)
>        at ome.xml.model.Pixels.getChannel(Pixels.java:573)
>        at ome.xml.meta.OMEXMLMetadataImpl.getChannelName(OMEXMLMetadataImpl.java:1053)
>        at org.gnf.HCIReaders.HCIReaderOpera.setWellImagesProps(HCIReaderOpera.java:161)
> 
> In the past the  ome.xml.model.Pixels.getChannel() returned null if it did not exist. I have figured out that in my case, I need to invert int imageIndex, int channelIndex, which is probably caused by the bug in handling the flex format from v2.0.  However, I think that either the out-of bound exception should be handled internally and that the value null should be returned (I think this was the default behavior), or that the method should throw an error of its own, which a programmer would know to handle externally.
> 
> Best,
> 
> Ghislain Bonamy, PhD

> _______________________________________________
> ome-devel mailing list
> ome-devel at lists.openmicroscopy.org.uk
> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel



More information about the ome-devel mailing list