>        // see https://issues.apache.org/jira/browse/JCLOUDS-570
>        Optional<? extends Image> image = tryFind(images, idPredicate);
> -      if (!image.isPresent()) {
> -         logger.warn("Image %s not found in the image cache. Trying to get 
> it directly...", imageId);
> -         // Note that this might generate make a call to the provider 
> instead of using a cache, but
> -         // this will be executed rarely, only when an image is not present 
> in the image list but
> -         // it actually exists in the provider. It shouldn't be an expensive 
> call so using a cache just for
> -         // this corner case is overkill.
> -         image = Optional.fromNullable(getImageStrategy.getImage(imageId));
> -         if (!image.isPresent()) {
> -            throwNoSuchElementExceptionAfterLoggingImageIds(format("%s not 
> found", idPredicate), images);
> -         }
> +      if (image.isPresent()) {
> +         return image.get();
> +      }
> +
> +      logger.warn("Image %s not found in the image cache. Trying to get it 
> from the provider...", imageId);

I like the past tense approach after having fetched the image. Will change.
Regarding the log level, I'd rather use warning, as using this "hidden" images 
is something we might want to notify users (and we can expect debug level to be 
disabled). Take into account that the message will appear only once, since the 
image is being added to the cache. WDYT?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/401/files#r13656806

Reply via email to