1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* 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
257
257
double width , double height , boolean preserveAspectRatio ,
258
258
float pixelScale , boolean smooth ) throws ImageStorageException {
259
259
ImageLoader loader = null ;
260
+ ImageFrame [] images = null ;
261
+
260
262
try {
261
263
if (isIOS ) {
262
264
// no extension/signature recognition done here,
@@ -265,17 +267,20 @@ public static ImageFrame[] loadAll(InputStream input, ImageLoadListener listener
265
267
} else {
266
268
loader = getLoaderBySignature (input , listener );
267
269
}
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 ;
268
277
} catch (IOException e ) {
269
278
throw new ImageStorageException (e .getMessage (), e );
279
+ } finally {
280
+ if (loader != null ) {
281
+ loader .dispose ();
282
+ }
270
283
}
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
-
279
284
return images ;
280
285
}
281
286
@@ -326,6 +331,9 @@ public static ImageFrame[] loadAll(String input, ImageLoadListener listener,
326
331
throw new ImageStorageException ("No loader for image data" );
327
332
}
328
333
} finally {
334
+ if (loader != null ) {
335
+ loader .dispose ();
336
+ }
329
337
try {
330
338
if (theStream != null ) {
331
339
theStream .close ();
0 commit comments