[Demonstration 1]

[Buggy Method]
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
    //crashes here when rebuilding when you were in a game already
    // real users are not expected to crash here, so we won't worry about it
    Log.i(TAG, "Game has been successfully updated for game: " + ((mDBGameReference != null) ? mDBGameReference.getKey() : "null"));
    DBGame newDBGame = dataSnapshot.getValue(DBGame.class);
    if (mDBGame != null && newDBGame != null) {
        if (!mDBGame.isGameLoaded() && newDBGame.isGameLoaded()) {
            notifyFollowersLoaded();
        }
        if (!mDBGame.isGameReady() && newDBGame.isGameReady()) {
            notifyFollowersReady();
        }
        if (!mDBGame.isGameOver() && newDBGame.isGameOver()) {
            notifyFollowersOver();
        }
    } else if (newDBGame == null) {
        notifyFollowersDeleted();
    }
    mDBGame = newDBGame;
    notifyFollowers();
}

[Buggy Hunk]
} else if (newDBGame==null) {

[Patch]
} else if (newDBGame==null && !Player.getInstance().getName().equals(mDBGame.getHost())) {

[Demonstration 2]

[Buggy Method]
private void testBasicSoftwareProcessStopModes(StopMode stopProcessMode, StopMode stopMachineMode, boolean isEntityStopped) throws Exception {
    FixedListMachineProvisioningLocation<SshMachineLocation> l = getLocation();
    MyService entity = app.createAndManageChild(EntitySpec.create(MyService.class));
    entity.start(ImmutableList.of(l));
    SimulatedDriver d = (SimulatedDriver) entity.getDriver();
    Location machine = Iterables.getOnlyElement(entity.getLocations());
    d.events.clear();
    if (isEntityStopped) {
        ((EntityInternal) entity).setAttribute(ServiceStateLogic.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);
    }
    TaskAdaptable<Void> t1 = Entities.submit(entity, Effectors.invocation(entity, Startable.STOP, ConfigBag.newInstance().configure(StopSoftwareParameters.STOP_PROCESS_MODE, stopProcessMode).configure(StopSoftwareParameters.STOP_MACHINE_MODE, stopMachineMode)));
    t1.asTask().get(10, TimeUnit.SECONDS);
    if (MachineLifecycleEffectorTasksTest.canStop(stopProcessMode, isEntityStopped)) {
        assertEquals(d.events, ImmutableList.of("stop"));
    } else {
        assertTrue(d.events.isEmpty());
    }
    if (MachineLifecycleEffectorTasksTest.canStop(stopMachineMode, isEntityStopped)) {
        assertTrue(entity.getLocations().isEmpty());
        assertTrue(l.getAvailable().contains(machine));
    } else {
        assertEquals(ImmutableList.copyOf(entity.getLocations()), ImmutableList.of(machine));
        assertFalse(l.getAvailable().contains(machine));
    }
}

[Buggy Hunk]
if (MachineLifecycleEffectorTasksTest.canStop(stopMachineMode, isEntityStopped)) {

[Patch]
if (MachineLifecycleEffectorTasksTest.canStop(stopMachineMode, machine == null)) {

[Demonstration 3]

[Buggy Method]
public void cluster(Cluster cluster) {
    this.cluster = cloneCluster(cluster);
}

[Buggy Hunk]
this.cluster = cloneCluster(cluster);

[Patch]
this.cluster = cluster;