[Demonstration 1]

[Buggy Method]
@PostConstruct
public void init() {
    productManager = new ProductManager();
    productManager.init(DataSource.LOCAL);
    orderManager = new OrderManager();
    orderManager.init(DataSource.LOCAL);
    userManager = new UserManager();
    userManager.init(DataSource.LOCAL);
    User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    userId = user.getUsername();
    storeItems = new HashMap<String, List<StoreItem>>();
    cart = new HashMap<Integer, StoreItem>();
    try {
        newOrder();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

[Buggy Hunk]
storeItems = new HashMap<String, List<StoreItem>>();

[Patch]
storeItems = new ArrayList<StoreItem>();

[Demonstration 2]

[Buggy Method]
public <T> Optional<T> get(final String key) {
    return cache.getOrDefault(key, Optional.empty());
}

[Buggy Hunk]
return cache.getOrDefault(key, Optional.empty());

[Patch]
return Optional.ofNullable((T) cache.get(key));

[Demonstration 3]

[Buggy Method]
@Override
public void run() {
    logger.trace("Running 'Show licenses' command");
    StringBuilder sbQuPath = new StringBuilder();
    StringBuilder sbThirdParty = new StringBuilder();
    String buildString = qupath.getBuildString();
    if (buildString != null && !buildString.trim().isEmpty()) {
        sbQuPath.append("QuPath").append("\n");
        sbQuPath.append(buildString);
    }
    try {
        String licenseText = GeneralTools.readInputStreamAsString(ShowLicensesCommand.class.getResourceAsStream("/license/QuPathLicenseDescription.txt"));
        sbQuPath.append(licenseText);
    } catch (Exception e) {
        sbQuPath.append("Error reading license information!\n\n");
        sbQuPath.append("For the most up-to-date QuPath license information, see http://github.com/qupath/");
        logger.error("Cannot read license information", e);
    }
    // Try to get license file location
    // We assume it's in a license directory, located one level up from the current Jar
    File currentFile = null;
    try {
        currentFile = new File(ShowLicensesCommand.class.getProtectionDomain().getCodeSource().getLocation().toURI());
        logger.info("Running file: {}", currentFile);
    } catch (URISyntaxException e) {
        logger.error("Error identifying running file", e);
    }
    File fileLicenses = null;
    if (currentFile != null && currentFile.getName().toLowerCase().endsWith(".jar")) {
        File dirBase = currentFile.getParentFile();
        //			logger.debug("Base directory: {}", dirBase);
        if (new File(dirBase, "licenses").isDirectory())
            fileLicenses = new File(dirBase, "THIRD-PARTY.txt");
        else if (new File(dirBase.getParentFile(), "licenses").isDirectory())
            fileLicenses = new File(new File(dirBase.getParentFile(), "licenses"), "THIRD-PARTY.txt");
        logger.debug("License file: {}", fileLicenses);
    }
    if (fileLicenses == null || !fileLicenses.isFile()) {
        sbThirdParty.append("No license information could be found for third party dependencies.");
    } else {
        sbThirdParty.append("THIRD PARTY LICENSES");
        sbThirdParty.append("\n");
        sbThirdParty.append("----------------------");
        sbThirdParty.append("\n");
        try {
            for (String line : Files.readAllLines(fileLicenses.toPath(), StandardCharsets.UTF_8)) {
                sbThirdParty.append(line);
                sbThirdParty.append("\n");
            }
        } catch (IOException e) {
            logger.error("Error reading license information", e);
        }
    }
    // Create dialog to show
    Stage dialog = new Stage();
    dialog.initOwner(qupath.getStage());
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.setTitle("Licenses");
    TextArea textAreaQuPath = getTextArea(sbQuPath.toString());
    BorderPane paneThirdParty = new BorderPane(getTextArea(sbThirdParty.toString()));
    if (fileLicenses != null) {
        Button btnThirdParty = new Button("View third party licenses");
        File dirLicenses = fileLicenses.getParentFile();
        btnThirdParty.setOnAction(e -> {
            DisplayHelpers.openFile(dirLicenses);
        });
        btnThirdParty.setMaxWidth(Double.MAX_VALUE);
        paneThirdParty.setBottom(btnThirdParty);
    }
    Tab tabQuPath = new Tab("QuPath", textAreaQuPath);
    Tab tabThirdParty = new Tab("Third party", paneThirdParty);
    TabPane tabPane = new TabPane(tabQuPath, tabThirdParty);
    tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
    dialog.setScene(new Scene(tabPane));
    dialog.show();
}

[Buggy Hunk]
sbQuPath.append(buildString);

[Patch]
sbQuPath.append(buildString).append("\n\n");