Community
Participate
Working Groups
When running tests outside the RWTAllTestSuite, Fixture#tearDown fails with an IllegalStateException while cleaning up the web context directory. The reason is that files could not be deleted. For example running the Graphics_Test raises the following exception in #testGetImageWithClassLoader java.lang.IllegalStateException: Could not delete: C:\Users\Ruediger\AppData\Local\Temp\testapp\test.gif at org.eclipse.rwt.Fixture.doDelete(Fixture.java:437) at org.eclipse.rwt.Fixture.delete(Fixture.java:410) at org.eclipse.rwt.Fixture.doDelete(Fixture.java:431) at org.eclipse.rwt.Fixture.delete(Fixture.java:410) at org.eclipse.rwt.Fixture.deleteWebContextDirectories(Fixture.java:171) at org.eclipse.rwt.Fixture.disposeOfApplicationContext(Fixture.java:113) at org.eclipse.rwt.graphics.Graphics_Test.tearDown(Graphics_Test.java:253) ... Trying to delete the file manually while pausing the test just before tearDown() is called, reveals the reason why the file cannot be deleted: "The action cannot be completed because the file is open in Java Platform SE binary". This can probably only be observed on Windows, as to my knowledge other operation systems don't prevent files from being deleted while still in use. Nevetheless it indicates a resource leak. Running the RWTAllTestSuite works because it sets the Fixture#usePerformanceOptimizations to true before running the tests, which in turn prevents the web context directory from being cleaned up.
After further investigation it turned out that two tests in Graphics_Test cause the problem as they (or the code under test) leave open an input stream: * testGetImageWithClassLoader * testGetImageWithInputStream Changed the bug summary accordingly
Fixed testGetImageWithInputStream by closing the input stream. Changes are in CVS HEAD.
Created attachment 197296 [details] Proposed fix for Graphics_Test#testGetImageWithClassLoader Tis patch fixes the issue by closing the class resource input stream in ImageFactory#createImage(String,ClassLoader)
Applied patch from atachment 197296 to CVS HEAD. If you don't like to try-catch block, pleasse see bug 348190. @Ralf: Do you have a chance to revise this fix? Is this a candidate for 1.4.1?
Marking as FIXED (see comment #4)