Closed jim618 closed 8 years ago
Possible sequence to reproduce (needs verifying):
c:\tmp\empty
c:\tmp
empty
(don't enter it, just single click on it).c:\tmp\empty
Bit of a weird sequence that I've adapted from Java bug 6509187
I could not reproduce this error using the sequence given in the previous post
Looks like it is something to do with accessing the FileChooser on a non-Swing Thread: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6637181
I have added a defensive SwingUtilities.invokeLater to the FileChooser picking code. Looking at the original code I don't see how this could be invoked by a non-Swing thread though as it is the result of a button click. Anyhow the change is pretty safe.
Awaiting review and closing.
I'm not convinced that we've got the bottom of this. It's clear that we're accessing the FileChooser on the EDT. I'm inclined to think it's to do with setting the initial directory and that if that changes between invocations then we'll see an error if the file sizes are different.
While the defensive Swing wrapper is OK, I'd like to push this back into 0.1.3 for more attention.
I have narrowed the scope of the JFileChooser so that it is created anew each time the file chooser button is pressed. Then an initial value is set if it is available in the model
I am hoping that by shortening the life cycle of the file chooser it will have less chance to get confused by file system changes (which is most likely what is happening)
Awaiting code review, testing and closing
I have also tested this on a cold start successfully
Code review looks good. Adding the invocation to a later item on the EDT queue should ensure that any earlier model operations within the file chooser are resolved before the next item is processed.
This is a probabilistic fix so let's put it out there and see if it recurs in 0.1.3. If so then we'll add further defensive code (such as trapping the IllegalArgumentException and performing a fixed number of repeat attempts before giving up).
Closing.
Seen this reappear in log 1af2f7b under 0.1.4 so needs further attention. Further trawling through logs has it showing up quite a lot.
Reading the two bug reports mentioned above 'setSelectedFile' appears problematic so I have rewritten the code to avoid invoking it. Now the constructor is used to set the initial file shown if it is available and is a directory.
This is a probable fix as the error is not reproducible.
Awaiting review and closing.
Verified working. Closing (subject to ongoing probabilistic fix).