Buggy code:
public class TrainingAnalysis extends JFrame { private static final long serialVersionUID = - 7939830514817673972L ; private JLabel fiveSecondPower ; private JLabel fiveSecondWKG ; private JLabel oneMinutePower ; private JLabel oneMinuteWKG ; private JLabel fiveMinutePower ; private JLabel fiveMinuteWKG ; private JLabel twentyMinutePower ; private JLabel twentyMinuteWKG ; private JLabel maxHeartRate ; private JLabel aveHeartRate ; private JLabel minHeartRate ; private JLabel fTHR ; private JLabel distance ; private JLabel totalPower ; private JLabel avePower ; private JLabel maxPower ; private JLabel qPower ; private JLabel ftPower ; private JLabel ft1Power ; private JLabel ft20Power ; private JLabel load ; private JLabel stress ; SimpleDateFormat df ; DecimalFormat decimalFormat = new DecimalFormat ( "#.##" ) ; private JLabel time ; private static Logger logger = LogManager . getLogger ( "Training<seq2seq4repair_space>Analysis" ) ; private final UserPreferences userPrefs = UserPreferences . INSTANCE ; public TrainingAnalysis ( ) { } public void show ( WorkoutData workoutData ) { } public static WorkoutData analyze ( ArrayList < Telemetry > data ) { WorkoutData workoutData = new WorkoutData ( ) ; if ( ( data == null ) || ( ( data . size ( ) ) == 0 ) ) { TrainingAnalysis . logger . info ( "No<seq2seq4repair_space>training<seq2seq4repair_space>data<seq2seq4repair_space>to<seq2seq4repair_space>analyze" ) ; return null ; } Telemetry firstPoint = data . get ( 0 ) ; Telemetry lastPoint = data . get ( ( ( data . size ( ) ) - 1 ) ) ; long len = ( lastPoint . getTime ( ) ) - ( firstPoint . getTime ( ) ) ; workoutData . setTime ( len ) ; workoutData . setDate ( firstPoint . getTime ( ) ) ; <START_BUG> workoutData . setDistanceMeters ( lastPoint . getDistanceMeters ( ) ) ; <END_BUG> int maxCad = 0 ; long aveCad = 0 ; int maxHR = 0 ; long aveHR = 0 ; int minHR = 220 ; double tPower = 0 ; Telemetry last = null ; int maxPwr = 0 ; double qPwr = 0 ; TreeMap < Integer , Long > pow = new TreeMap < Integer , Long > ( ) ; TreeMap < Integer , Long > hr = new TreeMap < Integer , Long > ( ) ; Telemetry first = null ; for ( Telemetry t : data ) { if ( first == null ) { first = t ; } else { if ( pow . containsKey ( t . getPower ( ) ) ) { long time = pow . get ( t . getPower ( ) ) ; pow . put ( t . getPower ( ) , ( time + ( ( t . getTime ( ) ) - ( first . getTime ( ) ) ) ) ) ; } else { pow . put ( t . getPower ( ) , ( ( t . getTime ( ) ) - ( first . getTime ( ) ) ) ) ; } if ( hr . containsKey ( t . getHeartRate ( ) ) ) { long time = hr . get ( t . getHeartRate ( ) ) ; hr . put ( t . getHeartRate ( ) , ( time + ( ( t . getTime ( ) ) - ( first . getTime ( ) ) ) ) ) ; } else { hr . put ( t . getHeartRate ( ) , ( ( t . getTime ( ) ) - ( first . getTime ( ) ) ) ) ; } first = t ; } if ( maxPwr < ( t . getPower ( ) ) ) { maxPwr = t . getPower ( ) ; } qPwr += ( t . getPower ( ) ) * ( t . getPower ( ) ) ; if ( ( t . getHeartRate ( ) ) > maxHR ) { maxHR = t . getHeartRate ( ) ; } if ( ( t . getCadence ( ) ) > maxCad ) { maxCad = t . getCadence ( ) ; } if ( ( ( t . getHeartRate ( ) ) != ( - 1 ) ) && ( ( t . getHeartRate ( ) ) < minHR ) ) { minHR = t . getHeartRate ( ) ; } if ( last != null ) { tPower += ( t . getPower ( ) ) * ( ( t . getTime ( ) ) - ( last . getTime ( ) ) ) ; if ( ( t . getHeartRate ( ) ) > 0 ) { aveHR += ( t . getHeartRate ( ) ) * ( ( t . getTime ( ) ) - ( last . getTime ( ) ) ) ; } aveCad += ( t . getCadence ( ) ) * ( ( t . getTime ( ) ) - ( last . getTime ( ) ) ) ; } last = t ; } int fiveSecPwr = 0 ; int oneMinPwr = 0 ; int fiveMinPwr = 0 ; int twentyMinPwr = 0 ; long timeInMillis = 0 ; for ( Map . Entry < Integer , Long > entry : pow . descendingMap ( ) . entrySet ( ) ) { timeInMillis += entry . getValue ( ) ; if ( ( timeInMillis >= 5000 ) && ( fiveSecPwr == 0 ) ) { fiveSecPwr = entry . getKey ( ) ; } if ( ( timeInMillis >= 60000 ) && ( oneMinPwr == 0 ) ) { oneMinPwr = entry . getKey ( ) ; } if ( ( timeInMillis >= 300000 ) && ( fiveMinPwr == 0 ) ) { fiveMinPwr = entry . getKey ( ) ; } if ( ( timeInMillis >= 1200000 ) && ( twentyMinPwr == 0 ) ) { twentyMinPwr = entry . getKey ( ) ; } } workoutData . setFiveSecondPwr ( fiveSecPwr ) ; workoutData . setFiveMinutePwr ( fiveMinPwr ) ; workoutData . setOneMinutePwr ( oneMinPwr ) ;

Fix:
workoutData . setDistanceMeters ( ( ( lastPoint . getDistanceMeters ( ) ) - ( firstPoint . getDistanceMeters ( ) ) ) ) ;