[Demonstration 1]

[Buggy Method]
private void parseGCMemoryRecords(JavaGarbageCollectionLogLine line, String str) {
    final int index = str.lastIndexOf(',');
    if (index != -1) {
        int index2 = str.indexOf(' ', index);
        // find time
        String time = str.substring(index2).trim();
        index2 = time.indexOf(' ');
        line.gcTime = Double.parseDouble(time.substring(0, index2));
        // for the next thing
        str = str.substring(0, index);
    }
    if (str.startsWith("GC")) {
        line.gcType = GCType.MinorGC;
        str = str.substring("GC".length());
    } else if (str.startsWith("Full GC")) {
        line.gcType = GCType.FullGC;
        str = str.substring("Full GC".length());
    } else {
        throw new IllegalArgumentException("Unknown GC Type");
    }
    StringTokenReader reader = new StringTokenReader(str);
    String record;
    do {
        char peeked = reader.peek();
        if (peeked == 0) {
            break;
        }
        switch(peeked) {
            case '[':
                record = reader.readBetween('[', ']');
                parseMemoryRecordWithName(line, record);
                continue;
            case '(':
                throw new NotImplementedException();
            default:
                record = reader.readTillNext(')');
                line.heap = parseMemoryRecord(record);
                continue;
        }
    } while (true);
}

[Buggy Hunk]
char peeked = reader.peek();

[Patch]
char peeked = reader.peekNextNonWhitespace();

[Demonstration 2]

[Buggy Method]
private double[] preProcessRecording(File recording_file) throws Exception {
    double[] samples = null;
    try {
        // Get the original audio and its format
        AudioInputStream original_stream = AudioSystem.getAudioInputStream(recording_file);
        AudioFormat original_format = original_stream.getFormat();
        // Set the bit depth
        int bit_depth = original_format.getSampleSizeInBits();
        if (bit_depth != 8 && bit_depth != 16)
            bit_depth = 16;
        // If the audio is not PCM signed big endian, then convert it to PCM
        // signed
        // This is particularly necessary when dealing with MP3s
        AudioInputStream second_stream = original_stream;
        if (original_format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED || original_format.isBigEndian() == false) {
            AudioFormat new_format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, original_format.getSampleRate(), bit_depth, original_format.getChannels(), original_format.getChannels() * (bit_depth / 8), original_format.getSampleRate(), true);
            second_stream = AudioSystem.getAudioInputStream(new_format, original_stream);
        }
        // Convert to the set sampling rate, if it is not already at this
        // sampling rate.
        // Also, convert to an appropriate bit depth if necessary.
        AudioInputStream new_stream = second_stream;
        if (original_format.getSampleRate() != (float) sampling_rate || bit_depth != original_format.getSampleSizeInBits()) {
            AudioFormat new_format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, (float) sampling_rate, bit_depth, original_format.getChannels(), original_format.getChannels() * (bit_depth / 8), original_format.getSampleRate(), true);
            new_stream = AudioSystem.getAudioInputStream(new_format, second_stream);
        }
        // Extract data from the AudioInputStream
        AudioSamples audio_data = new AudioSamples(new_stream, recording_file.getPath(), false);
        // Normalise samples if this option has been requested
        if (normalise)
            audio_data.normalizeMixedDownSamples();
        // Return all channels compressed into one
        samples = audio_data.getSamplesMixedDown();
        if (preEmphasis)
            preEmphasis(samples);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(controller.getFrame(), "Bad file: " + recording_file.getName() + "\nPress to continue the process without this file.", "Info", JOptionPane.INFORMATION_MESSAGE);
        System.out.println("Bad file: " + recording_file.getName());
        // e.printStackTrace();
    }
    return samples;
}

[Buggy Hunk]
JOptionPane.showMessageDialog(controller.getFrame(), "Bad file: " + recording_file.getName() + "\nPress to continue the process without this file.", "Info",

[Patch]
JOptionPane.showMessageDialog(controller.extractionThread.getProgressFrame(), "Bad file: " + recording_file.getName() + "\nPress to continue the process without this file.", "Info",

[Demonstration 3]

[Buggy Method]
@Test
public void testDecodeMaskedPong() throws ProtocolException {
    byte[] msgBytes = new byte[] { (byte) 0x8a, (byte) 0x85, 0x37, (byte) 0xfa, 0x21, 0x3d, (byte) 0x7f, (byte) 0x9f, 0x4d, 0x51, 0x58 };
    ByteBuffer msg = ByteBuffer.allocate(msgBytes.length);
    msg.put(msgBytes);
    msg.flip();
    WsDecoder decoder = new WsDecoder();
    Decoder.Result<?> result = decoder.decode(msg, null, true);
    assertFalse(result.isOverflow());
    assertFalse(result.isUnderflow());
    assertFalse(result.closeConnection());
    assertTrue(result.isHeaderCompleted());
    assertTrue(decoder.header().isPresent());
    assertTrue(decoder.header().get() instanceof WsPongFrame);
    WsPongFrame hdr = (WsPongFrame) decoder.header().get();
    CharBuffer txt = Charset.forName("utf-8").decode(hdr.applicationData());
    assertEquals("Hello", txt.toString());
}

[Buggy Hunk]
.decode(hdr.applicationData());

[Patch]
.decode(hdr.applicationData().get());