[Demonstration 1]

[Buggy Method]
private static Channel createChannel(ChannelDefinition channelDefinition, ThingUID thingUID, String groupId, ConfigDescriptionRegistry configDescriptionRegistry) {
    ChannelType type = TypeResolver.resolve(channelDefinition.getChannelTypeUID());
    if (type == null) {
        logger.warn("Could not create channel '{}' for thing type '{}', because channel type '{}' could not be found.", channelDefinition.getId(), thingUID, channelDefinition.getChannelTypeUID());
        return null;
    }
    ChannelBuilder channelBuilder = ChannelBuilder.create(new ChannelUID(thingUID, groupId, channelDefinition.getId()), type.getItemType()).withType(type.getUID()).withDefaultTags(type.getTags());
    // If we want to override the label, add it...
    if (channelDefinition.getLabel() != null) {
        channelBuilder = channelBuilder.withLabel(channelDefinition.getLabel());
    }
    // If we want to override the description, add it...
    if (channelDefinition.getDescription() != null) {
        channelBuilder = channelBuilder.withDescription(channelDefinition.getDescription());
    }
    // Initialize channel configuration with default-values
    URI channelConfigDescriptionURI = type.getConfigDescriptionURI();
    if (configDescriptionRegistry != null && channelConfigDescriptionURI != null) {
        ConfigDescription cd = configDescriptionRegistry.getConfigDescription(channelConfigDescriptionURI);
        if (cd != null) {
            Configuration config = new Configuration();
            for (ConfigDescriptionParameter param : cd.getParameters()) {
                String defaultValue = param.getDefault();
                if (defaultValue != null) {
                    Object value = getDefaultValueAsCorrectType(param.getType(), defaultValue);
                    if (value != null) {
                        config.put(param.getName(), value);
                    }
                }
            }
            channelBuilder = channelBuilder.withConfiguration(config);
        }
    }
    channelBuilder = channelBuilder.withProperties(channelDefinition.getProperties());
    Channel channel = channelBuilder.build();
    return channel;
}

[Buggy Hunk]
.withType(type.getUID()).withDefaultTags(type.getTags());

[Patch]
.withType(type.getUID()).withDefaultTags(type.getTags()).withKind(type.getKind());

[Demonstration 2]

