[Demonstration 1]

[Buggy Method]
public boolean spawnMeteorite(final IMeteoriteWorld w, final int x, final int y, final int z) {
    if (!w.hasSkyLight()) {
        return false;
    }
    Block blk = w.getBlock(x, y, z);
    if (!this.validSpawn.contains(blk)) {
        // must spawn on a valid block..
        return false;
    }
    this.settings = new NBTTagCompound();
    this.settings.setInteger("x", x);
    this.settings.setInteger("y", y);
    this.settings.setInteger("z", z);
    this.settings.setInteger("blk", Block.getIdFromBlock(blk));
    this.settings.setDouble("real_sizeOfMeteorite", this.meteoriteSize);
    this.settings.setDouble("realCrater", this.realCrater);
    this.settings.setDouble("sizeOfMeteorite", this.squaredMeteoriteSize);
    this.settings.setDouble("crater", this.crater);
    this.settings.setBoolean("lava", Math.random() > 0.9);
    if (blk == Blocks.SAND) {
        this.type = new FalloutSand(w, x, y, z, this.putter, this.skyStoneDefinition);
    } else if (blk == Blocks.HARDENED_CLAY) {
        this.type = new FalloutCopy(w, x, y, z, this.putter, this.skyStoneDefinition);
    } else if (blk == Blocks.ICE || blk == Blocks.SNOW) {
        this.type = new FalloutSnow(w, x, y, z, this.putter, this.skyStoneDefinition);
    }
    int realValidBlocks = 0;
    for (int i = x - 6; i < x + 6; i++) {
        for (int j = y - 6; j < y + 6; j++) {
            for (int k = z - 6; k < z + 6; k++) {
                blk = w.getBlock(i, j, k);
                if (this.validSpawn.contains(blk)) {
                    realValidBlocks++;
                }
            }
        }
    }
    int validBlocks = 0;
    for (int i = x - 15; i < x + 15; i++) {
        for (int j = y - 15; j < y + 15; j++) {
            for (int k = z - 15; k < z + 15; k++) {
                blk = w.getBlock(i, j, k);
                if (this.invalidSpawn.contains(blk)) {
                    return false;
                }
                if (this.validSpawn.contains(blk)) {
                    validBlocks++;
                }
            }
        }
    }
    final int minBlocks = 200;
    if (validBlocks > minBlocks && realValidBlocks > 80) {
        // we can spawn here!
        int skyMode = 0;
        for (int i = x - 15; i < x + 15; i++) {
            for (int j = y - 15; j < y + 11; j++) {
                for (int k = z - 15; k < z + 15; k++) {
                    if (w.canBlockSeeTheSky(i, j, k)) {
                        skyMode++;
                    }
                }
            }
        }
        boolean solid = true;
        for (int j = y - 15; j < y - 1; j++) {
            if (w.getBlock(x, j, z) == Platform.AIR_BLOCK) {
                solid = false;
            }
        }
        if (!solid) {
            skyMode = 0;
        }
        // creator
        if (skyMode > 10) {
            this.placeCrater(w, x, y, z);
        }
        this.placeMeteorite(w, x, y, z);
        // collapse blocks...
        if (skyMode > 3) {
            this.decay(w, x, y, z);
        }
        this.settings.setInteger("skyMode", skyMode);
        w.done();
        WorldData.instance().spawnData().addNearByMeteorites(w.getWorld().provider.getDimension(), x >> 4, z >> 4, this.settings);
        return true;
    }
    return false;
}

[Buggy Hunk]
if( !w.hasSkyLight() )

[Patch]
if( !w.isNether() )

[Demonstration 2]

