Help save net neutrality! Learn more.

#45 ModbusSerialListener constructor does not return

Transport (27)
Julie Haugh

The constructor for the ModbusSerialListener class contains a call to the listen() method, which does not return until the listen() method completes. The is inconsistent with the Java programming model, where a class constructor returns the object, which is then acted upon by its methods.

The solution (IMHO) is to make the listener() method public and add a second constructor with a different signature. A better solution (IMHO) is to change the name to run() and have ModbusSerialListener extend Runnable so the listener can be executed as a Thread().


  • Dieter Wimberger

    While I would not classify it as a bug (because it works), this is definitely a design flaw.
    Updated implementation to match the TCP implementation better (Runnable, start() and stop() as API).

    Removed the GC construct, if some special handling is required, it is probably best to implement a derived class.

  • Dieter Wimberger

    • labels: --> Transport
    • milestone: --> v1.2rc1
    • assigned_to: nobody --> wimpi
    • status: open --> closed-accepted

Log in to post a comment.