jclouds/jclouds — pull request #432 by aledsage (2012-03-13 13:12:54+00:00)
Title: Issue 445: retry EC2ComputeService.cleanUpIncidentalResources, due to failure if done too soon after last VM terminates!

Fix for failing non-deterministic test AWSEC2ComputeServiceLiveTesttestIncidentalResourcesGetCleanedUpOnlyOnLastInstanceDestroy...

Ugly workaround is to retry the cleanUpIncidentalResources as it seems deleteSecurityGroup can fail if called immediately after the final VM enters a terminated state. If you wait a short period of time, then it does work.

I added RetryableNumTimesPredicate for this (as opposed to the time-based RetryablePredicate. I'm not particularly happy with:
* the duplication between the two, but I like using Retryables would hide the difference. That feels like a good guava pattern we should be using more.
* the exception handling in RetryableNumTimesPredicate (copied from RetryablePredicate). Why are those particular exceptions special for returning false? Should it not be left up to the predicate what exceptions to catch?