File tree 1 file changed +6
-14
lines changed
java/client/src/org/openqa/selenium
1 file changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -84,26 +84,18 @@ public File convertFromPngBytes(byte[] data) {
84
84
}
85
85
86
86
private File save (byte [] data ) {
87
- OutputStream stream = null ;
88
-
89
87
try {
90
88
File tmpFile = File .createTempFile ("screenshot" , ".png" );
91
89
tmpFile .deleteOnExit ();
92
90
93
- stream = new FileOutputStream (tmpFile );
94
- stream .write (data );
95
-
96
- return tmpFile ;
91
+ try (OutputStream stream = new FileOutputStream (tmpFile )) {
92
+ stream .write (data );
93
+ return tmpFile ;
94
+ } catch (IOException e ) {
95
+ throw new WebDriverException (e );
96
+ }
97
97
} catch (IOException e ) {
98
98
throw new WebDriverException (e );
99
- } finally {
100
- if (stream != null ) {
101
- try {
102
- stream .close ();
103
- } catch (IOException e ) {
104
- // Nothing sane to do
105
- }
106
- }
107
99
}
108
100
}
109
101
You can’t perform that action at this time.
0 commit comments