On Mon, 28 Feb 2022 21:56:44 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:
>> DamonGuy has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Updated exception propagation. Added button location to EDT. Updated >> testImageCentering for variable arguments. Moved object instantiation to the >> same line. > > test/jdk/javax/swing/JButton/HtmlButtonImageTest/HtmlButtonImageTest.java > line 92: > >> 90: BufferedImage failImg = robot.createScreenCapture(new >> Rectangle(point.x - BUTTON_WIDTH / 2, point.y - BUTTON_HEIGHT / 2, >> BUTTON_WIDTH, BUTTON_HEIGHT)); >> 91: ImageIO.write(failImg, "png", new File(testDir + >> "/fail_square.png")); >> 92: throw new RuntimeException("Failed image generation: " + e); > > This doesn't make sense. I mean `IOException` can be thrown from try-block > only from `generateImage` method. In this case, there's nothing to display on > screen and therefore nothing to capture. You should not catch `IOException` > at all. > > You should create the screenshot if the conditions you verify aren't met. The > screenshot should be taken inside `if (!checkRedness(c))` block before you > throw the `RuntimeException` to indicate failure. I believe I fixed the additional changes requested in the next commit. I understand what you meant with main handling exceptions now. ------------- PR: https://git.openjdk.java.net/jdk/pull/7310