@Test public void testGetHostnameWhenInputIsNull() { SocketAddress socketAddress = null; String hostname = SyslogUtils.getHostname(socketAddress); assertEquals("", hostname); }
public static String getHostname(SocketAddress socketAddress) { try { InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress; String hostname = inetSocketAddress.getHostName(); if (hostname != null) { return hostname; } else { throw new NullPointerException("The returned hostname is null"); } } catch (Exception e) { logger.warn("Unable to retrieve client hostname", e); } return ""; }
SyslogUtils { public static String getHostname(SocketAddress socketAddress) { try { InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress; String hostname = inetSocketAddress.getHostName(); if (hostname != null) { return hostname; } else { throw new NullPointerException("The returned hostname is null"); } } catch (Exception e) { logger.warn("Unable to retrieve client hostname", e); } return ""; } }
SyslogUtils { public static String getHostname(SocketAddress socketAddress) { try { InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress; String hostname = inetSocketAddress.getHostName(); if (hostname != null) { return hostname; } else { throw new NullPointerException("The returned hostname is null"); } } catch (Exception e) { logger.warn("Unable to retrieve client hostname", e); } return ""; } SyslogUtils();  SyslogUtils(boolean isUdp);  SyslogUtils(Integer defaultSize, Set<String> keepFields, boolean isUdp);  SyslogUtils(Integer eventSize, Set<String> keepFields, boolean isUdp, Clock clock); }
SyslogUtils { public static String getHostname(SocketAddress socketAddress) { try { InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress; String hostname = inetSocketAddress.getHostName(); if (hostname != null) { return hostname; } else { throw new NullPointerException("The returned hostname is null"); } } catch (Exception e) { logger.warn("Unable to retrieve client hostname", e); } return ""; } SyslogUtils();  SyslogUtils(boolean isUdp);  SyslogUtils(Integer defaultSize, Set<String> keepFields, boolean isUdp);  SyslogUtils(Integer eventSize, Set<String> keepFields, boolean isUdp, Clock clock); static boolean keepAllFields(Set<String> keepFields); static Set<String> chooseFieldsToKeep(String keepFields); static String addFieldsToBody(Set<String> keepFields,
                                       String body,
                                       String priority,
                                       String version,
                                       String timestamp,
                                       String hostname); static String getIP(SocketAddress socketAddress); static String getHostname(SocketAddress socketAddress); void addFormats(Map<String, String> formatProp); Event extractEvent(ChannelBuffer in); Integer getEventSize(); void setEventSize(Integer eventSize); void setKeepFields(Set<String> keepFields); }
SyslogUtils { public static String getHostname(SocketAddress socketAddress) { try { InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress; String hostname = inetSocketAddress.getHostName(); if (hostname != null) { return hostname; } else { throw new NullPointerException("The returned hostname is null"); } } catch (Exception e) { logger.warn("Unable to retrieve client hostname", e); } return ""; } SyslogUtils();  SyslogUtils(boolean isUdp);  SyslogUtils(Integer defaultSize, Set<String> keepFields, boolean isUdp);  SyslogUtils(Integer eventSize, Set<String> keepFields, boolean isUdp, Clock clock); static boolean keepAllFields(Set<String> keepFields); static Set<String> chooseFieldsToKeep(String keepFields); static String addFieldsToBody(Set<String> keepFields,
                                       String body,
                                       String priority,
                                       String version,
                                       String timestamp,
                                       String hostname); static String getIP(SocketAddress socketAddress); static String getHostname(SocketAddress socketAddress); void addFormats(Map<String, String> formatProp); Event extractEvent(ChannelBuffer in); Integer getEventSize(); void setEventSize(Integer eventSize); void setKeepFields(Set<String> keepFields); static final String SYSLOG_TIMESTAMP_FORMAT_RFC5424_2; static final String SYSLOG_TIMESTAMP_FORMAT_RFC5424_1; static final String SYSLOG_TIMESTAMP_FORMAT_RFC5424_3; static final String SYSLOG_TIMESTAMP_FORMAT_RFC5424_4; static final String SYSLOG_TIMESTAMP_FORMAT_RFC3164_1; static final String SYSLOG_MSG_RFC5424_0; static final String SYSLOG_MSG_RFC3164_0; static final int SYSLOG_PRIORITY_POS; static final int SYSLOG_VERSION_POS; static final int SYSLOG_TIMESTAMP_POS; static final int SYSLOG_HOSTNAME_POS; static final int SYSLOG_BODY_POS; static final String SYSLOG_FACILITY; static final String SYSLOG_SEVERITY; static final String SYSLOG_PRIORITY; static final String SYSLOG_VERSION; static final String EVENT_STATUS; static final Integer MIN_SIZE; static final Integer DEFAULT_SIZE; static final String KEEP_FIELDS_ALL; }