Here's more context:
NodeMetadata.getHostname is Nullable, when the backend api doesn't return data for hostname.
jclouds doesn't filter the data the api returns, so if an ip address is returned, that would end up in the field. jclouds could add a sanity check and null it out, if the api returned an ip address.
As hostname assignment is performed in most clouds by commands on the image itself, it is possible for a custom image to screw this up, even on a provider that usually sets hostnames. As such, any code that uses node.hostname should probably treat it as "best efforts". This is basically what NodeMetadata.getHostname javadoc says.
This glitch is checked in the assertion here in the jclouds codebase:
The above ensures that the hostname command corresponds with what's returned from the api. This is overridden by cloud providers who either don't return hostnames, or use images do not assign the hostname properly. jclouds could break this test up slightly to only bother checking the hostname command, if the node.hostname field is set. This would make it more easy to show providers or images which are faulty in this regard.