Buggy code:
@ Slf4j @ Component @ DependsOn ( "plugin-manager" ) public class CloudService { @ Resource private QueryHelper queryHelper ; @ Resource ( name = "alien-es-dao" ) private IGenericSearchDAO alienDAO ; @ Resource private PaaSProviderFactoriesService paaSProviderFactoriesService ; @ Resource private PaaSProviderService paaSProviderService ; @ Resource private CloudImageService cloudImageService ; @ Resource private DeploymentService deploymentService ; public void initializeAndWait ( ) { } public List < Future < ? > > initialize ( ) { } private void disableOnInitFailure ( Cloud cloud , Throwable t ) { } public synchronized String create ( Cloud cloud ) { } private void initializeMatcherConfig ( IPaaSProvider provider , Cloud cloud ) { } @ SuppressWarnings ( "rawtypes" ) private void saveDefaultConfiguration ( String cloudId , Object defaultConfiguration ) { } public synchronized void update ( Cloud updated ) { } public synchronized boolean delete ( String id ) { } private void removeCloudIdInApplicationEnvironment ( String id ) { } public Cloud get ( String id ) { } public Cloud getByName ( String name ) { } public GetMultipleDataResult < Cloud > get ( String query , boolean enabledOnly , int from , int size , FilterBuilder authorizationFilter ) { } public Map < String , PropertyDefinition > getDeploymentPropertyDefinitions ( String id ) { } public Object getConfiguration ( String id ) { } public Class < ? > getConfigurationType ( String id ) { } private Class < ? > getConfigurationType ( Cloud cloud ) { } public synchronized void updateConfiguration ( String id , Object newConfiguration ) { } public synchronized void enableCloud ( String id ) throws PluginConfigurationException { } @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) private void initCloud ( Cloud cloud ) throws PluginConfigurationException { } public Object configurationAsValidObject ( String id , Object configuration ) throws PluginConfigurationException , IOException { } private Object configurationAsValidObject ( Cloud cloud , Object configuration ) throws PluginConfigurationException , IOException { } public synchronized boolean disableCloud ( String id ) { } private void disableCloud ( Cloud cloud ) { } public IPaaSProvider getPaaSProvider ( String cloudId ) throws CloudDisabledException { } public Cloud getMandatoryCloud ( String id ) { } private boolean isFlavorMatchImageRequirement ( CloudImage image , CloudImageFlavor flavor ) { } public void addCloudImage ( Cloud cloud , String cloudImageId ) { } public void addCloudImageFlavor ( Cloud cloud , CloudImageFlavor flavor ) { } public void removeCloudImage ( Cloud cloud , String cloudImageId ) { } public void removeCloudImageFlavor ( Cloud cloud , String flavorId ) { } public void setCloudTemplateStatus ( Cloud cloud , String activableComputeId , boolean enabled ) { } public String [ ] getCloudResourceIds ( Cloud cloud , CloudResourceType type ) { } public CloudResourceMatcherConfig getCloudResourceMatcherConfig ( Cloud cloud ) { } private < U extends ICloudResourceTemplate > Map < String , U > buildResourcesMap ( Set < U > resources ) { } public void setCloudImageResourceId ( Cloud cloud , String cloudImageId , String paaSResourceId ) throws CloudDisabledException { } private void addComputeTemplatesForImage ( Cloud cloud , IPaaSProvider paaSProvider , CloudResourceMatcherConfig matcherConfig , String cloudImageId ) { } public void setCloudImageFlavorResourceId ( Cloud cloud , String flavorId , String paaSResourceId ) throws CloudDisabledException { } private void addComputeTemplatesForFlavor ( Cloud cloud , IPaaSProvider paaSProvider , CloudResourceMatcherConfig matcherConfig , CloudImageFlavor flavor ) { } public List < ActivableComputeTemplate > getComputeTemplates ( Cloud cloud , String cloudImageId , String flavorId , boolean take ) { } public ActivableComputeTemplate getActivableComputeByIdOrFail ( Cloud cloud , String activableComputeId ) { } private < T extends ICloudResourceTemplate > T getResource ( Collection < T > resources , String id , boolean take ) { } public void addNetwork ( Cloud cloud , NetworkTemplate network ) { } public void removeNetwork ( Cloud cloud , String networkName ) { } public void setNetworkResourceId ( Cloud cloud , String networkName , String paaSResourceId ) throws CloudDisabledException { } public void addStorageTemplate ( Cloud cloud , StorageTemplate storageTemplate ) { } public void removeStorageTemplate ( Cloud cloud , String storageId ) { } public void setStorageResourceId ( Cloud cloud , String storageId , String paaSResourceId ) throws CloudDisabledException { } public String clone ( String id ) { } private String getUniqueCloudName ( String baseName , int attemptCount ) { } public void addAvailabilityZone ( Cloud cloud , AvailabilityZone availabilityZone ) { } public void removeAvailabilityZone ( Cloud cloud , String availabilityZoneId ) { Set < AvailabilityZone > availabilityZones = cloud . getAvailabilityZones ( ) ; getResource ( availabilityZones , availabilityZoneId , true ) ; <START_BUG> cloud . getStorageMapping ( ) . remove ( availabilityZoneId ) ; <END_BUG> alienDAO . save ( cloud ) ; } public void setAvailabilityZoneResourceId ( Cloud cloud , String availabilityZoneId , String pasSResourceId ) throws CloudDisabledException { } }

Fix:
cloud . getAvailabilityZoneMapping ( ) . remove ( availabilityZoneId ) ;