[issue 795] Fixing a compilation failure in EC2ListNodesStrategy - looks like something happened with generic casts between Java 6 and 7 (see http://stackoverflow.com/questions/8637937/why-does-a-generic-cast-of-a-list-extends-set-to-listset-succeed-on-sun)

This commit is contained in:
Andrew Phillips 2011-12-26 18:19:01 +00:00
parent 1b98e09bac
commit 1ba75f623f
1 changed files with 7 additions and 2 deletions

View File

@ -96,12 +96,17 @@ public class EC2ListNodesStrategy implements ListNodesStrategy {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public Future<Set<? extends Reservation<? extends RunningInstance>>> apply(String from) { public Future<Set<? extends Reservation<? extends RunningInstance>>> apply(String from) {
return (Future<Set<? extends Reservation<? extends RunningInstance>>>) client return castToSpecificTypedFuture(client.getInstanceServices().describeInstancesInRegion(from));
.getInstanceServices().describeInstancesInRegion(from);
} }
}, executor, null, logger, "reservations"); }, executor, null, logger, "reservations");
return concat(concat(reservations)); return concat(concat(reservations));
} }
// "hide" this cast (i.e. do not perform inline) from the Java 7 compiler - see http://stackoverflow.com/questions/8637937/why-does-a-generic-cast-of-a-list-extends-set-to-listset-succeed-on-sun
@SuppressWarnings("unchecked")
private static <T> Future<T> castToSpecificTypedFuture(Future<? extends T> input) {
return (Future<T>) input;
}
} }