[Demonstration 1]

[Buggy Method]
@Override
public Optional<PropertyUnit> retrievePropertyBy(String propertyReferenceId, User user) {
    Optional<PropertyUnit> propertyUnit = Optional.of(propertyUnitRepository.findOne(propertyReferenceId));
    PropertySearchCriteria propertySearchCriteria = new PropertySearchCriteria();
    propertySearchCriteria.setPropertyReferenceId(propertyReferenceId);
    recordUserSearchHistory(new UserSearchHistory(propertySearchCriteria, propertyUnit.isPresent() ? 1 : 0), user);
    propertyUnit.ifPresent(p -> {
        FileMetadata fileMetadata = new FileMetadata();
        fileMetadata.setReferenceId(p.getPropertyId());
        fileMetadata.setFileType(FileMetadata.FILETYPE.PHOTO.name());
        List<GridFSDBFile> attachments = gridFsService.getAllAttachments(fileMetadata, ReferenceIdFor.PROPERTY);
        p.setAttachments(FileMetadata.getFileMetaFromGridFSDBFileAsList(attachments).parallelStream().map(Attachment::new).collect(Collectors.toList()));
    });
    return propertyUnit;
}

[Buggy Hunk]
Optional<PropertyUnit> propertyUnit = Optional.of(propertyUnitRepository.findOne(propertyReferenceId));

[Patch]
Optional<PropertyUnit> propertyUnit = Optional.ofNullable(propertyUnitRepository.findOne(propertyReferenceId));

[Demonstration 2]

[Buggy Method]
@Override
public Optional<Configuration> findConfiguration(String url) {
    try {
        return Optional.ofNullable(cache.get(url));
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
    return Optional.empty();
}

[Buggy Hunk]
return Optional.ofNullable(cache.get(url));

[Patch]
return cache.get(url);

[Demonstration 3]

[Buggy Method]
public void addStartupDelayedServerConnector(ServerConnector serverConnector) {
    startupDelayedServerConnectors.add(serverConnector);
}

[Buggy Hunk]
startupDelayedServerConnectors.add(serverConnector);

[Patch]
startupDelayedServerConnectors.put(serverConnector.getId(), serverConnector);