Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-9438

FailoverTransport throws UnknowHostException on compareURIs

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 5.18.3, 5.17.6, 5.16.7
    • 6.1.0, 5.18.4, 5.17.7, 6.0.2
    • Transport
    • None
    • This occurs using OpenJDK 11 on both Windows and Linux environments.

    Description

      In the org.apache.activemq.transport.failover.FailoverTransport.compareURIs(), it is trying to compare 2 hosts to see if they are the same.

      To accomplish this, the function InetAddress.getByName() used to help extract out the the IP address of each of the hosts to see if they are the same.

      In the event one of the hosts is not resolvable,  InetAddress.getByName() throws a UnknownHostException.

      This UnknownHostException is not being caught in the try/catch block, only IOException.

      I believe the exception catch block should be extended to catch UnknownHostException as it is simply doing a string compare that the 2 hosts are the same at that point.

      For example, in the stacktrace below the uri was, failover:(tcp://UNKNOWN:61616,tcp://AMQ1:61616)?randomize=false/org.apache.activemq.jndi.ActiveMQInitialContextFactory/ConnectionFactory

      2024-02-27T19:37:20,311 | ERROR | FelixStartLevel  | FailoverTransport                | 28 - org.apache.activemq.osgi - 5.18.3 | Failed to Lookup INetAddress for URI[tcp://UNKNOWN:61616] : {}
      java.net.UnknownHostException: No such host is known (UNKNOWN)
          at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) ~[?:?]
          at java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929) ~[?:?]
          at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1519) ~[?:?]
          at java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:848) ~[?:?]
          at java.net.InetAddress.getAllByName0(InetAddress.java:1509) ~[?:?]
          at java.net.InetAddress.getAllByName(InetAddress.java:1368) ~[?:?]
          at java.net.InetAddress.getAllByName(InetAddress.java:1302) ~[?:?]
          at java.net.InetAddress.getByName(InetAddress.java:1252) ~[?:?]
          at org.apache.activemq.transport.failover.FailoverTransport.compareURIs(FailoverTransport.java:1393) ~[?:?] 

      Attachments

        Activity

          People

            jbonofre Jean-Baptiste Onofré
            gmccone George McCone
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m