[Demonstration 1]

[Buggy Method]
@Override
public void afterTestMethod(TestContext testContext) throws Exception {
    ClearCollections annotation = AnnotationUtils.findAnnotation(testContext.getTestClass(), ClearCollections.class);
    if (annotation == null) {
        return;
    }
    MongoTemplate mongoTemplate;
    try {
        mongoTemplate = testContext.getApplicationContext().getBean("mongoTemplate", MongoTemplate.class);
    } catch (NoSuchBeanDefinitionException e) {
        LOG.warn("mongoTemplate bean not found. Skipping collections cleanup.", e);
        return;
    }
    Consumer<String> consumer = annotation.drop() ? DropConsumer.of(mongoTemplate) : ClearConsumer.of(mongoTemplate);
    Arrays.stream(annotation.value()).forEach(consumer);
}

[Buggy Hunk]
Consumer<String> consumer = annotation.drop() ? DropConsumer.of(mongoTemplate) : ClearConsumer.of(mongoTemplate);

[Patch]
Consumer<String> consumer = annotation.drop() ? new DropConsumer(mongoTemplate) : new ClearConsumer(mongoTemplate);

[Demonstration 2]

[Buggy Method]
private void testTypeConversion(Class targetClass, String propertyName, Object propertyValue, Class expectedClass) {
    ConversionContextHolder.getInstance().setCurrentType(targetClass);
    Object result = convertType(propertyName, propertyValue);
    assertEquals(expectedClass, result.getClass());
    ConversionContextHolder.getInstance().setCurrentType(null);
}

[Buggy Hunk]
Object result = convertType(propertyName, propertyValue);

[Patch]
Object result = dummyConverter.convertType(propertyName, propertyValue);

[Demonstration 3]

[Buggy Method]
protected boolean allowMetadataOperations(File file, NodeRef node) {
    if (!enabled) {
        LOG.debug("Metadata writing disabled by configuration (pdfapilot.metadatawriter.enabled). Aborting");
        return false;
    }
    String extension = FilenameUtils.getExtension(file.getName());
    String sizeLimitProperty = SIZE_LIMIT_PROPERTY_PREFIX + extension + SIZE_LIMIT_PROPERTY_SUFFIX;
    String sizeLimit = globalProperties.getProperty(sizeLimitProperty);
    if (sizeLimit == null || sizeLimit.length() == 0) {
        sizeLimit = globalProperties.getProperty(SIZE_LIMIT_PROPERTY_DEFAULT);
    }
    if (sizeLimit == null || sizeLimit.length() == 0) {
        LOG.warn("No size limit found. Allowing. File name: " + file.getName());
    } else {
        long sizeLimitLong = Long.valueOf(sizeLimit) * 1024;
        if (file.length() > sizeLimitLong) {
            LOG.warn("File length is above the limit for node " + node + ". File name: " + file.getName() + " Denying.");
            return false;
        } else if (LOG.isDebugEnabled()) {
            LOG.debug("Allowing, size is below limit for node " + node + ". File name: " + file.getName());
        }
    }
    return true;
}

[Buggy Hunk]
LOG.warn("No size limit found. Allowing. File name: " + file.getName());

[Patch]
LOG.trace("No size limit found. Allowing. File name: " + file.getName());