[Demonstration 1]

[Buggy Method]
private void addWordsToLexicon(ContextTerm term, TreeMap<Integer, String> context) {
    /*
        create new entry if the key not exists in the _contextLexicon field
         */
    String key = normalizeKey(term.getCorresp(), term.getAna());
    SortedMap<Integer, String> leftContextTarget = context.subMap(0, true, term.getBeginTag(), true);
    Map<Integer, String> contextTarget = new TreeMap<>(context.subMap(term.getEndTag(), true, context.lastKey(), true));
    contextTarget.putAll(leftContextTarget);
    if (!_targetContext.containsKey(key)) {
        _targetContext.put(key, new ArrayList<>());
    }
    if (!_contextLexicon.containsKey(key)) {
        _contextLexicon.put(key, new LexiconProfile());
    }
    _targetContext.get(key).forEach(contextTarget::remove);
    _targetContext.get(key).addAll(new ArrayList<>(contextTarget.keySet()));
    _contextLexicon.get(key).addOccurrences(new ArrayList<>(contextTarget.values()));
}

[Buggy Hunk]
private void addWordsToLexicon(ContextTerm term, TreeMap<Integer, String> context) {

[Patch]
void addWordsToLexicon(ContextTerm term, TreeMap<Integer, String> context) {

[Demonstration 2]

[Buggy Method]
@GET
@Path("/")
@Produces({ HTML, XML })
public Response searchObjects(@QueryParam(RestParam.TERMS) String terms, @QueryParam(RestParam.QUERY) String query, @QueryParam(RestParam.MAX_RESULTS) @DefaultValue("25") int maxResults, @QueryParam(RestParam.SESSION_TOKEN) String sessionToken, @QueryParam(RestParam.RESULT_FORMAT) @DefaultValue(HTML) String format, @QueryParam(RestParam.FLASH) @DefaultValue("false") boolean flash) {
    try {
        Context context = getContext();
        String[] wantedFields = getWantedFields(m_servletRequest);
        MediaType mime = RestHelper.getContentType(format);
        FieldSearchResult result = null;
        if (wantedFields.length > 0 || sessionToken != null) {
            if (sessionToken != null) {
                result = m_access.resumeFindObjects(context, sessionToken);
            } else {
                if ((terms != null) && (terms.length() != 0)) {
                    result = m_access.findObjects(context, wantedFields, maxResults, new FieldSearchQuery(terms));
                } else {
                    result = m_access.findObjects(context, wantedFields, maxResults, new FieldSearchQuery(Condition.getConditions(query)));
                }
            }
        }
        ReadableCharArrayWriter writer = new ReadableCharArrayWriter(2048);
        if (TEXT_HTML.isCompatible(mime)) {
            getSerializer(context).searchResultToHtml(query, terms, SEARCHABLE_FIELDS, wantedFields, maxResults, result, writer);
            writer.close();
        } else {
            getSerializer(context).searchResultToXml(result, writer);
            writer.close();
        }
        return Response.ok(writer.toReader(), mime).build();
    } catch (Exception ex) {
        return handleException(ex, flash);
    }
}

[Buggy Hunk]
} else {

[Patch]
} else if ((query != null) && (query.length() != 0)) {

[Demonstration 3]

[Buggy Method]
public void init(Context context) {
    this.context = context;
    Thread.setDefaultUncaughtExceptionHandler(this);
    mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
    storageState = StorageStrategy.STRATEGY_NONE;
    inspectionAndInitializedFileSystem(context);
}

[Buggy Hunk]
public void init(Context context) {

[Patch]
public final void init(Context context) {