[Demonstration 1]

[Buggy Method]
@Nullable
public static SearchResult search(String query) throws SearchErrorException {
    YouTube youtube = new YouTube.Builder(new NetHttpTransport(), new JacksonFactory(), httpRequest -> {
    }).setApplicationName("youtube-cmdline-search").build();
    YouTube.Search.List request;
    try {
        request = youtube.search().list("id");
    } catch (IOException e) {
        Bot.LOGGER.error("Error creating search for youtube video: " + query, e);
        throw new SearchErrorException(e);
    }
    String apiKey = Env.readFile().get("GOOGLE_KEY");
    request.setKey(apiKey);
    request.setQ(query);
    request.setType("video");
    request.setMaxResults(1L);
    SearchListResponse searchResponse;
    try {
        searchResponse = request.execute();
    } catch (IOException e) {
        Bot.LOGGER.error("Error executing search for youtube video: " + query, e);
        throw new SearchErrorException(e);
    }
    List<SearchResult> searchItems = searchResponse.getItems();
    if (searchItems == null) {
        Bot.LOGGER.warn("No search results found for youtube video: " + query);
        return null;
    }
    return searchItems.get(0);
}

[Buggy Hunk]
if (searchItems == null) {

[Patch]
if (searchItems.size() == 0) {

[Demonstration 2]

[Buggy Method]
@Override
public void handleGET(CoapExchange exchange) {
    Collection<Resource> resources = rdResource.getChildren();
    List<String> query = exchange.getRequestOptions().getUriQuery();
    String result = "";
    String domainQuery = "";
    String endpointQuery = "";
    TreeSet<String> endpointTypeQuery = new TreeSet<String>();
    for (String q : query) {
        LinkAttribute attr = LinkAttribute.parse(q);
        if (attr.getName().equals(LinkFormat.DOMAIN)) {
            domainQuery = attr.getValue();
        }
        if (attr.getName().equals(LinkFormat.END_POINT)) {
            endpointQuery = attr.getValue();
        }
        if (attr.getName().equals(LinkFormat.END_POINT_TYPE)) {
            Collections.addAll(endpointTypeQuery, attr.getValue().split(" "));
        }
    }
    Iterator<Resource> resIt = resources.iterator();
    while (resIt.hasNext()) {
        Resource res = resIt.next();
        if (res.getClass() == RDNodeResource.class) {
            RDNodeResource node = (RDNodeResource) res;
            if ((domainQuery.isEmpty() || domainQuery.equals(node.getDomain())) && (endpointQuery.isEmpty() || endpointQuery.equals(node.getEndpointIdentifier())) && (endpointTypeQuery.isEmpty() || endpointTypeQuery.contains(node.getEndpointType()))) {
                result += "<" + node.getContext() + ">;" + LinkFormat.END_POINT + "=\"" + node.getEndpointIdentifier() + "\"";
                result += ";" + LinkFormat.DOMAIN + "=\"" + node.getDomain() + "\"";
                if (!node.getEndpointType().isEmpty()) {
                    result += ";" + LinkFormat.RESOURCE_TYPE + "=\"" + node.getEndpointType() + "\"";
                }
                result += ",";
            }
        }
    }
    if (result.isEmpty()) {
        exchange.respond(ResponseCode.NOT_FOUND);
    } else {
        exchange.respond(ResponseCode.CONTENT, result.substring(0, result.length() - 1), MediaTypeRegistry.APPLICATION_LINK_FORMAT);
    }
}

[Buggy Hunk]
if(!node.getEndpointType().isEmpty()){

[Patch]
if(node.getEndpointType() != null && !node.getEndpointType().isEmpty()){ // fixed NullPointerException. was: if(!node.getEndpointType().isEmpty()){

[Demonstration 3]

[Buggy Method]
public void sendRequest(IProcess process, IExecutionEngine engine, IEntity systemSettings, Verb verb, String url, String xml) throws Exception {
    String apiKey = (String) systemSettings.getAttributeValue(BylaserConstants.SYSTEM_SETTINGS_XERO_CONSUMER_KEY_ATTR);
    if (apiKey == null)
        throw new Exception("XERO Invoice: XERO Consumer key not defined");
    String apiSecret = (String) systemSettings.getAttributeValue(BylaserConstants.SYSTEM_SETTINGS_XERO_CONSUMER_SECRET_ATTR);
    if (apiSecret == null)
        throw new Exception("XERO Invoice: XERO Consumer secret not defined");
    String xeroAccessToken = (String) systemSettings.getAttributeValue(BylaserConstants.SYSTEM_SETTINGS_XERO_ACC_TOKEN_ATTR);
    if (xeroAccessToken == null) {
        throw new Exception("Xero Invoice: Xero Access Token not specified. Please Authorise.");
    }
    String xeroAccessTokenSecret = (String) systemSettings.getAttributeValue(BylaserConstants.SYSTEM_SETTINGS_XERO_ACC_TOKEN_SECRET_ATTR);
    if (xeroAccessTokenSecret == null) {
        throw new Exception("Xero Invoice: Xero Access Token Secret not specified. Please Authorise.");
    }
    OAuthService service = new ServiceBuilder().provider(XeroAPI.class).apiKey(apiKey).apiSecret(apiSecret).build();
    Token accessToken = new Token(xeroAccessToken, xeroAccessTokenSecret);
    OAuthRequest request = new OAuthRequest(verb, url);
    request.addBodyParameter("xml", xml);
    service.signRequest(accessToken, request);
    System.out.println("Sending XERO Invoice request");
    Response response = request.send();
    if (!response.isSuccessful()) {
        throw new ExecutionException(response.getBody(), -1, false);
    }
    System.out.println(response.getBody());
}

[Buggy Hunk]
OAuthService service = new ServiceBuilder().provider(XeroAPI.class).apiKey(apiKey).apiSecret(apiSecret).build();

[Patch]
OAuthService service = new ServiceBuilder().provider(XEROApi.class).apiKey(apiKey).apiSecret(apiSecret).build();