Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8196587: Remove use of deprecated finalize method from JPEGImageLoader #50

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -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
@@ -257,6 +257,8 @@ public static void addImageLoaderFactory(ImageLoaderFactory factory) {
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,
@@ -265,17 +267,20 @@ public static void addImageLoaderFactory(ImageLoaderFactory factory) {
} 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");
This conversation was marked as resolved by arapte

This comment has been minimized.

Copy link
@kevinrushforth

kevinrushforth Nov 26, 2019

Collaborator

Now that this is moved inside a try/catch, this ImageStorageException will get wrapped in another ImageStorageException if it is ever thrown. You probably want to catch ImageStorageException below and re-throw it without wrapping it.

This comment has been minimized.

Copy link
@arapte

arapte Nov 27, 2019

Author

I will change the catch as below and update with next commit.

} catch (ImageStorageException ise) {
        throw ise;
} catch (IOException e) {
        throw new ImageStorageException(e.getMessage(), e);
} 

This comment has been minimized.

Copy link
@arapte

arapte Dec 2, 2019

Author

Updated the catch statement.

}
} 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;
}

@@ -326,6 +331,9 @@ public static void addImageLoaderFactory(ImageLoaderFactory factory) {
throw new ImageStorageException("No loader for image data");
}
} finally {
if (loader != null) {
loader.dispose();
}
try {
if (theStream != null) {
theStream.close();
@@ -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
@@ -212,10 +212,6 @@ public synchronized void dispose() {
}
}

protected void finalize() {
dispose();
}

/**
* @inheritDoc
*/
@@ -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
@@ -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;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.