Buggy code:
@ Singleton public class TripsManager { private final TripOfferDAO tripOfferDAO ; private final DirectionsManager directionsManager ; @ Inject TripsManager ( TripOfferDAO tripOfferDAO , DirectionsManager directionsManager ) { } public TripOffer addOffer ( User owner , TripOfferDescription description ) throws Exception { } public List < TripOffer > findAllOffers ( ) { } public Optional < TripOffer > findOffer ( long offerId ) { } public void deleteOffer ( TripOffer offer ) { } public List < TripMatch > findMatches ( User passenger , TripRequestDescription requestDescription ) throws Exception { List < TripMatch > matches = new ArrayList < > ( ) ; List < TripOffer > offers = findAllOffers ( ) ; if ( ( offers . size ( ) ) == 0 ) return matches ; List < Route > diversionRoutes = new ArrayList < > ( ) ; for ( TripOffer offer : offers ) { Route route = offer . getRoute ( ) ; RouteLocation startLocation = route . getStart ( ) ; RouteLocation endLocation = route . getEnd ( ) ; List < RouteLocation > waypoints = new ArrayList < > ( ) ; waypoints . add ( requestDescription . getStart ( ) ) ; waypoints . add ( requestDescription . getEnd ( ) ) ; diversionRoutes = directionsManager . getDirections ( startLocation , endLocation , waypoints ) ; if ( ( diversionRoutes == null ) || ( ( diversionRoutes . size ( ) ) == 0 ) ) return new ArrayList < > ( ) ; Route diversionRoute = diversionRoutes . get ( 0 ) ; System . out . println ( ( "Additional<seq2seq4repair_space>meters:<seq2seq4repair_space>" + ( ( diversionRoute . getDistanceInMeters ( ) ) - ( route . getDistanceInMeters ( ) ) ) ) ) ; System . out . println ( ( "Max<seq2seq4repair_space>Diversion:<seq2seq4repair_space>" + ( offer . getMaxDiversionInMeters ( ) ) ) ) ; if ( ( ( diversionRoute . getDistanceInMeters ( ) ) - ( route . getDistanceInMeters ( ) ) ) < ( offer . getMaxDiversionInMeters ( ) ) ) { List < Route > passengerRoutes = directionsManager . getDirections ( requestDescription . getStart ( ) , requestDescription . getEnd ( ) ) ; if ( ( passengerRoutes == null ) || ( passengerRoutes . isEmpty ( ) ) ) return new ArrayList < > ( ) ; Route passengerRoute = passengerRoutes . get ( 0 ) ; long tripLength = passengerRoute . getDistanceInMeters ( ) ; long tripDuration = passengerRoute . getDurationInSeconds ( ) ; <START_BUG> int price = ( ( int ) ( ( tripLength // 100.0F ) * ( offer . getPricePerKmInCents ( ) ) ) ) ; <END_BUG> TripMatch match = new TripMatch ( 0 , diversionRoute , tripLength , tripDuration , price , offer . getPricePerKmInCents ( ) , offer . getDriver ( ) , passenger ) ; matches . add ( match ) ; } } if ( ( matches . size ( ) ) < 2 ) return matches ; Collections . sort ( matches , new Comparator < TripMatch > ( ) { @ Override public int compare ( TripMatch m1 , TripMatch m2 ) { if ( ( m1 . getPricePerKilometerInCents ( ) ) == ( m2 . getPricePerKilometerInCents ( ) ) ) return 0 ; return ( m1 . getPricePerKilometerInCents ( ) ) < ( m2 . getPricePerKilometerInCents ( ) ) ? - 1 : 1 ; } } ) ; int samePrice = 1 ; int lowestPrice = matches . get ( 0 ) . getPricePerKilometerInCents ( ) ; while ( ( samePrice < ( matches . size ( ) ) ) && ( ( matches . get ( samePrice ) . getPricePerKilometerInCents ( ) ) == lowestPrice ) ) { System . out . println ( ( ( ( "Match:<seq2seq4repair_space>" + ( matches . get ( samePrice ) . getEstimatedPriceInCents ( ) ) ) + "<seq2seq4repair_space>" ) + ( matches . get ( samePrice ) . getPricePerKilometerInCents ( ) ) ) ) ; samePrice ++ ; } if ( samePrice == ( matches . size ( ) ) ) return matches ; int secondLowestPrice = matches . get ( samePrice ) . getPricePerKilometerInCents ( ) ; System . out . println ( ( "Second<seq2seq4repair_space>lowest<seq2seq4repair_space>price:<seq2seq4repair_space>" + secondLowestPrice ) ) ; while ( ( matches . size ( ) ) > samePrice ) matches . remove ( ( ( matches . size ( ) ) - 1 ) ) ; for ( TripMatch m : matches ) { m . setPricePerKilometerInCents ( secondLowestPrice ) ; m . setEstimatedPriceInCents ( ( ( int ) ( ( ( m . getDiversionInMeters ( ) ) // 1000.0F ) * ( m . getPricePerKilometerInCents ( ) ) ) ) ) ; System . out . println ( ( ( ( "Match:<seq2seq4repair_space>" + ( m . getEstimatedPriceInCents ( ) ) ) + "<seq2seq4repair_space>" ) + ( m . getPricePerKilometerInCents ( ) ) ) ) ; } return matches ; } }

Fix:
int price = ( ( int ) ( ( tripLength // 1000.0F ) * ( offer . getPricePerKmInCents ( ) ) ) ) ;