Source:
<code>public SecurityGroup removeIpPermission(final IpProtocol protocol, int startPort, int endPort, Multimap<String, String> tenantIdGroupNamePairs, final Iterable<String> ipRanges, Iterable<String> groupIds, SecurityGroup group) { final String portRange = startPort + "-" + endPort; String ruleName = "ingress-" + protocol.name().toLowerCase() + "-" + portRange; logger.debug(">> deleting ip permissions matching [%s] from %s...", ruleName, group.getName()); final ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(group.getId()); NetworkSecurityGroupApi groupApi = api.getNetworkSecurityGroupApi(resourceGroupAndName.resourceGroup()); NetworkSecurityGroup networkSecurityGroup = groupApi.get(resourceGroupAndName.name()); if (networkSecurityGroup == null) { throw new IllegalArgumentException("Security group " + group.getName() + " was not found"); } NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourceGroupAndName.resourceGroup(), networkSecurityGroup.name()); Iterable<NetworkSecurityRule> rules = filter(ruleApi.list(), new Predicate<NetworkSecurityRule>() { @Override public boolean apply(NetworkSecurityRule input) { NetworkSecurityRuleProperties props = input.properties(); return Objects.equal(portRange, props.destinationPortRange()) && Objects.equal(Protocol.fromValue(protocol.name()), props.protocol()) && Objects.equal(Direction.Inbound, props.direction()) && Objects.equal(Access.Allow, props.access()) && any(ipRanges, equalTo(props.sourceAddressPrefix().replace("*", "0.0.0.0/0"))); } }); for (NetworkSecurityRule matchingRule : rules) { logger.debug(">> deleting network security rule %s from %s...", matchingRule.name(), group.getName()); ruleApi.delete(matchingRule.name()); <START> URI uri = api.getNetworkSecurityRuleApi(resourceGroupAndName.resourceGroup(), networkSecurityGroup.name()).delete(resourceGroupAndName.name()); <END> if (uri != null) { resourceDeleted.apply(uri); } } return getSecurityGroupById(group.getId()); }</code><technical_language>This wrong: * rule is deleted in line 297. * passing security group name delete method, rule name. Remove this line, capture URL in line 297 check that</technical_language>

Target:
public SecurityGroup removeIpPermission(final IpProtocol protocol, int startPort, int endPort, Multimap<String, String> tenantIdGroupNamePairs, final Iterable<String> ipRanges, Iterable<String> groupIds, SecurityGroup group) { final String portRange = startPort + "-" + endPort; String ruleName = "ingress-" + protocol.name().toLowerCase() + "-" + portRange; logger.debug(">> deleting ip permissions matching [%s] from %s...", ruleName, group.getName()); final ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(group.getId()); NetworkSecurityGroupApi groupApi = api.getNetworkSecurityGroupApi(resourceGroupAndName.resourceGroup()); NetworkSecurityGroup networkSecurityGroup = groupApi.get(resourceGroupAndName.name()); if (networkSecurityGroup == null) { throw new IllegalArgumentException("Security group " + group.getName() + " was not found"); } NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourceGroupAndName.resourceGroup(), networkSecurityGroup.name()); Iterable<NetworkSecurityRule> rules = filter(ruleApi.list(), new Predicate<NetworkSecurityRule>() { @Override public boolean apply(NetworkSecurityRule input) { NetworkSecurityRuleProperties props = input.properties(); return Objects.equal(portRange, props.destinationPortRange()) && Objects.equal(Protocol.fromValue(protocol.name()), props.protocol()) && Objects.equal(Direction.Inbound, props.direction()) && Objects.equal(Access.Allow, props.access()) && any(ipRanges, equalTo(props.sourceAddressPrefix().replace("*", "0.0.0.0/0"))); } }); for (NetworkSecurityRule matchingRule : rules) { logger.debug(">> deleting network security rule %s from %s...", matchingRule.name(), group.getName()); URI uri = ruleApi.delete(matchingRule.name()); if (uri != null) { checkState(resourceDeleted.apply(uri), "Rule %s could not be deleted in the configured timeout", matchingRule.id()); } } return getSecurityGroupById(group.getId()); }