On Tue, 31 May 2022 09:29:59 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:
>>> Can't the test be automated? >>> >>> Can you paint the table to a BufferredImage and catch the NPE? >>> >>> Alternatively, if the above can't be done, you can use >>> [Thread.setUncaughtExceptionHandler](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Thread.html#setUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)) >>> to set >>> [UncaughtExceptionHandler](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Thread.UncaughtExceptionHandler.html) >>> for the EDT and catch NPE. >>> >>> If NPE is thrown, the test fails. >> >> Yeah, wanted to change to automatic, but wasn't sure about whether its ok >> for NPE check or not. Actually if the current test executes then its a pass >> right......? Painting it to bufferedImage and then catching NPE is >> required........? > >> Yeah, wanted to change to automatic, but wasn't sure about whether its ok >> for NPE check or not. > > What can be wrong with it? It's just a regular test. If you can automate the > test, you should. > >> Actually if the current test executes then its a pass right......? > > I don't understand your question, sorry. What surprises me is that the test > fails automatically without the fix. But I can't see how the NPE is re-thrown > on the main thread. > > I thought the NPE would be just printed in the jtreg log file and the tester > wouldn't even see it. > > So your test is already automated to some extent. What we want is to make it > pass automatically if NPE isn't thrown. > >> Painting it to bufferedImage and then catching NPE is required........? > > No, it's not, however, I think it's a more effective way than showing UI. The > exception occurs when `paint` is called. Painting to `BufferedImage` gives > you control when and how `paint` is called: you do it _explicitly_. So you > wrap the call to `paint` in a try-catch block, if the exception is thrown you > re-throw it on main thread to fail the test; if the exception isn't thrown, > the test completed successfully. Perhaps, try-catch block isn't necessary, > just let the exception propagate. > _Actually if the current test executes then its a pass right......?_ This > means, if there is no NPE raised then its a pass case right.......? Yeah to > some extent it is automatic, I actually didn't get how to handle the caught > NPE, so just left it so that the Test case will be failed by NPE. ------------- PR: https://git.openjdk.java.net/jdk/pull/8830