OMEXMLMetadata: prevent IndexOutOfBoundsException when setting references #229
+126
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes the issue detected in ome/bioformats#4394 (comment) as a follow-up of #226
As shown in the failing tests https://github.com/ome/ome-model/blob/master/specification/samples/2016-06/folders-larger-taxonomy.ome.xml is a good way to reproduce the
IndexOutOfBoundsExceptionusing Bio-Formatsshowinf -ome-xmlandorg.openmicroscopy:ome-xml 6.5.2.Taking
setImageROIRef(roiReference, imageIndex, roiRefIndex)as an example, the current logic following the changes in #226 is the following,roiReferencedoes not exist, the addition of the ROI reference for imageimageIndexis deferred underresolveReferencesis calledroiReferenceexists androiRefIndex == getRoiRefCount, the ROI reference is appended to the list of references for imageimageIndexroiReferenceexists androiRefIndex < getRoiRefCount, the ROI reference for imageimageIndexatroiRefIndexis replaced byroiReferenceThis Pull Requests adds a fourth additional conditional behavior allowing to restore backwards-compatibility
roiReferenceexists androiRefIndex > getRoiRefCount, the addition of the ROI reference for imageimageIndexis deferred underresolveReferencesis calledUnit tests are also added to cover the different failing scenarios found in our repository tests i.e.:
roiRefIndexstarting with a non-zero offset