nacx commented on this pull request. Thanks @tormath1!
> @@ -220,6 +225,14 @@ protected void configure() { return CacheBuilder.newBuilder().build(in); } + +@Provides +@Singleton +protected LoadingCache<URI, Optional<Firewall>> firewallsMap( + CacheLoader<URI, Optional<Firewall>> in) { + return CacheBuilder.newBuilder().build(in); +} [minor] fix indentation > @@ -96,4 +97,9 @@ @Named("Images:get") @GET @Fallback(NullOnNotFoundOr404.class) @Nullable Image image(@EndpointParam URI selfLink); + + /** Returns a firewall by self-link or null if not found*/ [minor] fix leading and trailing spaces in the comment. > + + @Override + public Optional<Firewall> load(URI key) throws ExecutionException { + try { + return Optional.fromNullable(resources.firewall(key)); + } catch (Exception ex) { + throw new ExecutionException(message(key, ex), ex); + } + } + + public static String message(URI key, Exception ex) { + return String.format("could not find firewall %s: %s", key.toString(), ex.getMessage()); + } + + +} jclouds uses a 3 space indent. Please format the code accordingly. > if (options.getNetworks().isEmpty()) { networkName = DEFAULT_NETWORK_NAME; } else { Iterator<String> iterator = options.getNetworks().iterator(); - networkName = nameFromNetworkString(iterator.next()); + net = iterator.next(); + if (net.startsWith("projects")) { + isFullURI = true; + } Just `isFullURI = net.startsWith("projects")` > checkArgument(!iterator.hasNext(), "Error: Please specify only one network/subnetwork in TemplateOptions when using GCE."); } String region = ZONE == location.getScope() ? location.getParent().getId() : location.getId(); - Optional<Subnetwork> subnet = subnetworksMap.getUnchecked(fromRegionAndName(region, networkName)); + Optional<Subnetwork> subnet; + + subnet = isFullURI ? Optional.fromNullable(resources.subnetwork(URI.create(net))) : subnetworksMap.getUnchecked(fromRegionAndName(region, networkName)); Could this logic be abstracted in the subnet cache? Otherwise, we are catching subnets only if the provided ID is not the full URI, which does not seem right? This way you save an extra call in the adapter. With the current code, you are calling the `resources` API here and calling it again in the adapter. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds/pull/1236#pullrequestreview-150895576