Skip to content

Commit 1140d34

Browse files
committed
8196587: Remove use of deprecated finalize method from JPEGImageLoader
Reviewed-by: kcr, jvos
1 parent d2d44b4 commit 1140d34

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

modules/javafx.graphics/src/main/java/com/sun/javafx/iio/ImageStorage.java

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -257,6 +257,8 @@ public static ImageFrame[] loadAll(InputStream input, ImageLoadListener listener
257257
double width, double height, boolean preserveAspectRatio,
258258
float pixelScale, boolean smooth) throws ImageStorageException {
259259
ImageLoader loader = null;
260+
ImageFrame[] images = null;
261+
260262
try {
261263
if (isIOS) {
262264
// no extension/signature recognition done here,
@@ -265,17 +267,20 @@ public static ImageFrame[] loadAll(InputStream input, ImageLoadListener listener
265267
} else {
266268
loader = getLoaderBySignature(input, listener);
267269
}
270+
if (loader != null) {
271+
images = loadAll(loader, width, height, preserveAspectRatio, pixelScale, smooth);
272+
} else {
273+
throw new ImageStorageException("No loader for image data");
274+
}
275+
} catch (ImageStorageException ise) {
276+
throw ise;
268277
} catch (IOException e) {
269278
throw new ImageStorageException(e.getMessage(), e);
279+
} finally {
280+
if (loader != null) {
281+
loader.dispose();
282+
}
270283
}
271-
272-
ImageFrame[] images = null;
273-
if (loader != null) {
274-
images = loadAll(loader, width, height, preserveAspectRatio, pixelScale, smooth);
275-
} else {
276-
throw new ImageStorageException("No loader for image data");
277-
}
278-
279284
return images;
280285
}
281286

@@ -326,6 +331,9 @@ public static ImageFrame[] loadAll(String input, ImageLoadListener listener,
326331
throw new ImageStorageException("No loader for image data");
327332
}
328333
} finally {
334+
if (loader != null) {
335+
loader.dispose();
336+
}
329337
try {
330338
if (theStream != null) {
331339
theStream.close();

modules/javafx.graphics/src/main/java/com/sun/javafx/iio/ios/IosImageLoader.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -212,10 +212,6 @@ public synchronized void dispose() {
212212
}
213213
}
214214

215-
protected void finalize() {
216-
dispose();
217-
}
218-
219215
/**
220216
* @inheritDoc
221217
*/

modules/javafx.graphics/src/main/java/com/sun/javafx/iio/jpeg/JPEGImageLoader.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -201,10 +201,6 @@ public synchronized void dispose() {
201201
}
202202
}
203203

204-
protected void finalize() {
205-
dispose();
206-
}
207-
208204
public ImageFrame load(int imageIndex, int width, int height, boolean preserveAspectRatio, boolean smooth) throws IOException {
209205
if (imageIndex != 0) {
210206
return null;

0 commit comments

Comments
 (0)