[Demonstration 1]

[Buggy Method]
@Override
public BlockStart tryStart(ParserState state, MatchedBlockParser matchedBlockParser) {
    CharSequence line = state.getLine();
    BlockParser parentParser = matchedBlockParser.getMatchedBlockParser();
    // check whether this line is the first line of whole document or not
    if (parentParser instanceof DocumentBlockParser && parentParser.getBlock().getFirstChild() == null && REGEX_BOUNDARY.matcher(line).matches()) {
        // count valid metadata line in metadata block
        int prevIndex;
        int index = nextLineEnd(line, 0);
        int validLineCount = 0;
        CharSequence subseq;
        do {
            prevIndex = index + 1;
            index = nextLineEnd(line, prevIndex);
            subseq = line.subSequence(prevIndex, index);
            if (REGEX_METADATA.matcher(subseq).matches()) {
                validLineCount++;
            }
        } while (!REGEX_BOUNDARY.matcher(subseq).matches() && prevIndex != index);
        if (validLineCount > 0) {
            return BlockStart.of(new MetadataBlockParser()).atIndex(state.getNextNonSpaceIndex());
        }
    }
    return BlockStart.none();
}

[Buggy Hunk]
} while (!REGEX_BOUNDARY.matcher(subseq).matches() && prevIndex != index);

[Patch]
} while (!REGEX_BOUNDARY.matcher(subseq).matches() && prevIndex < index);

[Demonstration 2]

[Buggy Method]
public Image getImage() throws IOException {
    Image img = ImageIO.read(f);
    int imgWidth = img.getWidth(null);
    int imgHeight = img.getHeight(null);
    double scaleFactor = (imgHeight + 0.0) / 480;
    int scaledHeight = (int) (imgHeight / scaleFactor);
    int scaledWidth = (int) (imgWidth / scaleFactor);
    Image resizedImg = img.getScaledInstance(scaledWidth, scaledHeight, Image.SCALE_SMOOTH);
    Image newImage = resizedImg;
    // Do we need to rotate the image?
    try {
        Metadata metadata = ImageMetadataReader.readMetadata(f);
        Directory directory = metadata.getFirstDirectoryOfType(ExifIFD0Directory.class);
        int orientation = 1;
        if (directory != null) {
            orientation = directory.getInt(ExifIFD0Directory.TAG_ORIENTATION);
            AffineTransform transform = getTransform(orientation, scaledWidth, scaledHeight);
            newImage = transformImage(toBufferedImage(newImage), transform);
        }
    } catch (MetadataException me) {
        me.printStackTrace();
    } catch (ImageProcessingException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return newImage;
}

[Buggy Hunk]
if (directory != null) {

[Patch]
if (directory != null && directory.containsTag(ExifIFD0Directory.TAG_ORIENTATION)) {

[Demonstration 3]

[Buggy Method]
public synchronized void updateObstaclesEnnemi() {
    if (rechercheEnCours)
        updateObstacles(gridspace.getOldAndNewObstacles());
}

[Buggy Hunk]
public synchronized void updateObstaclesEnnemi()

[Patch]
public synchronized void updateObstaclesEnnemi() throws InterruptedException