[Demonstration 1]

[Buggy Method]
@Override
protected void execute(CommandWriter writer, String[] args) throws Exception {
    // 获取内存快照
    Map<String, String> configs = PropertiesUtils.memory();
    // 修改内存快照
    configs.put(args[0], args[1]);
    // 通知新配置
    this.config.config(configs);
    // 同步ZK
    this.sync.sync();
    writer.write("\r\n\r\n");
}

[Buggy Hunk]
configs.put(args[0], args[1]);

[Patch]
configs.put(args[0], this.value(Arrays.copyOfRange(args, 1, args.length)));

[Demonstration 2]

[Buggy Method]
@Override
public int run(String[] args) throws Exception {
    if (args.length != 2) {
        return -1;
    }
    Job job = Job.getInstance();
    job.setJobName("hadoop-hands-on");
    job.setJarByClass(App.class);
    job.setMapperClass(MyMapper.class);
    job.setReducerClass(MyReducer.class);
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(LongWritable.class);
    FileInputFormat.addInputPath(job, new Path(args[0]));
    FileOutputFormat.setOutputPath(job, new Path(args[1]));
    return job.waitForCompletion(true) ? 0 : 1;
}

[Buggy Hunk]
job.setOutputValueClass(LongWritable.class);

[Patch]
job.setOutputValueClass(IntWritable.class);

[Demonstration 3]

[Buggy Method]
@Override
protected void cleanup(Context context) throws IOException, InterruptedException {
    log.info("Writing model");
    TopicModel readFrom = modelTrainer.getWriteModel();
    TupleWritable[] container = new TupleWritable[tupleMatrix.get(0).size()];
    for (MatrixSlice topic : readFrom) {
        Writable[] topicModelRow = { new IntWritable(-1), new VectorWritable(topic.getVector()) };
        tupleMatrix.get(topic.index()).add(0, new TupleWritable(topicModelRow));
        context.write(new IntWritable(topic.index()), new ArrayWritable(TupleWritable.class, tupleMatrix.get(topic.index()).toArray(container)));
        Arrays.fill(container, null);
    }
}

[Buggy Hunk]
context.write(new IntWritable(topic.index()), new ArrayWritable(TupleWritable.class, tupleMatrix.get(topic.index()).toArray(container)));

[Patch]
context.write(new IntWritable(topic.index()), new TupleArrayWritable(tupleMatrix.get(topic.index()).toArray(container)));