private String formatMaybeIpv6 ( String address ) { String openBracket = "[" ; String closeBracket = "]" ; if ( address . contains ( ":" ) && ! address . startsWith ( openBracket ) && ! address . endsWith ( closeBracket ) ) { return openBracket + address + closeBracket ; } return address ; }
This isn t very precise ; org . jboss . as . network . NetworkUtils has better implementation but that s in a private module .