CAMEL-6555 Don't throw exception when the host is not IP address
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/efd5de71 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/efd5de71 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/efd5de71 Branch: refs/heads/master Commit: efd5de71770ab23817789847b80514395f1669e1 Parents: e236e6a Author: Willem Jiang <willem.ji...@gmail.com> Authored: Mon Jul 21 14:13:04 2014 +0800 Committer: Willem Jiang <willem.ji...@gmail.com> Committed: Tue Jul 22 21:25:19 2014 +0800 ---------------------------------------------------------------------- .../org/apache/camel/component/netty4/util/SubnetUtils.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/efd5de71/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/util/SubnetUtils.java ---------------------------------------------------------------------- diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/util/SubnetUtils.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/util/SubnetUtils.java index a6c90e6..9edba1a 100644 --- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/util/SubnetUtils.java +++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/util/SubnetUtils.java @@ -122,7 +122,12 @@ public class SubnetUtils { * @return True if in range, false otherwise */ public boolean isInRange(String address) { - return isInRange(toInteger(address)); + Matcher matcher = ADDRESS_PATTERN.matcher(address); + if (matcher.matches()) { + return isInRange(toInteger(address)); + } else { + return false; + } } private boolean isInRange(int address) {