[Demonstration 1]

[Buggy Method]
static public void readFile(String path, String encoding, final Promise promise) {
    String resolved = normalizePath(path);
    if (resolved != null)
        path = resolved;
    try {
        byte[] bytes;
        if (resolved != null && resolved.startsWith(RNFetchBlobConst.FILE_PREFIX_BUNDLE_ASSET)) {
            String assetName = path.replace(RNFetchBlobConst.FILE_PREFIX_BUNDLE_ASSET, "");
            long length = RNFetchBlob.RCTContext.getAssets().openFd(assetName).getLength();
            bytes = new byte[(int) length];
            InputStream in = RNFetchBlob.RCTContext.getAssets().open(assetName);
            in.read(bytes, 0, (int) length);
            in.close();
        } else // issue 287
        if (resolved == null) {
            InputStream in = RNFetchBlob.RCTContext.getContentResolver().openInputStream(Uri.parse(path));
            int length = (int) in.available();
            bytes = new byte[length];
            in.read(bytes);
            in.close();
        } else {
            File f = new File(path);
            int length = (int) f.length();
            bytes = new byte[length];
            FileInputStream in = new FileInputStream(f);
            in.read(bytes);
            in.close();
        }
        switch(encoding.toLowerCase()) {
            case "base64":
                promise.resolve(Base64.encodeToString(bytes, Base64.NO_WRAP));
                break;
            case "ascii":
                WritableArray asciiResult = Arguments.createArray();
                for (byte b : bytes) {
                    asciiResult.pushInt((int) b);
                }
                promise.resolve(asciiResult);
                break;
            case "utf8":
                promise.resolve(new String(bytes));
                break;
            default:
                promise.resolve(new String(bytes));
                break;
        }
    } catch (Exception err) {
        promise.reject("ReadFile Error", err.getLocalizedMessage());
    }
}

[Buggy Hunk]
asciiResult.pushInt((int)b);

[Patch]
asciiResult.pushInt((int)b & 0xff);

[Demonstration 2]

[Buggy Method]
public static void getActor(final ObjectResolveHandler<Actor> rh) {
    Session.execute("actor.self.describe", new ServiceResponseHandler() {

        @Override
        public void processResponse(XmlElement xe, List<Output> outputs) throws Throwable {
            if (xe != null) {
                String actorType = xe.value("actor/@type");
                String actorName = xe.value("actor/@name");
                if (actorName != null) {
                    rh.resolved(new Actor(actorType, actorName));
                    return;
                }
            }
            rh.resolved(null);
        }
    });
}

[Buggy Hunk]
rh.resolved(new Actor(actorType, actorName));

[Patch]
rh.resolved(new Actor(actorName, actorType));

[Demonstration 3]

[Buggy Method]
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    baseRequest.setHandled(true);
    //defaulted
    String sandboxId = "1";
    String sandboxName = "name";
    try {
        long startedRequest = System.currentTimeMillis();
        String requestId = UUID.randomUUID().toString();
        //convert incoming request to InstanceHttpRequest
        HttpRuntimeRequest runtimeRequest = servletConverter.httpServletToInstanceHttpRequest(request);
        //get a runtime service instance
        RuntimeService runtimeService = context.getBean(RuntimeService.class);
        //create and lookup routing table
        RoutingTable routingTable = cache.getRoutingTableForSandboxId(sandboxId);
        if (routingTable == null) {
            routingTable = runtimeService.handleRoutingTableRequest(sandboxId);
            cache.setRoutingTableForSandboxId(sandboxId, routingTable);
        }
        MatchedRouteDetails routeMatch = findMatchedRoute(runtimeRequest, routingTable);
        //if no route match for given request, then log message and send error response.
        if (routeMatch == null) {
            logger.warn("** Error processing request for {} {} - Invalid route", runtimeRequest.getMethod(), runtimeRequest.getPath() == null ? request.getRequestURI() : runtimeRequest.getPath());
            response.setStatus(500);
            response.setHeader("Content-Type", "application/json");
            response.getWriter().write(convertExceptionMessageToResponse("Invalid route"));
            return;
        }
        //log request with route
        logRequest(runtimeRequest, routeMatch, requestId);
        //run request
        HTTPRequest httpRequest = serviceConverter.fromInstanceHttpRequest(runtimeService.getSandboxScriptEngine().getEngine(), runtimeRequest);
        HttpRuntimeResponse runtimeResponse = null;
        if ("options".equalsIgnoreCase(httpRequest.getMethod())) {
            //if options request, send back CORS headers
            runtimeResponse = new HttpRuntimeResponse("", 200, new HashMap<>(), new ArrayList<>());
            runtimeResponse.getHeaders().put("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS");
            runtimeResponse.getHeaders().put("Access-Control-Allow-Origin", runtimeRequest.getHeaders().getOrDefault("Origin", "*"));
            runtimeResponse.getHeaders().put("Access-Control-Allow-Headers", runtimeRequest.getHeaders().getOrDefault("Access-Control-Request-Headers", "Content-Type"));
            runtimeResponse.getHeaders().put("Access-Control-Allow-Credentials", "true");
        } else {
            //otherwise process normally
            runtimeResponse = runtimeService.handleRequest(sandboxId, sandboxId, httpRequest);
        }
        runtimeResponse.setDurationMillis(System.currentTimeMillis() - startedRequest);
        logConsole(runtimeService);
        logResponse(runtimeResponse, requestId);
        //set response data back onto servlet response
        mapResponse(runtimeResponse, response);
    } catch (Exception e) {
        logger.error("Error processing request", e);
        //write out error as json
        response.setStatus(500);
        response.setHeader("Content-Type", "application/json");
        response.getWriter().write(convertExceptionToResponse(e));
    }
}

[Buggy Hunk]
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {

[Patch]
public synchronized void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {