[Demonstration 1]

[Buggy Method]
public static void main(String[] args) throws Exception {
    SparkConf conf = new SparkConf().setAppName("goMonitor.SparkDaily");
    JavaSparkContext context = new JavaSparkContext(conf);
    InjectorManager.setInjector(Guice.createInjector(new SparkInjectModule()));
    MachineRecordRepository machineRecordRepository = InjectorManager.getInjector().getInstance(MachineRecordRepository.class);
    List<String> ipAddress = machineRecordRepository.getMachineIpAddresses();
    JavaRDD<String> ipRDD = context.parallelize(ipAddress);
    System.out.println(ipRDD.flatMap(new GetSystemInfoByIPFunction()).count());
}

[Buggy Hunk]
System.out.println(ipRDD.flatMap(new GetSystemInfoByIPFunction()).count());

[Patch]
ipRDD.flatMap(new GetSystemInfoByIPFunction()).foreach((s) -> System.out.println(s));

[Demonstration 2]

[Buggy Method]
public static <K, V extends Comparable> LinkedHashMap<K, V> sortByValues(Map<K, V> map, boolean reverse) {
    int moves = 0;
    boolean firstRun = true;
    List<Map.Entry<K, V>> entrySet = new ArrayList<>(map.entrySet());
    while (moves > 0 || firstRun) {
        moves = 0;
        firstRun = false;
        for (int i = 1; i < entrySet.size(); i++) {
            Map.Entry<K, V> entryA = entrySet.get(i - 1);
            Map.Entry<K, V> entryB = entrySet.get(i);
            if (reverse ? entryA.getValue().compareTo(entryB.getValue()) < 0 : entryA.getValue().compareTo(entryB.getValue()) > 0) {
                entrySet.set(i - 1, entryB);
                entrySet.set(i, entryA);
                moves++;
            }
        }
    }
    LinkedHashMap<K, V> sorted = new LinkedHashMap<>();
    for (Map.Entry<K, V> entry : entrySet) {
        sorted.put(entry.getKey(), entry.getValue());
    }
    return sorted;
}

[Buggy Hunk]
public static <K, V extends Comparable> LinkedHashMap<K, V> sortByValues(Map<K, V> map, boolean reverse)

[Patch]
public static <K, V extends Comparable<V>> LinkedHashMap<K, V> sortByValues(Map<K, V> map, boolean reverse)

[Demonstration 3]

[Buggy Method]
public Passanger findPassanger(int id) {
    return db.PassangerDatabase.get(id);
}

[Buggy Hunk]
public Passanger findPassanger(int id)

[Patch]
public final Passanger findPassanger(int id)