[Buggy Method]
public boolean run(final String[] args) throws Exception {
    // Get exist home directory
    final File home = ConfigurationHelper.getExistHome();
    // initialize with default properties, before add client properties
    properties = new Properties(defaultProps);
    // get default configuration filename from the driver class and set it in properties
    final Class<?> cl = Class.forName(properties.getProperty(DRIVER));
    final Field CONF_XML = cl.getDeclaredField("CONF_XML");
    if (CONF_XML != null && home != null) {
        final File configuration = ConfigurationHelper.lookup((String) CONF_XML.get(new String()));
        properties.setProperty(CONFIGURATION, configuration.getAbsolutePath());
    }
    properties.putAll(loadClientProperties());
    // parse command-line options
    final CommandlineOptions cOpt = getCommandlineOptions(args, properties);
    if (cOpt == null) {
        // An error occured during parsing. exit program.
        return false;
    }
    // print copyright notice - after parsing command line options, or it can't be silenced!
    if (!quiet) {
        printNotice();
    }
    // Fix "uri" property: Excalibur CLI can't parse dashes, so we need to URL encode them:
    properties.setProperty("uri", URLDecoder.decode(properties.getProperty("uri"), "UTF-8"));
    // prompt for password if needed
    if (cOpt.interactive && startGUI) {
        final boolean haveLoginData = getGuiLoginData(properties);
        if (!haveLoginData) {
            return false;
        }
    } else if (cOpt.needPasswd) {
        try {
            properties.setProperty("password", console.readLine("password: ", Character.valueOf('*')));
        } catch (final Exception e) {
        }
    }
    historyFile = new File(home, ".exist_history");
    queryHistoryFile = new File(home, ".exist_query_history");
    if (queryHistoryFile.canRead()) {
        readQueryHistory();
    }
    if (cOpt.interactive) {
        // in gui mode we use Readline for history management
        // initialize Readline library
        Terminal.setupTerminal();
        console = new ConsoleReader();
        console.addCompletor(new CollectionCompleter());
        try {
            final History history = new History(historyFile);
            console.setHistory(history);
        } catch (final Exception e) {
            // No error handling
        }
    }
    // connect to the db
    connectToDatabase();
    if (current == null) {
        if (startGUI && frame != null) {
            frame.setStatus("Could not retrieve collection " + path);
        } else {
            System.err.println("Could not retrieve collection " + path);
        }
        shutdown(false);
        return false;
    }
    final boolean processingOK = processCommandLineActions(cOpt);
    if (!processingOK) {
        return false;
    }
    if (cOpt.interactive) {
        if (startGUI) {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (final UnsupportedLookAndFeelException ulafe) {
                System.err.println("Warning: Unable to set native look and feel: " + ulafe.getMessage());
            }
            frame = new ClientFrame(this, path, properties);
            frame.setLocation(100, 100);
            frame.setSize(500, 500);
            frame.setVisible(true);
        }
        // enter interactive mode
        if ((!startGUI) || (frame == null)) {
            // No gui
            try {
                getResources();
            } catch (final XMLDBException e) {
                System.err.println("XMLDBException while " + "retrieving collection contents: " + getExceptionMessage(e));
                e.getCause().printStackTrace();
                return false;
            }
        } else {
            // with gui ; re-login posibility
            boolean retry = true;
            while (retry) {
                String errorMessage = "";
                try {
                    getResources();
                } catch (final XMLDBException e) {
                    errorMessage = getExceptionMessage(e);
                    ClientFrame.showErrorMessage("XMLDBException occurred while retrieving collection: " + errorMessage, e);
                }
                // Determine error text. For special reasons we can retry
                // to connect.
                if (errorMessage.matches("^.*Invalid password for user.*$") || errorMessage.matches("^.*User .* unknown.*") || errorMessage.matches("^.*Connection refused: connect.*")) {
                    final boolean haveLoginData = getGuiLoginData(properties);
                    if (!haveLoginData) {
                        // pressed cancel
                        return false;
                    }
                    // Need to shutdown ?? ask wolfgang
                    shutdown(false);
                    // connect to the db
                    connectToDatabase();
                } else {
                    if (!errorMessage.isEmpty()) {
                        // No pattern match, but we have an error. stop here
                        frame.dispose();
                        return false;
                    } else {
                        // No error message, continue startup.
                        retry = false;
                    }
                }
            }
        }
        messageln(EOL + "type help or ? for help.");
        if (cOpt.openQueryGui) {
            final QueryDialog qd = new QueryDialog(this, current, properties);
            qd.setLocation(100, 100);
            qd.setVisible(true);
        } else if (!startGUI) {
            readlineInputLoop(home.getAbsolutePath());
        } else {
            frame.displayPrompt();
        }
    } else {
        shutdown(false);
    }
    return true;
}

[Buggy Hunk]
final File configuration = ConfigurationHelper.lookup((String)CONF_XML.get(new String()));

[Patch]
final File configuration = ConfigurationHelper.lookup((String)CONF_XML.get(""));

[Demonstration 3]

[Buggy Method]
public boolean isUnique(String name) {
    boolean flag = true;
    for (int i = 0; i < size(); i++) {
        Node nNode = nodeList.item(i);
        Element nodeElement = (Element) nNode;
        if (nodeElement.getElementsByTagName("name").item(0).getTextContent().equals(name)) {
            flag = false;
        }
    }
    return flag;
}

[Buggy Hunk]
if(nodeElement.getElementsByTagName("name").item(0).getTextContent().equals(name)){

[Patch]
if(doc.getElementsByTagName("name").item(i).getFirstChild().getNodeValue().equals(name)){