Buggy code:
private static final String suffix = "';<//script><//html>" ; public static final Pattern uuidRegExp = Pattern . compile ( "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$" ) ; static void cleanDatasetCache ( Path datasetDir ) { } static void cleanPreparedDir ( Path preparedDir ) { } static String digest ( Long id , String location , String key ) throws InternalException { } public static String getLocation ( Datafile df ) throws InsufficientPrivilegesException , InternalException { } static String getLocationFromDigest ( Long id , String locationWithHash , String key ) throws InsufficientPrivilegesException , InternalException { } static void pack ( OutputStream stream , boolean zip , boolean compress , Map < Long , DsInfo > dsInfos , Set < DfInfoImpl > dfInfos , Set < Long > emptyDatasets ) { } static Prepared unpack ( InputStream stream ) throws InternalException { } public static void validateUUID ( String thing , String id ) throws BadRequestException { } private ArchiveStorageInterface archiveStorage ; private Path datasetDir ; private DatatypeFactory datatypeFactory ; @ EJB private FiniteStateMachine fsm ; private ICAT icat ; private Path linkDir ; private boolean linkEnabled ; private MainStorageInterface mainStorage ; private Path markerDir ; private Path preparedDir ; private PropertyHandler propertyHandler ; @ EJB IcatReader reader ; private boolean readOnly ; private Set < String > rootUserNames ; private StorageUnit storageUnit ; private ZipMapperInterface zipMapper ; private int maxIdsInQuery ; private boolean twoLevel ; public void archive ( String sessionId , String investigationIds , String datasetIds , String datafileIds ) throws BadRequestException , InsufficientPrivilegesException , InternalException , NotFoundException , NotImplementedException { } private void checkDatafilesPresent ( Set < ? extends DfInfo > dfInfos , String lockId ) throws InternalException , NotFoundException { } private void checkOnlineAndFreeLockOnFailure ( Collection < DsInfo > dsInfos , Set < Long > emptyDatasets , Set < DfInfoImpl > dfInfos , String lockId , SetLockType lockType ) throws DataNotOnlineException , InternalException { } private boolean restoreIfOffline ( DfInfoImpl dfInfo ) throws IOException , InternalException { } private boolean restoreIfOffline ( DsInfo dsInfo , Set < Long > emptyDatasets ) throws IOException , InternalException { } public void delete ( String sessionId , String investigationIds , String datasetIds , String datafileIds ) throws BadRequestException , DataNotOnlineException , InsufficientPrivilegesException , InternalException , NotFoundException , NotImplementedException { } public Response getData ( String preparedId , String outname , final long offset ) throws BadRequestException , DataNotOnlineException , InsufficientPrivilegesException , InternalException , NotFoundException , NotImplementedException { } private class SO implements StreamingOutput { private long offset ; private boolean zip ; private Map < Long , DsInfo > dsInfos ; private String lockId ; private boolean compress ; private Set < DfInfoImpl > dfInfos ; SO ( Map < Long , DsInfo > dsInfos , Set < DfInfoImpl > dfInfos , long offset , boolean zip , boolean compress , String lockId ) { } @ Override public void write ( OutputStream output ) throws IOException { } } public Response getData ( String sessionId , String investigationIds , String datasetIds , String datafileIds , final boolean compress , boolean zip , String outname , final long offset ) throws BadRequestException , DataNotOnlineException , InsufficientPrivilegesException , InternalException , NotFoundException , NotImplementedException { } public String getLink ( String sessionId , long datafileId , String username ) throws BadRequestException , DataNotOnlineException , InsufficientPrivilegesException , InternalException , NotFoundException , NotImplementedException { } public String getServiceStatus ( String sessionId ) throws InsufficientPrivilegesException , InternalException { } public long getSize ( String sessionId , String investigationIds , String datasetIds , String datafileIds ) throws BadRequestException , InsufficientPrivilegesException , InternalException , NotFoundException { IdsBean . logger . info ( String . format ( "New<seq2seq4repair_space>webservice<seq2seq4repair_space>request:<seq2seq4repair_space>getSize<seq2seq4repair_space>investigationIds=%s,<seq2seq4repair_space>datasetIds=%s,<seq2seq4repair_space>datafileIds=%s" , investigationIds , datasetIds , datafileIds ) ) ; IdsBean . validateUUID ( "sessionId" , sessionId ) ; final DataSelection dataSelection = new DataSelection ( icat , sessionId , investigationIds , datasetIds , datafileIds , Returns . DATASETS_AND_DATAFILES ) ; long size = 0 ; StringBuilder sb = new StringBuilder ( ) ; int n = 0 ; for ( DfInfoImpl df : dataSelection . getDfInfo ( ) ) { if ( ( sb . length ( ) ) != 0 ) { sb . append ( ',' ) ; } sb . append ( df . getDfId ( ) ) ; <START_BUG> if ( ( n ++ ) == 100 ) { <END_BUG> size += getSizeFor ( sessionId , sb ) ; sb = new StringBuilder ( ) ; n = 0 ; } } if ( n > 0 ) { size += getSizeFor ( sessionId , sb ) ; } return size ; } private long getSizeFor ( String sessionId , StringBuilder sb ) throws InternalException { } public String getStatus ( String sessionId , String investigationIds , String datasetIds , String datafileIds ) throws BadRequestException , InsufficientPrivilegesException , InternalException , NotFoundException { } @ PostConstruct private void init ( ) { } public Boolean isPrepared ( String preparedId ) throws BadRequestException , InternalException , NotFoundException { } public boolean isReadOnly ( ) { } public boolean isTwoLevel ( ) { } public String prepareData ( String sessionId , String investigationIds , String datasetIds , String datafileIds , boolean compress , boolean zip ) throws BadRequestException , InsufficientPrivilegesException , InternalException , NotFoundException , NotImplementedException { } public Response put ( InputStream body , String sessionId , String name , long datafileFormatId , long datasetId , String description , String doi , Long datafileCreateTime , Long datafileModTime , boolean wrap , boolean padding ) throws BadRequestException , DataNotOnlineException , InsufficientPrivilegesException , InternalException , NotFoundException , NotImplementedException { } private Long registerDatafile ( String sessionId , String name , long datafileFormatId , String location , long checksum , long size , Dataset dataset , String description , String doi , Long datafileCreateTime , Long datafileModTime ) throws BadRequestException , InsufficientPrivilegesException , InternalException , NotFoundException { } private void restartUnfinishedWork ( ) throws InternalException { } public void restore ( String sessionId , String investigationIds , String datasetIds , String datafileIds ) throws BadRequestException , InsufficientPrivilegesException , InternalException , NotFoundException , NotImplementedException { } public String getIcatUrl ( ) { }

Fix:
if ( ( n ++ ) == 500 ) {