Uploaded image for project: 'AMQ Clients'
  1. AMQ Clients
  2. ENTMQCL-470

[python] Faulty error handling when listener address is already in use

XMLWordPrintable

    • Hide
      In earlier releases of the product, there was an incorrect string format in an error handler. As a consequence, the `address already in use` error message was obscured.

      In this release, the string format is corrected and the error message is no longer obscured.
      Show
      In earlier releases of the product, there was an incorrect string format in an error handler. As a consequence, the `address already in use` error message was obscured. In this release, the string format is corrected and the error message is no longer obscured.
    • Documented as Resolved Issue

      There is a wrong syntax when raising the "Address already in use" error in proton-c/bindings/python/proton/reactor.py (line 179):

      raise IOError("%s (%s:%s)" % pn_error_text(pn_reactor_error(self._impl)), host, port)
      

      Which leads to unexpected TypeError:

      Traceback (most recent call last):
        File "in_handler.py", line 15, in <module>
          container.run()
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 133, in run
          while self.process(): pass
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 159, in process
          self._check_errors()
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 155, in _check_errors
          _compat.raise_(exc, value, tb)
        File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 4040, in dispatch
          ev.dispatch(self.handler)
        File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 3949, in dispatch
          result = dispatch(handler, type.method, self)
        File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 3827, in dispatch
          return m(*args)
        File "/usr/lib64/python2.7/site-packages/proton/handlers.py", line 436, in on_reactor_init
          self.on_start(event)
        File "in_handler.py", line 6, in on_start
          acceptor = event.container.listen("localhost:5672")
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 869, in listen
          acceptor = self.acceptor(url.host, url.port)
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 179, in acceptor
          raise IOError("%s (%s:%s)" % pn_error_text(pn_reactor_error(self._impl)), host, port)
      TypeError: not enough arguments for format string
      

      Proposed fix:

      diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
      index 269ed9e..a0699c8 100644
      --- a/proton-c/bindings/python/proton/reactor.py
      +++ b/proton-c/bindings/python/proton/reactor.py
      @@ -176,7 +176,7 @@ class Reactor(Wrapper):
               if aimpl:
                   return Acceptor(aimpl)
               else:
      -            raise IOError("%s (%s:%s)" % pn_error_text(pn_reactor_error(self._impl)), host, port)
      +            raise IOError("%s (%s:%s)" % (pn_error_text(pn_reactor_error(self._impl)), host, port))
       
           def connection(self, handler=None):
               """Deprecated: use connection_to_host() instead
      

              jross@redhat.com Justin Ross
              pematous Petr Matousek
              David Kornel David Kornel
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: