[Demonstration 1]

[Buggy Method]
private void validateLineItems(PhysicalInventoryDto dto) {
    List<PhysicalInventoryLineItemDto> lineItems = dto.getLineItems();
    if (lineItems == null || lineItems.isEmpty()) {
        throw new ValidationMessageException(new Message(ERROR_PHYSICAL_INVENTORY_LINE_ITEMS_MISSING));
    }
    boolean orderableMissing = lineItems.stream().anyMatch(lineItem -> lineItem.getOrderable() == null);
    if (orderableMissing) {
        throw new ValidationMessageException(new Message(ERROR_PHYSICAL_INVENTORY_ORDERABLE_MISSING));
    }
    checkOrderableDuplication(lineItems);
}

[Buggy Hunk]
if (lineItems == null || lineItems.isEmpty()) {

[Patch]
if (CollectionUtils.isEmpty(lineItems)) {

[Demonstration 2]

[Buggy Method]
@Override
public void run() {
    try {
        // try to export remote object on available port
        boolean exported = false;
        INameserver thisExported = null;
        for (int i = 0; i < 7 && !exported; i++) {
            try {
                thisExported = (INameserver) UnicastRemoteObject.exportObject(this, registryPort - i);
                exported = true;
            } catch (ExportException ee) {
                // when port is already in use
            }
        }
        if (!exported) {
            System.out.println("There was no port available between " + (registryPort - 6) + " and " + registryPort + " to start the nameserver on");
            return;
        }
        // start registry if root ns
        if (managedDomain == null) {
            registry = LocateRegistry.createRegistry(registryPort);
            registry.bind(rootId, thisExported);
            System.out.println("Nameserver 'root-nameserver' started");
        } else {
            registry = LocateRegistry.getRegistry(registryHost, registryPort);
            INameserver rootNs = (INameserver) registry.lookup(rootId);
            rootNs.registerNameserver(managedDomain, thisExported, thisExported);
            System.out.println("Nameserver '" + managedDomain + "' started");
        }
        // initialize shell
        shell = new Shell(componentName, userRequestStream, userResponseStream);
        shell.register(this);
        new Thread(shell).start();
    } catch (Exception e) {
        System.out.println("Nameserver could not start: " + e.getLocalizedMessage());
        try {
            exit();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    }
}

[Buggy Hunk]
System.out.println("Nameserver could not start: " + e.getLocalizedMessage());

[Patch]
System.out.println("Nameserver could not start. Was the root nameserver started? (" + e.getLocalizedMessage() + ")");

[Demonstration 3]

[Buggy Method]
private void loadData(String file) {
    ReadApiClientData reader = new ReadApiClientData();
    try {
        List<ModelData<?>> mdList = reader.readDataFromFile(file);
        for (ModelData<?> modelData : mdList) {
            store(modelData);
        }
    } catch (Exception e) {
        throw new IllegalStateException("Cannot read dummy startup data due to: " + e.getMessage(), e);
    }
}

[Buggy Hunk]
} catch (Exception e) {

[Patch]
} catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception e) {