Buggy code:
public class MrsImagePyramidMetadata extends MrsPyramidMetadata { private static final Logger log = LoggerFactory . getLogger ( MrsImagePyramidMetadata . class ) ; private static final long serialVersionUID = 1L ; public static class ImageMetadata extends MrsPyramidMetadata . TileMetadata { private static final long serialVersionUID = 1L ; public LongRectangle pixelBounds = null ; public ImageStats [ ] stats = null ; public ImageMetadata ( ) { } public void setImage ( final String image ) { } } private MrsImagePyramidMetadata . ImageMetadata [ ] imageData = null ; private int bands = 0 ; private double [ ] defaultValues ; private int tileType ; private ImageStats [ ] stats ; private MrsImagePyramidMetadata . Classification classification = MrsImagePyramidMetadata . Classification . Continuous ; private String resamplingMethod ; public enum Classification { Categorical , Continuous ; } @ Deprecated public static MrsImagePyramidMetadata load ( final File file ) throws IOException , JsonGenerationException , JsonMappingException { } public static MrsImagePyramidMetadata load ( final InputStream stream ) throws IOException , JsonGenerationException , JsonMappingException { } public static int toBytes ( final int tiletype ) { } public static int toTileType ( final String tiletype ) { } public static String toTileTypeText ( final int tiletype ) { } public int getBands ( ) { } @ JsonIgnore public double getPixelHeight ( int zoom ) { } @ JsonIgnore public double getPixelWidth ( int zoom ) { } @ JsonIgnore public double getDefaultValue ( final int band ) { } @ JsonIgnore public byte getDefaultValueByte ( final int band ) { } @ JsonIgnore public double getDefaultValueDouble ( final int band ) { } @ JsonIgnore public float getDefaultValueFloat ( final int band ) { } @ JsonIgnore public int getDefaultValueInt ( final int band ) { } @ JsonIgnore public long getDefaultValueLong ( final int band ) { } public double [ ] getDefaultValues ( ) { } @ JsonIgnore public byte [ ] getDefaultValuesByte ( ) { } @ JsonIgnore public double [ ] getDefaultValuesDouble ( ) { } @ JsonIgnore public float [ ] getDefaultValuesFloat ( ) { } @ JsonIgnore public short getDefaultValueShort ( final int band ) { } @ JsonIgnore public int [ ] getDefaultValuesInt ( ) { } @ JsonIgnore public long [ ] getDefaultValuesLong ( ) { } @ JsonIgnore public short [ ] getDefaultValuesShort ( ) { } @ Override public String getName ( final int zoomlevel ) { } public MrsImagePyramidMetadata . ImageMetadata [ ] getImageMetadata ( ) { } public LongRectangle getPixelBounds ( final int zoomlevel ) { } @ Override public LongRectangle getTileBounds ( final int zoomlevel ) { } public ImageStats [ ] getImageStats ( final int zoomlevel ) { } public ImageStats getImageStats ( final int zoomlevel , int band ) { } public ImageStats getStats ( int band ) { } public ImageStats [ ] getStats ( ) { } @ Override public LongRectangle getOrCreateTileBounds ( final int zoomlevel ) { } public LongRectangle getOrCreatePixelBounds ( final int zoomlevel ) { } public int getTileType ( ) { } public MrsImagePyramidMetadata . Classification getClassification ( ) { } public double [ ] getExtrema ( final int zoomLevel ) { } public String getResamplingMethod ( ) { } public void setResamplingMethod ( String resamplingMethod ) { } public void save ( final OutputStream stream ) throws IOException , JsonGenerationException , JsonMappingException { } public void setBands ( final int bands ) { } public void setDefaultValues ( final double [ ] defaultValues ) { } @ Override public void setName ( final int zoomlevel , final String name ) { } public void setImageMetadata ( final MrsImagePyramidMetadata . ImageMetadata [ ] metadata ) { imageData = metadata ; if ( ( imageData ) == null ) { for ( int i = 0 ; i <= ( maxZoomLevel ) ; i ++ ) { imageData = ( ( MrsImagePyramidMetadata . ImageMetadata [ ] ) ( ArrayUtils . add ( imageData , new MrsImagePyramidMetadata . ImageMetadata ( ) ) ) ) ; } } else <START_BUG> if ( ( maxZoomLevel ) < ( imageData . length ) ) { <END_BUG> imageData = ( ( MrsImagePyramidMetadata . ImageMetadata [ ] ) ( ArrayUtils . subarray ( imageData , 0 , ( ( maxZoomLevel ) + 1 ) ) ) ) ; } else if ( ( maxZoomLevel ) > ( imageData . length ) ) { for ( int i = imageData . length ; i <= ( maxZoomLevel ) ; i ++ ) { imageData = ( ( MrsImagePyramidMetadata . ImageMetadata [ ] ) ( ArrayUtils . add ( imageData , new MrsImagePyramidMetadata . ImageMetadata ( ) ) ) ) ; } } } @ Override public void setMaxZoomLevel ( final int zoomlevel ) { } public void setPixelBounds ( final int zoomlevel , final LongRectangle pixelBounds ) { } @ Override public void setTileBounds ( final int zoomlevel , final LongRectangle tileBounds ) { } public void setImageStats ( final int zoomlevel , final ImageStats [ ] stats ) { } public void setStats ( final ImageStats [ ] stats ) { } public void setTileType ( final int tileType ) { } public void setClassification ( MrsImagePyramidMetadata . Classification classification ) { } }

Fix:
if ( ( ( maxZoomLevel ) + 1 ) < ( imageData . length ) ) {