> + private final LoadingCache<String, DriveInfo> cache;
> +
> + @Inject
> + public DeviceToVolume(LoadingCache<String, DriveInfo> cache) {
> + this.cache = checkNotNull(cache, "cache");
> + }
> +
> + @Override
> + public Volume apply(Device input) {
> + VolumeBuilder builder = new VolumeBuilder();
> + builder.id(input.getId());
> + try {
> + DriveInfo drive = cache.getUnchecked(input.getDriveUuid());
> + builder.size(drive.getSize().floatValue());
> + } catch (NullPointerException e) {
> + logger.debug("drive %s not found", input.getDriveUuid());
Is there a better way to handle drive absence than catching a NPE?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/12/files#r5278649