[Demonstration 1]

[Buggy Method]
synchronized protected void downloadAssetBundle(final AssetBundle assetBundle, HttpUrl baseUrl) {
    Set<AssetBundle.Asset> missingAssets = new HashSet<AssetBundle.Asset>();
    for (AssetBundle.Asset asset : assetBundle.getOwnAssets()) {
        // Create containing directories for the asset if necessary
        File containingDirectory = asset.getFile().getParentFile();
        if (!containingDirectory.exists()) {
            if (!containingDirectory.mkdirs()) {
                didFail(new IOException("Could not create containing directory: " + containingDirectory));
                return;
            }
        }
        // If we find a cached asset, we copy it
        AssetBundle.Asset cachedAsset = cachedAssetForAsset(asset);
        if (cachedAsset != null) {
            try {
                resourceApi.copyResource(cachedAsset.getFileUri(), asset.getFileUri());
            } catch (IOException e) {
                didFail(e);
                return;
            }
        } else {
            missingAssets.add(asset);
        }
    }
    // If all assets were cached, there is no need to start a download
    if (missingAssets.isEmpty()) {
        didFinishDownloadingAssetBundle(assetBundle);
        return;
    }
    assetBundleDownloader = new AssetBundleDownloader(assetBundle, baseUrl, missingAssets);
    assetBundleDownloader.setCallback(new AssetBundleDownloader.Callback() {

        @Override
        public void onFinished() {
            assetBundleDownloader = null;
            moveDownloadedAssetBundleIntoPlace(assetBundle);
            didFinishDownloadingAssetBundle(assetBundle);
        }

        @Override
        public void onFailure(Throwable cause) {
            didFail(cause);
        }
    });
    assetBundleDownloader.resume();
}

[Buggy Hunk]
assetBundleDownloader = new AssetBundleDownloader(assetBundle, baseUrl, missingAssets);

[Patch]
assetBundleDownloader = new AssetBundleDownloader(webAppConfiguration, assetBundle, baseUrl, missingAssets);

[Demonstration 2]

[Buggy Method]
public static int maxDiff(int[] nums) {
    if (nums.length <= 1) {
        return -1;
    }
    int min = Integer.MAX_VALUE;
    int diff = 0;
    for (int n : nums) {
        diff = Math.max(n - min, diff);
        min = Math.min(n, min);
    }
    return diff != 0 ? diff : -1;
}

[Buggy Hunk]
int min = Integer.MAX_VALUE;

[Patch]
int min = nums[0];

[Demonstration 3]

[Buggy Method]
public static String generateRandomString(int stringLength) {
    char[] chars = elegibleChars.toCharArray();
    StringBuffer finalString = new StringBuffer();
    for (int i = 0; i < stringLength; i++) {
        double randomValue = Math.random();
        int randomIndex = (int) Math.round(randomValue * (chars.length - 1));
        char characterToShow = chars[randomIndex];
        finalString.append(characterToShow);
    }
    return finalString.toString();
}

[Buggy Hunk]
StringBuffer finalString = new StringBuffer();

[Patch]
final StringBuffer finalString = new StringBuffer();