[Buggy Method]
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(this.getApplicationContext());
    setContentView(R.layout.activity_main);
    // Preferences
    PreferenceManager.setDefaultValues(this, R.xml.settings, false);
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    PreferenceChangeListener preferenceListener = new PreferenceChangeListener();
    preferences.registerOnSharedPreferenceChangeListener(preferenceListener);
    // Setup the toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // Setup the DrawLayout
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    mNavigationView = (NavigationView) findViewById(R.id.nav_view);
    mNavigationView.setNavigationItemSelectedListener(this);
    // Create the badge for messages
    ActionItemBadge.update(this, mNavigationView.getMenu().findItem(R.id.nav_messages), (Drawable) null, BADGE_GRAY_FULL, Integer.MIN_VALUE);
    // Hide buttons if they are disabled
    if (!preferences.getBoolean(SettingsActivity.KEY_PREF_MESSAGING, false)) {
        mNavigationView.getMenu().findItem(R.id.nav_messages).setVisible(false);
    }
    if (!preferences.getBoolean(SettingsActivity.KEY_PREF_JUMP_TOP_BUTTON, false)) {
        mNavigationView.getMenu().findItem(R.id.nav_jump_top).setVisible(false);
    }
    if (!preferences.getBoolean(SettingsActivity.KEY_PREF_BACK_BUTTON, false)) {
        mNavigationView.getMenu().findItem(R.id.nav_back).setVisible(false);
    }
    // Start the Swipe to reload listener
    swipeView = (SwipeRefreshLayout) findViewById(R.id.swipeLayout);
    swipeView.setColorSchemeResources(R.color.colorPrimary);
    swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            mWebView.reload();
        }
    });
    // Inflate the FAB
    FloatingActionButton webviewFab = (FloatingActionButton) findViewById(R.id.webviewFAB);
    webviewFab.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            mWebView.loadUrl("javascript:try{document.querySelector('button[name=\"view_overview\"]').click();}catch(_){window.location.href='http://m.facebook.com/?loadcomposer';}");
        }
    });
    // Load the WebView
    mWebView = (AdvancedWebView) findViewById(R.id.webview);
    mWebView.addPermittedHostnames(HOSTNAMES);
    mWebView.setGeolocationEnabled(preferences.getBoolean(SettingsActivity.KEY_PREF_LOCATION, false));
    mWebView.setListener(this, new WebViewListener(this, mWebView));
    mWebView.addJavascriptInterface(new JavaScriptInterfaces(this), "android");
    mWebView.getSettings().setBlockNetworkImage(preferences.getBoolean(SettingsActivity.KEY_PREF_STOP_IMAGES, false));
    callbackManager = CallbackManager.Factory.create();
    FacebookCallback<LoginResult> loginResult = new FacebookCallback<LoginResult>() {

        @Override
        public void onSuccess(LoginResult loginResult) {
            mWebView.loadUrl(chooseUrl());
            updateUserInfo();
        }

        @Override
        public void onCancel() {
            checkLoggedInState();
        }

        @Override
        public void onError(FacebookException error) {
            Snackbar.make(mWebView, "Something went wrong, please try logging in again", Snackbar.LENGTH_LONG).show();
            Log.e(Helpers.LogTag, error.toString());
            LoginManager.getInstance().logOut();
            checkLoggedInState();
        }
    };
    LoginManager.getInstance().setLoginBehavior(LoginBehavior.WEB_ONLY);
    LoginManager.getInstance().registerCallback(callbackManager, loginResult);
    if (checkLoggedInState()) {
        mWebView.loadUrl(chooseUrl());
        updateUserInfo();
    }
}

[Buggy Hunk]
Snackbar.make(mWebView, "Something went wrong, please try logging in again", Snackbar.LENGTH_LONG).show();

[Patch]
Snackbar.make(mWebView, R.string.error_login, Snackbar.LENGTH_LONG).show();

[Demonstration 3]

[Buggy Method]
public static Result service(String ownerName, String projectName, String service, boolean isAdvertise) throws IOException, UnsupportedOperationException, ServletException {
    if (!isSupportedService(service)) {
        return forbidden(String.format("Unsupported service: '%s'", service));
    }
    Project project = Project.findByOwnerAndProjectName(ownerName, projectName);
    if (project == null) {
        return notFound();
    }
    models.User user = UserApp.currentUser();
    if (!isAllowed(project, service)) {
        if (user.isAnonymous()) {
            return BasicAuthAction.unauthorized(response());
        } else {
            // If you want the Git client showing your custom message to
            // the user, the Content-Type should be exact "text/plain"
            // without any parameter. For more details, see the code at
            // https://github.com/git/git/commit/426e70d4a11ce3b4f70636d57c6a0ab16ae08a00#diff-eea0ad565ec5903a11b6023755d491cfR154
            response().setHeader("Content-Type", "text/plain");
            return forbidden(String.format("'%s' has no permission to '%s/%s'.", user.name, ownerName, projectName));
        }
    }
    if (isAdvertise) {
        return ok(RepositoryService.gitAdvertise(project, service, response()));
    } else {
        if (request().body().isMaxSizeExceeded()) {
            return status(REQUEST_ENTITY_TOO_LARGE);
        } else {
            user.visits(project);
            return ok(RepositoryService.gitRpc(project, service, request(), response()));
        }
    }
}

[Buggy Hunk]
user.name, ownerName, projectName));

[Patch]
user.loginId, ownerName, projectName));