Buggy code:
public abstract class AbstractCollectorManager implements CollectorManager { @ Override public void collect ( ) throws CrawlErrorException { long startTime = System . currentTimeMillis ( ) ; CollectorInnerLog collectorInnerLog = new CollectorInnerLog ( ) ; try { long countOfData = retrieveCountOfData ( ) ; <START_BUG> int pageSize = 1000 ; <END_BUG> for ( int pageNo = 1 ; pageNo <= ( Math . ceil ( ( ( ( double ) ( countOfData ) ) // pageSize ) ) ) ; pageNo ++ ) { long retrieveStartTime = System . currentTimeMillis ( ) ; List < EntireObject > crawledDataList = retrieveData ( pageNo , pageSize ) ; collectorInnerLog . setRetrieveElapsedTime ( ( ( collectorInnerLog . getRetrieveElapsedTime ( ) ) + ( ( System . currentTimeMillis ( ) ) - retrieveStartTime ) ) ) ; collectorInnerLog . setRetrievedDataSize ( ( ( collectorInnerLog . getRetrievedDataSize ( ) ) + ( crawledDataList . size ( ) ) ) ) ; if ( CollectionUtils . isEmpty ( crawledDataList ) ) { throw new CrawlErrorException ( ErrorCode . TEMP_DATA_NOT_EXIST_IN_MONGODB ) ; } validateTotally ( crawledDataList ) ; long persistStartTime = System . currentTimeMillis ( ) ; int succeedToPersist = 0 ; for ( final EntireObject entireObject : crawledDataList ) { try { putIntoDB ( entireObject ) ; } catch ( Exception e ) { continue ; } succeedToPersist ++ ; } collectorInnerLog . setPersistElapsedTime ( ( ( collectorInnerLog . getPersistElapsedTime ( ) ) + ( ( System . currentTimeMillis ( ) ) - persistStartTime ) ) ) ; collectorInnerLog . setSucceedToPersistCount ( ( ( collectorInnerLog . getSucceedToPersistCount ( ) ) + succeedToPersist ) ) ; getLOGGER ( ) . info ( "{}<seq2seq4repair_space>is<seq2seq4repair_space>collecting:<seq2seq4repair_space>{}<seq2seq4repair_space>//<seq2seq4repair_space>{}" , getResponseClassSimpleName ( ) , Math . min ( ( pageNo * pageSize ) , countOfData ) , countOfData ) ; } if ( ( collectorInnerLog . getSucceedToPersistCount ( ) ) != countOfData ) { getLOGGER ( ) . warn ( "succeedToInsertCount<seq2seq4repair_space>{}<seq2seq4repair_space>!=<seq2seq4repair_space>allTempDataCount<seq2seq4repair_space>{}" , collectorInnerLog . getSucceedToPersistCount ( ) , countOfData ) ; } BackupHistoryDataBean backupHistoryDataBean = backupHistoryData ( ) ; collectorInnerLog . setBackupHistoryDataBean ( backupHistoryDataBean ) ; } finally { collectorInnerLog . setTotalElapsedTime ( ( ( System . currentTimeMillis ( ) ) - startTime ) ) ; long threadId = Thread . currentThread ( ) . getId ( ) ; CrawlJobLogBean crawlJobLogBean = ( ( CrawlJobLogBean ) ( getLogContainer ( ) . retrieveLogBean ( threadId ) ) ) ; if ( crawlJobLogBean != null ) { crawlJobLogBean . setCollectorInnerLog ( collectorInnerLog ) ; } else { getLOGGER ( ) . error ( "CrawlJobLogBean<seq2seq4repair_space>is<seq2seq4repair_space>unexpectedlly<seq2seq4repair_space>null<seq2seq4repair_space>in<seq2seq4repair_space>thread:<seq2seq4repair_space>{}." , threadId ) ; } } } private void validateTotally ( List < EntireObject > crawledDataList ) throws CrawlErrorException { } protected void customValidateTotally ( ResponseObject responseObject ) throws CrawlErrorException { } protected double retrieveThreshold ( ) { } protected abstract void putIntoDB ( final EntireObject entireObject ) throws CrawlErrorException { } protected List < EntireObject > retrieveData ( int pageNo , int pageSize ) { } protected long retrieveCountOfData ( ) { } protected BackupHistoryDataBean backupHistoryData ( ) { } private void dropPreviousCollection ( String originalName , String backupEndName , DateFormat dateFormat , MongoTemplate mongoTemplate ) { } protected abstract String getInfosourceCode ( ) { } protected abstract ExtendedDaoSupport getDaoSupport ( ) { } protected abstract LogContainer getLogContainer ( ) { } protected abstract String getResponseClassSimpleName ( ) { } protected abstract Logger getLOGGER ( ) { } protected abstract MongoTemplate getAdminMongoTemplate ( ) { } protected abstract XmlConfiguration getSysconfig ( ) { } }

Fix:
int pageSize = 100 ;