From b4619a35fdc81c3c99bab97be89ecc2cf867416e Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 15 Mar 2012 08:59:31 -0700 Subject: [PATCH] reverted pull 446 --- .../domain/internal/TemplateBuilderImpl.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java index ae483158dd..17f1da2d43 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/TemplateBuilderImpl.java @@ -139,20 +139,17 @@ public class TemplateBuilderImpl implements TemplateBuilder { * * If the input location is null, then the data isn't location sensitive * - * If the input location is a child (descendent, recursively) of the specified location, then we are ok. + * If the input location is a parent of the specified location, then we are ok. */ final Predicate locationPredicate = new Predicate() { @Override public boolean apply(ComputeMetadata input) { - if (location == null) return true; - Location inputLocation = input.getLocation(); - if (inputLocation == null) return true; - while (inputLocation!=null) { - if (location.equals(inputLocation)) - return true; - inputLocation = inputLocation.getParent(); - } - return false; + boolean returnVal = true; + if (location != null && input.getLocation() != null) + returnVal = location.equals(input.getLocation()) || location.getParent() != null + && location.getParent().equals(input.getLocation()) || location.getParent().getParent() != null + && location.getParent().getParent().equals(input.getLocation()); + return returnVal; } @Override