Buggy code:
public class TileJob implements Runnable { private static final int TILESIZE = 256 ; private final File file ; private final CrsProfile crsProfile ; private final TileScheme tileScheme ; private final Color noDataColor ; private Dataset outputDataset ; private final TileStoreReader tileStoreReader ; private final TileStoreWriter tileStoreWriter ; @ SuppressWarnings ( "unused" ) private final TaskMonitor monitor ; public TileJob ( final File file , final TileStoreReader tileStoreReader , final TileStoreWriter tileStoreWriter , final Settings settings , final TaskMonitor monitor ) { } @ Override public void run ( ) { } private void tile ( ) throws TilingException { } private static Dataset getDataset ( final File file ) throws TilingException { } private static Dataset getTransformedDataset ( final Dataset inputDataset , final int requestedEpsgCrsIdentifier , final int resampleAlgorithm ) throws TilingException { } private static String getWellKnownText ( final Dataset dataset ) { } private static int getMaxZoom ( final BoundingBox world , final Dimensions transformPixelDimensions ) { } private static int getMaxZoom ( final double crsDistance , final double pixelDistance ) { } private int getMinZoom ( final BoundingBox world , final GeoTransformation geoTransformation , final Dimensions rasterDimensions , final Coordinate < Double > imageUpperLeft , final Coordinate < Double > imageLowerRight ) { } private static int f ( final int z , final int d ) { } public static < T extends Number > Coordinate < Integer > transform ( final BoundingBox worldBounds , final Coordinate < T > input , final TileSet tileSet ) { } public BufferedImage convert ( final Dataset dataset ) throws TilingException { Band band = null ; final int bandCount = dataset . getRasterCount ( ) ; final ByteBuffer [ ] bands = new ByteBuffer [ bandCount ] ; final int [ ] banks = new int [ bandCount ] ; final int [ ] offsets = new int [ bandCount ] ; final int xsize = dataset . getRasterXSize ( ) ; final int ysize = dataset . getRasterYSize ( ) ; final int pixels = xsize * ysize ; int bandBufferType = 0 ; for ( int bandIndex = 0 ; bandIndex < bandCount ; ++ bandIndex ) { band = dataset . GetRasterBand ( ( bandIndex + 1 ) ) ; bandBufferType = band . getDataType ( ) ; <START_BUG> final int bandBufferSize = ( pixels * ( gdal . GetDataTypeSize ( bandBufferType ) ) ) // 8 ; <END_BUG> final ByteBuffer data = ByteBuffer . allocateDirect ( bandBufferSize ) ; data . order ( ByteOrder . nativeOrder ( ) ) ; if ( ( band . ReadRaster_Direct ( 0 , 0 , band . getXSize ( ) , band . getYSize ( ) , xsize , ysize , bandBufferType , data ) ) != ( gdalconstConstants . CE_None ) ) { throw new TilingException ( String . format ( "Reading<seq2seq4repair_space>a<seq2seq4repair_space>raster<seq2seq4repair_space>band<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>image<seq2seq4repair_space>failed:<seq2seq4repair_space><%d><seq2seq4repair_space>%s" , gdal . GetLastErrorNo ( ) , gdal . GetLastErrorMsg ( ) ) ) ; } bands [ bandIndex ] = data ; banks [ bandIndex ] = bandIndex ; offsets [ bandIndex ] = 0 ; } if ( band == null ) { throw new RuntimeException ( "The<seq2seq4repair_space>GDAL<seq2seq4repair_space>dataset<seq2seq4repair_space>returned<seq2seq4repair_space>null<seq2seq4repair_space>for<seq2seq4repair_space>a<seq2seq4repair_space>raster<seq2seq4repair_space>band" ) ; } final TileJob . ImageProperties imageProperties = this . getImageProperties ( band , bandCount , pixels , bands ) ; final SampleModel sampleModel = new BandedSampleModel ( imageProperties . bufferType , xsize , ysize , xsize , banks , offsets ) ; final WritableRaster raster = Raster . createWritableRaster ( sampleModel , imageProperties . imageBuffer , null ) ; BufferedImage img = null ; if ( ( band . GetRasterColorInterpretation ( ) ) == ( gdalconstConstants . GCI_PaletteIndex ) ) { img = new BufferedImage ( band . GetRasterColorTable ( ) . getIndexColorModel ( gdal . GetDataTypeSize ( bandBufferType ) ) , raster , false , null ) ; } else { if ( bandCount > 2 ) { final ColorModel colorModel = new ComponentColorModel ( ColorSpace . getInstance ( ColorSpace . CS_sRGB ) , ( bandCount == 4 ) , false , ( bandCount == 4 ? Transparency . TRANSLUCENT : Transparency . OPAQUE ) , imageProperties . bufferType ) ; img = new BufferedImage ( colorModel , raster , true , null ) ; } else { img = new BufferedImage ( xsize , ysize , imageProperties . dataType ) ; img . setData ( raster ) ; } } return img ; } private static double log2 ( final double value ) { } private TileJob . ImageProperties getImageProperties ( final Band band , final int bandCount , final int pixels , final ByteBuffer [ ] bands ) throws TilingException { } private class ImageProperties { DataBuffer imageBuffer ; int dataType ; int bufferType ; } }

Fix:
final int bandBufferSize = pixels * ( ( gdal . GetDataTypeSize ( bandBufferType ) ) // 8 ) ;