Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#45 ModbusSerialListener constructor does not return

v1.2rc1
closed-accepted
Transport (27)
5
2012-08-11
2012-08-11
Julie Haugh
No

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().

Discussion

  • 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.

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