Skip to content

Commit

Permalink
8196587: Remove use of deprecated finalize method from JPEGImageLoader
Browse files Browse the repository at this point in the history
Reviewed-by: kcr, jvos
  • Loading branch information
arapte committed Dec 18, 2019
1 parent d2d44b4 commit 1140d34
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -257,6 +257,8 @@ public static ImageFrame[] loadAll(InputStream input, ImageLoadListener listener
double width, double height, boolean preserveAspectRatio,
float pixelScale, boolean smooth) throws ImageStorageException {
ImageLoader loader = null;
ImageFrame[] images = null;

try {
if (isIOS) {
// no extension/signature recognition done here,
Expand All @@ -265,17 +267,20 @@ public static ImageFrame[] loadAll(InputStream input, ImageLoadListener listener
} else {
loader = getLoaderBySignature(input, listener);
}
if (loader != null) {
images = loadAll(loader, width, height, preserveAspectRatio, pixelScale, smooth);
} else {
throw new ImageStorageException("No loader for image data");
}
} catch (ImageStorageException ise) {
throw ise;
} catch (IOException e) {
throw new ImageStorageException(e.getMessage(), e);
} finally {
if (loader != null) {
loader.dispose();
}
}

ImageFrame[] images = null;
if (loader != null) {
images = loadAll(loader, width, height, preserveAspectRatio, pixelScale, smooth);
} else {
throw new ImageStorageException("No loader for image data");
}

return images;
}

Expand Down Expand Up @@ -326,6 +331,9 @@ public static ImageFrame[] loadAll(String input, ImageLoadListener listener,
throw new ImageStorageException("No loader for image data");
}
} finally {
if (loader != null) {
loader.dispose();
}
try {
if (theStream != null) {
theStream.close();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -212,10 +212,6 @@ public synchronized void dispose() {
}
}

protected void finalize() {
dispose();
}

/**
* @inheritDoc
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -201,10 +201,6 @@ public synchronized void dispose() {
}
}

protected void finalize() {
dispose();
}

public ImageFrame load(int imageIndex, int width, int height, boolean preserveAspectRatio, boolean smooth) throws IOException {
if (imageIndex != 0) {
return null;
Expand Down

0 comments on commit 1140d34

Please sign in to comment.