From 8f2623e33cc47d90605dfffb1f140863d2d893e9 Mon Sep 17 00:00:00 2001 From: cketti Date: Wed, 19 Jan 2011 00:10:36 +0000 Subject: [PATCH] Rewrote code to be easier to read and not raise a potential null pointer warning by Eclipse. --- src/com/fsck/k9/helper/DomainNameChecker.java | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/com/fsck/k9/helper/DomainNameChecker.java b/src/com/fsck/k9/helper/DomainNameChecker.java index 308514ef6..bb0e7b8fd 100644 --- a/src/com/fsck/k9/helper/DomainNameChecker.java +++ b/src/com/fsck/k9/helper/DomainNameChecker.java @@ -84,36 +84,38 @@ public class DomainNameChecker */ private static boolean isIpAddress(String domain) { - boolean rval = ((domain != null) && (domain.length() != 0)); - if (rval) + if ((domain == null) || (domain.length() == 0)) { - try - { - // do a quick-dirty IP match first to avoid DNS lookup - rval = QUICK_IP_PATTERN.matcher(domain).matches(); - if (rval) - { - rval = domain.equals(InetAddress.getByName(domain) - .getHostAddress()); - } - } - catch (UnknownHostException e) - { - String errorMessage = e.getMessage(); - if (errorMessage == null) - { - errorMessage = "unknown host exception"; - } + return false; + } - if (K9.DEBUG) - { - Log.v(K9.LOG_TAG, "DomainNameChecker.isIpAddress(): " - + errorMessage); - } - - rval = false; + boolean rval; + try + { + // do a quick-dirty IP match first to avoid DNS lookup + rval = QUICK_IP_PATTERN.matcher(domain).matches(); + if (rval) + { + rval = domain.equals(InetAddress.getByName(domain) + .getHostAddress()); } } + catch (UnknownHostException e) + { + String errorMessage = e.getMessage(); + if (errorMessage == null) + { + errorMessage = "unknown host exception"; + } + + if (K9.DEBUG) + { + Log.v(K9.LOG_TAG, "DomainNameChecker.isIpAddress(): " + + errorMessage); + } + + rval = false; + } return rval; }