[Demonstration 1]

[Buggy Method]
public void programBridgeDomainAclEntry(Long dpidLong, Long segmentationId, Acl acl, boolean writeFlow) {
    String nodeName = OPENFLOW + dpidLong;
    String flowId = "PipelineAcl_BridgeDomain_";
    AccessListEntries accessListEntries = acl.getAccessListEntries();
    for (Ace ace : accessListEntries.getAce()) {
        flowId = flowId + ace.getRuleName();
        Matches aclMatches = ace.getMatches();
        MatchBuilder matchBuilder = new MatchBuilder();
        matchBuilder = MatchUtils.createTunnelIDMatch(matchBuilder, BigInteger.valueOf(segmentationId.longValue()));
        Actions aclActions = ace.getActions();
        AceType aceType = aclMatches.getAceType();
        if (aceType instanceof AceEth) {
            aceEthAcl(nodeName, flowId, matchBuilder, (AceEth) aceType, writeFlow, aclActions);
        } else if (aceType instanceof AceIp) {
            aceIpAcl(nodeName, flowId, matchBuilder, (AceIp) aceType, writeFlow, aclActions);
        }
    }
}

[Buggy Hunk]
String flowId = "PipelineAcl_BridgeDomain_";

[Patch]
String flowId = "PipelineAcl_BridgeDomain_" + segmentationId.toString();

[Demonstration 2]

[Buggy Method]
@Override
protected Integer doInBackground(UploadFilePayload... uploadFilePayloads) {
    final int MAX_BUFFER_SZ = 1 * 1024;
    Integer response_code = 0;
    JSONObject json = uploadFilePayloads[0].mJSONObject;
    mCallback = uploadFilePayloads[0].mCallbackContext;
    String file_path = json.optString("filePath");
    String upload_url = json.optString("serverUrl");
    JSONObject headers = json.optJSONObject("headers");
    HttpURLConnection huc = null;
    try {
        // retrieve params from JS
        int bytes_read, bytes_available, buffer_size, total_bytes;
        byte[] buffer;
        huc = (HttpURLConnection) new URL(upload_url).openConnection();
        // get file sz
        File file = new File(file_path);
        FileInputStream fis = new FileInputStream(file);
        bytes_available = fis.available();
        final int FILE_SZ = bytes_available;
        // set custom headers
        Iterator<?> keys = headers.keys();
        while (keys.hasNext()) {
            String key = (String) keys.next();
            String val = headers.getString(key);
            huc.setRequestProperty(key, val);
        }
        // urlConnection.setRequestProperty("Connection", "Keep-Alive");
        huc.setRequestProperty("Content-Length", "" + FILE_SZ);
        huc.setRequestProperty("User-Agent", System.getProperty("http.agent"));
        // config request
        huc.setUseCaches(false);
        huc.setDoInput(true);
        huc.setDoOutput(true);
        huc.setRequestMethod("POST");
        // urlConnection.setInstanceFollowRedirects(false);
        huc.setChunkedStreamingMode(1024 * 1000);
        // urlConnection.setFixedLengthStreamingMode(bytesAvailable);
        // read input file chunks + publish progress
        OutputStream out = huc.getOutputStream();
        buffer_size = Math.min(bytes_available, MAX_BUFFER_SZ);
        buffer = new byte[buffer_size];
        bytes_read = fis.read(buffer, 0, buffer_size);
        total_bytes = bytes_read;
        while (bytes_read > 0) {
            out.write(buffer, 0, buffer_size);
            bytes_available = fis.available();
            buffer_size = Math.min(bytes_available, MAX_BUFFER_SZ);
            bytes_read = fis.read(buffer, 0, buffer_size);
            total_bytes += bytes_read;
            publishProgress(buffer_size, total_bytes, FILE_SZ);
        }
        out.flush();
        out.close();
        // get server response
        response_code = huc.getResponseCode();
        String response_message = huc.getResponseMessage();
        // back to JS
        if (response_code / 100 != 2) {
            // error
            JSONObject json_error = new JSONObject();
            json_error.put("code", response_code);
            json_error.put("source", file_path);
            json_error.put("target", upload_url);
            json_error.put("message", response_message);
            PluginResult pr = new PluginResult(PluginResult.Status.ERROR, json_error);
            mCallback.sendPluginResult(pr);
        } else {
            // ok
            InputStream is = huc.getInputStream();
            StringBuilder sb = new StringBuilder();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            String read;
            while ((read = br.readLine()) != null) {
                sb.append(read);
            }
            br.close();
            PluginResult pr = new PluginResult(PluginResult.Status.OK, sb.toString());
            mCallback.sendPluginResult(pr);
        }
    } catch (Exception e) {
        e.printStackTrace();
        JSONObject json_error = new JSONObject();
        try {
            json_error.put("code", -1);
            json_error.put("source", file_path);
            json_error.put("target", upload_url);
            json_error.put("message", e.getLocalizedMessage());
        } catch (JSONException ex) {
        }
        PluginResult pr = new PluginResult(PluginResult.Status.ERROR, json_error);
        mCallback.sendPluginResult(pr);
    } finally {
        if (huc != null) {
            huc.disconnect();
        }
    }
    return response_code;
}

[Buggy Hunk]
while (bytes_read > 0) {

[Patch]
while (bytes_read > 0 && huc.getErrorStream() == null) {

[Demonstration 3]

[Buggy Method]
private void inspect(ChannelHandlerContext ctx, String msg) {
    if (isNotEmpty(userName) && sessionId != null)
        return;
    JsonNode node;
    try {
        node = mapper.readTree(msg);
    } catch (IOException e) {
        log.error("Unexpected exception processing message {} on {}", msg, ctx.channel(), e);
        return;
    }
    if (hasValue(node, USER_NAME)) {
        userName = node.get(USER_NAME).asText();
        registry.put(msg, ctx.channel());
    }
    if (hasValue(node, SESSION_ID)) {
        sessionId = node.get(SESSION_ID).asLong();
        registry.put(sessionId, ctx.channel());
    }
}

[Buggy Hunk]
registry.put(msg, ctx.channel());

[Patch]
registry.put(userName, ctx.channel());