Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-220

TFTPServer is not threadsafe

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.0
    • Fix Version/s: None
    • Component/s: TFTP
    • Labels:
      None

      Description

      The TFTPServer class is not threadsafe.

      There are several reasons for this:

      Ctors call private launch() method which creates a thread and start()s it.
      This publishes the instance before it has been fully constructed.

      Various instance fields are not thread-safe - e.g. serverReadDirectory_ is neither final nor volatile, and accesses to it are not synchronized.
      Although it is only written by the ctors, the lack of synch means that the field may not be visible to other threads.

      As far as possible, instance fields should be made final - this guarantees that the field will be visible to other threads.

      One of the shutdown_ variables is volatile (so is threadsafe) but the shutdown_ variable in the nested TFTPTransfer class is not, yet is accessed from multiple threads.

      The access to the variable serverException is not synch; should probably be volatile.

      Patch to follow.

        Attachments

        1. TFTPServerPathTest.patch
          1 kB
          Sebb
        2. TFTPServer.patch
          6 kB
          Sebb

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              sebb Sebb
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: