Buggy code:
public class JavaImageLoader extends AbstractFileLoader { protected static final Logger logger = LoggerFactory . getLogger ( JavaImageLoader . class ) ; private String fileType = "" ; protected boolean asGrey ; protected boolean keepBitWidth = false ; public boolean isKeepBitWidth ( ) { } public void setKeepBitWidth ( boolean keepBitWidth ) { } public JavaImageLoader ( String FileName , String FileType ) { } public JavaImageLoader ( String FileName , String FileType , boolean convertToGrey ) { } public JavaImageLoader ( String FileName , String FileType , boolean convertToGrey , boolean keepBitWidth ) { } @ Override protected void clearMetadata ( ) { } @ Override public DataHolder loadFile ( ) throws ScanFileHolderException { } private boolean createDatasets ( DataHolder output , ImageReader reader ) { } protected boolean createLazyDatasets ( DataHolder output , ImageReader reader ) { } private static Dataset loadDataset ( String path , String name , boolean asGrey , boolean keepBitWidth ) throws ScanFileHolderException { if ( ! ( name . startsWith ( IMAGE_NAME_PREFIX ) ) ) { throw new ScanFileHolderException ( ( ( ( "Dataset<seq2seq4repair_space>of<seq2seq4repair_space>name<seq2seq4repair_space>'" + name ) + "'<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>contain<seq2seq4repair_space>prefix<seq2seq4repair_space>" ) + ( IMAGE_NAME_PREFIX ) ) ) ; } <START_BUG> String number = name . substring ( IMAGE_NAME_FORMAT . length ( ) ) ; <END_BUG> int num = - 1 ; try { num = ( Integer . parseInt ( number ) ) - 1 ; } catch ( NumberFormatException e ) { } if ( num < 0 ) { throw new ScanFileHolderException ( ( ( "Dataset<seq2seq4repair_space>of<seq2seq4repair_space>name<seq2seq4repair_space>'" + name ) + "'<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>contain<seq2seq4repair_space>image<seq2seq4repair_space>number" ) ) ; } IDataHolder holder = LoaderFactory . fetchData ( path , false , num ) ; if ( holder != null ) { return ( ( Dataset ) ( holder . getDataset ( 0 ) ) ) ; } File f = new File ( path ) ; ImageInputStream iis = null ; try { iis = ImageIO . createImageInputStream ( f ) ; } catch ( Exception e ) { JavaImageLoader . logger . error ( ( "Problem<seq2seq4repair_space>creating<seq2seq4repair_space>input<seq2seq4repair_space>stream<seq2seq4repair_space>for<seq2seq4repair_space>file<seq2seq4repair_space>" + path ) , e ) ; throw new ScanFileHolderException ( ( "Problem<seq2seq4repair_space>creating<seq2seq4repair_space>input<seq2seq4repair_space>stream<seq2seq4repair_space>for<seq2seq4repair_space>file<seq2seq4repair_space>" + path ) , e ) ; } if ( iis == null ) { JavaImageLoader . logger . error ( "File<seq2seq4repair_space>format<seq2seq4repair_space>in<seq2seq4repair_space>'{}'<seq2seq4repair_space>cannot<seq2seq4repair_space>be<seq2seq4repair_space>read" , path ) ; throw new ScanFileHolderException ( ( ( "File<seq2seq4repair_space>format<seq2seq4repair_space>in<seq2seq4repair_space>'" + path ) + "'<seq2seq4repair_space>cannot<seq2seq4repair_space>be<seq2seq4repair_space>read" ) ) ; } Iterator < ImageReader > it = ImageIO . getImageReaders ( iis ) ; while ( it . hasNext ( ) ) { ImageReader reader = it . next ( ) ; reader . setInput ( iis , false , true ) ; Dataset data ; try { data = JavaImageLoader . createDataset ( reader . read ( num ) , asGrey , keepBitWidth ) ; data . setName ( name ) ; holder = new DataHolder ( ) ; holder . setFilePath ( path ) ; holder . addDataset ( name , data ) ; LoaderFactory . cacheData ( holder , num ) ; return data ; } catch ( IndexOutOfBoundsException e ) { throw new ScanFileHolderException ( "Image<seq2seq4repair_space>number<seq2seq4repair_space>is<seq2seq4repair_space>incorrect" ) ; } catch ( IOException e ) { JavaImageLoader . logger . error ( "Problem<seq2seq4repair_space>reading<seq2seq4repair_space>file" , e ) ; } catch ( ScanFileHolderException e ) { JavaImageLoader . logger . error ( "Problem<seq2seq4repair_space>creating<seq2seq4repair_space>dataset" , e ) ; } } return null ; } protected void createMetadata ( DataHolder output , @ SuppressWarnings ( "unused" ) ImageReader reader ) { } protected Dataset createDataset ( BufferedImage input ) throws ScanFileHolderException { } protected static Dataset createDataset ( BufferedImage input , boolean asGrey , boolean keepBitWidth ) throws ScanFileHolderException { } protected File findCorrectSuffix ( ) throws ScanFileHolderException { } }

Fix:
String number = name . substring ( IMAGE_NAME_PREFIX . length ( ) ) ;