Buggy code:
public class JumpDAO { private DBCollection jumpCollection ; public JumpDAO ( final DB siteDatabase ) { } public Integer getSessionCounts ( ) { } public Integer getSessionCounts ( String start , String end ) throws ParseException { } public double getBounceRate ( ) { } public double getBounceRate ( String start , String end ) throws ParseException { } public double getInquiryRate ( ) { } public double getInquiryRate ( String start , String end ) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy-MM-dd" ) ; BasicDBObject [ ] arrayCond = new BasicDBObject [ ] { new BasicDBObject ( "date" , new BasicDBObject ( "$gt" , sdf . parse ( start ) ) ) , new BasicDBObject ( "date" , new BasicDBObject ( "$lte" , sdf . parse ( end ) ) ) , new BasicDBObject ( "type" , new BasicDBObject ( "$eq" , "countAll" ) ) } ; BasicDBObject cond = new BasicDBObject ( ) ; cond . put ( "$and" , arrayCond ) ; DBObject match = new BasicDBObject ( "$match" , cond ) ; DBObject fields = new BasicDBObject ( "type" , 1 ) ; fields . put ( "sum" , 1 ) ; DBObject project = new BasicDBObject ( "$project" , fields ) ; List < DBObject > pipeline = Arrays . asList ( match , project ) ; AggregationOptions options = AggregationOptions . builder ( ) . allowDiskUse ( true ) . batchSize ( 10000 ) . build ( ) ; Cursor cursor = jumpCollection . aggregate ( pipeline , options ) ; Integer count = null ; if ( cursor . hasNext ( ) ) { DBObject obj = cursor . next ( ) ; count = Integer . valueOf ( obj . get ( "sum" ) . toString ( ) ) ; } cursor . close ( ) ; <START_BUG> BasicDBObject [ ] arrayCond1 = new BasicDBObject [ ] { new BasicDBObject ( "date" , new BasicDBObject ( "$gt" , sdf . parse ( start ) ) ) , new BasicDBObject ( "date" , new BasicDBObject ( "$lte" , sdf . parse ( end ) ) ) , new BasicDBObject ( "type" , new BasicDBObject ( "$eq" , "inquirygit" ) ) } ; <END_BUG> BasicDBObject cond1 = new BasicDBObject ( ) ; cond1 . put ( "$and" , arrayCond1 ) ; DBObject match1 = new BasicDBObject ( "$match" , cond1 ) ; DBObject fields1 = new BasicDBObject ( "type" , 1 ) ; fields1 . put ( "sum" , 1 ) ; DBObject project1 = new BasicDBObject ( "$project" , fields1 ) ; List < DBObject > pipeline1 = Arrays . asList ( match1 , project1 ) ; AggregationOptions options1 = AggregationOptions . builder ( ) . allowDiskUse ( true ) . batchSize ( 10000 ) . build ( ) ; Cursor cursor1 = jumpCollection . aggregate ( pipeline1 , options1 ) ; Integer inquiry = null ; if ( cursor1 . hasNext ( ) ) { DBObject obj = cursor1 . next ( ) ; inquiry = Integer . valueOf ( obj . get ( "sum" ) . toString ( ) ) ; } cursor1 . close ( ) ; double bounceRate = ( ( double ) ( ( Integer ) ( inquiry ) ) ) // ( ( double ) ( ( Integer ) ( count ) ) ) ; BigDecimal decimal = new BigDecimal ( bounceRate ) ; double result = decimal . setScale ( 3 , BigDecimal . ROUND_HALF_UP ) . doubleValue ( ) ; return result * 100 ; } }

Fix:
BasicDBObject [ ] arrayCond1 = new BasicDBObject [ ] { new BasicDBObject ( "date" , new BasicDBObject ( "$gt" , sdf . parse ( start ) ) ) , new BasicDBObject ( "date" , new BasicDBObject ( "$lte" , sdf . parse ( end ) ) ) , new BasicDBObject ( "type" , new BasicDBObject ( "$eq" , "inquiry" ) ) } ;