[Demonstration 1]

[Buggy Method]
@Override
public void onValidationSucceeded() {
    _loginButton.setEnabled(false);
    final ProgressDialog progressDialog = new ProgressDialog(Login.this, R.style.AppTheme_Dark_Dialog);
    progressDialog.setIndeterminate(true);
    progressDialog.setMessage("Authenticating...");
    progressDialog.show();
    String email = _emailText.getText().toString();
    String password = _passwordText.getText().toString();
    ArrayList scope = new ArrayList();
    scope.add("all_all");
    UserAuth user = new UserAuth(email, password, scope, "AGENT_CONSOLE", "e8ea7bb0-5026-11e7-a69b-b153a7c332b9");
    Call<UserAuthResponse> call1 = apiInterface.authenticate(user);
    call1.enqueue(new Callback() {

        @Override
        public void onResponse(Call call, Response response) {
            if (response.isSuccessful() && response.body() instanceof UserAuthResponse) {
                UserAuthResponse userAuthResponse = (UserAuthResponse) response.body();
                progressDialog.dismiss();
                Log.d(TAG, userAuthResponse.getToken());
                sessionManager.createLoginSession("", userAuthResponse.getToken());
                onLoginSuccess();
            } else {
                String message = "Invalid email and/or password";
                try {
                    Log.d(TAG, response.errorBody().string());
                } catch (IOException e) {
                    e.printStackTrace();
                }
                progressDialog.dismiss();
                onLoginFailed(message);
            }
        }

        @Override
        public void onFailure(Call call, Throwable t) {
            call.cancel();
        }
    });
}

[Buggy Hunk]
call1.enqueue(new Callback() {

[Patch]
call1.enqueue(new Callback<UserAuthResponse>() {

[Demonstration 2]

[Buggy Method]
public void sendMessage(GwRequest msg) throws MqttException {
    final GwHeaders h = msg.headers();
    final Operation operation = h.get(GW_OPERATION);
    final String topic = h.get(GW_PATH);
    final int qos = max(0, min(2, h.get(GW_QOS)));
    switch(operation) {
        // CREATE or UPDATE is mapped as a publish, but this plugin treats CREATE as a retained message
        case CREATE:
        case UPDATE:
            final MqttMessage mqttMessage = new MqttMessage(msg.payload().asBytes());
            mqttMessage.setRetained(operation == Operation.CREATE);
            mqttMessage.setQos(qos);
            client.publish(topic, mqttMessage);
            replyLink.ack(msg.getSequence());
            break;
        // MQTT doesn't really specify a delete operation, but when a retained message with a zero byte payload
        // is sent, the broker removes the retained message
        case DELETE:
            client.publish(topic, ArrayUtils.EMPTY_BYTE_ARRAY, 0, true);
            replyLink.ack(msg.getSequence());
            break;
        // READ and OBSERVE are unsurprisingly directly mapped to subscribe
        case READ:
        case OBSERVE:
            synchronized (control) {
                final boolean marked = control.mark(topic, operation);
                if (!marked) {
                    client.subscribe(topic, qos);
                    logger.trace("subscribed on topic %s", topic);
                }
            }
            break;
        // UNOBSERVE is the equivalent of unsubscribe
        case UNOBSERVE:
            synchronized (control) {
                control.remove(topic);
            }
            client.unsubscribe(topic);
            logger.trace("unsubscribed from topic %s", topic);
            break;
    }
}

[Buggy Hunk]
final int qos = max(0, min(2, h.get(GW_QOS)));

[Patch]
final int qos = max(0, min(2, h.get(GW_QOS, (byte) 0)));

[Demonstration 3]

[Buggy Method]
@Test
public void hasDescription() {
    assertEquals("Two of SPADES", card1.description());
}

[Buggy Hunk]
assertEquals( "Two of SPADES",card1.description() );

[Patch]
assertEquals( "Two of SPADES",card1.cardRank() );