NO-JIRA: cleanup vhost handling issues found by Coverity
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/34ae9ea9 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/34ae9ea9 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/34ae9ea9 Branch: refs/heads/master Commit: 34ae9ea9e856d15c483ed8b98582c3e0bc665a85 Parents: 9a7b2cf Author: Ken Giusti <[email protected]> Authored: Tue May 31 13:35:23 2016 -0400 Committer: Ken Giusti <[email protected]> Committed: Tue May 31 15:02:55 2016 -0400 ---------------------------------------------------------------------- .../java/org/apache/qpid/proton/reactor/impl/IOHandler.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/34ae9ea9/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java index c0e51d5..30ad246 100644 --- a/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java +++ b/proton-j/src/main/java/org/apache/qpid/proton/reactor/impl/IOHandler.java @@ -87,9 +87,12 @@ public class IOHandler extends BaseHandler { if (vhost == null) { // setHostname never called, use the host from the connection's // socket address as the default virtual host: - Address addr = new Address(reactor.getConnectionAddress(connection)); - connection.setHostname(addr.getHost()); - } else if (vhost == "") { + String conAddr = reactor.getConnectionAddress(connection); + if (conAddr != null) { + Address addr = new Address(conAddr); + connection.setHostname(addr.getHost()); + } + } else if (vhost.isEmpty()) { // setHostname called explictly with a null string. This allows // the application to completely avoid sending a virtual host // name --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
