Menu

#3 Thread race in mail-fetch

Next_version
open
None
8
2009-05-08
2009-04-29
Anonymous
No

Most possibly a race can sometimes occur between the initialization of mails and the GUI mail-fetch. In v0.7.28 I put the initialization of mails in a worker thread. I did not anticipate that the GUI would fetch mails which could clash with the background thread, but obviously so is the case.

The initialization worker fetches a list of mails found in StarWarsGalaxies\profiles\station\galaxy\character\ and iterates over that list to move the mails to SWGAide\mails\... Probably the GUI snatches some mails while the background thread is iterating over the list which then will be invalid, in full or partial.

Here is a stacktrace from a player that mailed me his error-log

[Sun Apr 19 06:24:31 PDT 2009 | version 0.7.30 Beta == EXCEPTION == SWGMailMessage:parseHeader: C:\Users\David\mails\station\Europe-Chimaera\character\123456789.mail mails\station\Europe-Chimaera\character\123456789.mail (The system cannot find the path specified)

java.io.FileNotFoundException: mails\station\Europe-Chimaera\character\123456789.mail (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileReader.<init>(Unknown Source)
at swg.model.mail.SWGMailMessage.parseHeader(SWGMailMessage.java:351)
at swg.model.mail.SWGMailMessage.<init>(SWGMailMessage.java:130)
at swg.model.mail.SWGMailBox.fetchMails(SWGMailBox.java:367)
at swg.gui.SWGInitialize.scanForMails(SWGInitialize.java:701)
at swg.gui.SWGInitialize$12.doInBackground(SWGInitialize.java:515)
at swg.gui.SWGInitialize$12.doInBackground(SWGInitialize.java:1)
at javax.swing.SwingWorker$1.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at javax.swing.SwingWorker.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I have twice seen this error while running SWGAide under Eclipse so it definitely happens, randomly.

Need to scrutinize the code and make methods synchronized. Possibly the GUI should not be able to fetch mails before the initialization code is finished.

Discussion

  • Simon Gronlund

    Simon Gronlund - 2009-04-29

    Oops, I was not logged in, but it was me :D
    /Zimoon

     
  • Simon Gronlund

    Simon Gronlund - 2009-04-29
    • milestone: --> Next_version
    • priority: 5 --> 7
     
  • Simon Gronlund

    Simon Gronlund - 2009-05-02
    • assigned_to: nobody --> simgron
    • status: open --> closed-fixed
     
  • Simon Gronlund

    Simon Gronlund - 2009-05-02

    Fixed in r408, made fetxhMails() synchrnized.

     
  • Simon Gronlund

    Simon Gronlund - 2009-05-08

    Reopening due to new bug reports on same issue.
    Need a thorough review.

     
  • Simon Gronlund

    Simon Gronlund - 2009-05-08
    • priority: 7 --> 8
    • status: closed-fixed --> open-accepted
     
  • Simon Gronlund

    Simon Gronlund - 2009-05-08
    • status: open-accepted --> open
     

Log in to post a comment.