[Demonstration 1]

[Buggy Method]
@Override
public final synchronized ResultFuture<V> onCompleted(final CompletionListener listener, Executor listenerExecutor) {
    if (completionListener != null) {
        throw new IllegalStateException("Only one completion listener is supported");
    }
    this.completionListener = listener;
    this.completionListenerExecutor = listenerExecutor;
    if (isCancelled() || isResultReady()) {
        if (listenerExecutor != null) {
            listenerExecutor.execute(new Runnable() {

                @Override
                public void run() {
                    listener.onCompleted(isCancelled());
                }
            });
        } else {
            listener.onCompleted(isCancelled());
        }
    }
    return this;
}

[Buggy Hunk]
if (isCancelled() || isResultReady()) {

[Patch]
if (isCancelled() || isCompleted(peekResult())) {

[Demonstration 2]

[Buggy Method]
@Override
public RecordChangeSetListener registerQuery(String queryName, String querySpecification) {
    if (querySpecifications.containsKey(queryName)) {
        throw new IllegalStateException("Query " + queryName + " is already registered.");
    }
    querySpecifications.put(queryName, querySpecification);
    queryResults.put(queryName, HashMultiset.create());
    final Neo4jRecordChangeSetListener listener = new Neo4jRecordChangeSetListener();
    listeners.put(queryName, listener);
    return listener;
}

[Buggy Hunk]
final Neo4jRecordChangeSetListener listener = new Neo4jRecordChangeSetListener();

[Patch]
final Neo4jRecordChangeSetListener listener = new Neo4jRecordChangeSetListener(queryName);

[Demonstration 3]

[Buggy Method]
public void generateJavaPropertyForComponent(JDefinedClass beanClass, ResourceMetadata resourceMetadata, ComponentMetadata metadata) throws Exception {
    JType type = getTypeForComponent(resourceMetadata, metadata);
    String name = metadata.getName();
    if (type == null) {
        type = context.ref(Long.class);
        name = name + "ID";
    }
    String fieldName = name.equals("List") ? "_" + name : name;
    JFieldVar field = beanClass.field(JMod.PRIVATE, type, fieldName);
    if (metadata != null) {
        JAnnotationUse annotate = field.annotate(com.mailjet.api.client.model.metadata.Component.class);
        annotate.param("name", metadata.getName());
        annotate.param("type", metadata.getDataType());
        annotate.param("defaultValue", metadata.getDefaultValue());
        annotate.param("required", metadata.getIsRequired());
        annotate.param("description", metadata.getDescription());
    }
    JMethod getterMethod = beanClass.method(JMod.PUBLIC, type, "get" + capitalizeFirst(name));
    if (metadata != null) {
        JDocComment getDoc = getterMethod.javadoc();
        getDoc.add(String.format("Gets \"%1$s\" property.", metadata.getDescription()));
        getDoc.addReturn().add("the value set for the property or null if value is not present");
    }
    JBlock block = getterMethod.body();
    block._return(field);
    // Create the setter method and set the JFieldVar previously defined
    // with the given parameter
    JMethod setterMethod = beanClass.method(JMod.PUBLIC, beanClass, "set" + capitalizeFirst(name));
    setterMethod.param(type, "value");
    setterMethod.body().assign(field, JExpr.ref("value"))._return(JExpr._this());
    if (metadata != null) {
        JDocComment setDoc = setterMethod.javadoc();
        setDoc.add(String.format("Sets the specified value to \"%1$s\" property.", metadata.getDescription()));
        setDoc.addParam("value").add("the new value for the property");
        setDoc.addReturn().add("not null, the object on which this method was called ");
    }
}

[Buggy Hunk]
annotate.param("name", metadata.getName());

[Patch]
annotate.param("name", name);