Skip to content

Commit

Permalink
NIFI-560: FileBasedClusterNodeFirewall should use slf4j parameterized…
Browse files Browse the repository at this point in the history
… message instead of string operations.

Signed-off-by: Mark Payne <markap14@hotmail.com>
  • Loading branch information
busbey authored and markap14 committed May 1, 2015
1 parent 1a1cfe2 commit 5bf610a
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public boolean isPermissible(final String hostOrIp) {
try {
ip = InetAddress.getByName(hostOrIp).getHostAddress();
} catch (final UnknownHostException uhe) {
logger.warn("Blocking unknown host: " + hostOrIp, uhe);
logger.warn("Blocking unknown host '{}'", hostOrIp, uhe);
return false;
}

Expand Down Expand Up @@ -168,38 +168,38 @@ private void parseConfig(final File config) throws IOException {
if (ipOrHostLine.contains("/")) {
ipCidr = ipOrHostLine;
} else if (ipOrHostLine.contains("\\")) {
logger.warn("CIDR IP notation uses forward slashes '/'. Replacing backslash '\\' with forward slash'/' for '" + ipOrHostLine + "'");
logger.warn("CIDR IP notation uses forward slashes '/'. Replacing backslash '\\' with forward slash'/' for '{}'", ipOrHostLine);
ipCidr = ipOrHostLine.replace("\\", "/");
} else {
try {
ipCidr = InetAddress.getByName(ipOrHostLine).getHostAddress();
if (!ipOrHostLine.equals(ipCidr)) {
logger.debug(String.format("Resolved host '%s' to ip '%s'", ipOrHostLine, ipCidr));
logger.debug("Resolved host '{}' to ip '{}'", ipOrHostLine, ipCidr);
}
ipCidr += "/32";
logger.debug("Adding CIDR to exact IP: " + ipCidr);
logger.debug("Adding CIDR to exact IP: '{}'", ipCidr);
} catch (final UnknownHostException uhe) {
logger.warn("Firewall is skipping unknown host address: " + ipOrHostLine);
logger.warn("Firewall is skipping unknown host address: '{}'", ipOrHostLine);
continue;
}
}

try {
logger.debug("Adding CIDR IP to firewall: " + ipCidr);
logger.debug("Adding CIDR IP to firewall: '{}'", ipCidr);
final SubnetUtils subnetUtils = new SubnetUtils(ipCidr);
subnetUtils.setInclusiveHostCount(true);
subnetInfos.add(subnetUtils.getInfo());
totalIpsAdded++;
} catch (final IllegalArgumentException iae) {
logger.warn("Firewall is skipping invalid CIDR address: " + ipOrHostLine);
logger.warn("Firewall is skipping invalid CIDR address: '{}'", ipOrHostLine);
}

}

if (totalIpsAdded == 0) {
logger.info("No IPs added to firewall. Firewall will accept all requests.");
} else {
logger.info(String.format("Added %d IP(s) to firewall. Only requests originating from the configured IPs will be accepted.", totalIpsAdded));
logger.info("Added {} IP(s) to firewall. Only requests originating from the configured IPs will be accepted.", totalIpsAdded);
}

}
Expand Down

0 comments on commit 5bf610a

Please sign in to comment.