This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-text.git
commit 84193fef76ad3efa2c2e7c93aca8a6c944aeb07f Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Fri Jul 26 13:52:46 2019 -0400 Simplify. --- .../commons/text/lookup/LocalHostStringLookup.java | 29 ++++++++-------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/apache/commons/text/lookup/LocalHostStringLookup.java b/src/main/java/org/apache/commons/text/lookup/LocalHostStringLookup.java index ab4681e..2a0f144 100644 --- a/src/main/java/org/apache/commons/text/lookup/LocalHostStringLookup.java +++ b/src/main/java/org/apache/commons/text/lookup/LocalHostStringLookup.java @@ -49,8 +49,7 @@ final class LocalHostStringLookup extends AbstractStringLookup { /** * Looks up the value of the Java platform key. * - * @param key - * the key to be looked up, may be null + * @param key the key to be looked up, may be null * @return The value of the environment variable. */ @Override @@ -58,27 +57,19 @@ final class LocalHostStringLookup extends AbstractStringLookup { if (key == null) { return null; } - switch (key) { - case "name": - try { + try { + switch (key) { + case "name": return InetAddress.getLocalHost().getHostName(); - } catch (final UnknownHostException e) { - return null; - } - case "canonical-name": - try { + case "canonical-name": return InetAddress.getLocalHost().getCanonicalHostName(); - } catch (final UnknownHostException e) { - return null; - } - case "address": - try { + case "address": return InetAddress.getLocalHost().getHostAddress(); - } catch (final UnknownHostException e) { - return null; + default: + throw new IllegalArgumentException(key); } - default: - throw new IllegalArgumentException(key); + } catch (UnknownHostException e) { + return null; } } }