A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/coobird/thumbnailator/commit/0aac25ded262711daeccb0d02110cb43c69a1899 below:

Fix #148 by properly closing releasing resources in `FileImageSink`. · coobird/thumbnailator@0aac25d · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+24

-3

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+24

-3

lines changed Original file line number Diff line number Diff line change

@@ -313,12 +313,13 @@ public void write(BufferedImage img) throws IOException

313 313

"Could not determine output format."

314 314

);

315 315

}

316 - 317 -

imageSink = new OutputStreamImageSink(new FileOutputStream(destinationFile));

316 + 317 +

FileOutputStream fos = new FileOutputStream(destinationFile);

318 +

imageSink = new OutputStreamImageSink(fos);

318 319

imageSink.setThumbnailParameter(param);

319 320

imageSink.setOutputFormatName(formatName);

320 - 321 321

imageSink.write(img);

322 +

fos.close();

322 323

}

323 324 324 325

/**

Original file line number Diff line number Diff line change

@@ -2332,4 +2332,24 @@ public void preferredOutputFormatName_FileIsPNG()

2332 2332

// then

2333 2333

assertEquals("png", sink.preferredOutputFormatName());

2334 2334

}

2335 + 2336 +

// What we really want to check the file resource is released.

2337 +

@Test

2338 +

public void write_FileDeletableAfterWrite_Issue148() throws IOException

2339 +

{

2340 +

// given

2341 +

File outputFile = new File(TMPDIR, "test.png");

2342 + 2343 +

BufferedImage imgToWrite =

2344 +

new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);

2345 + 2346 +

FileImageSink sink = new FileImageSink(outputFile);

2347 + 2348 +

// when

2349 +

sink.write(imgToWrite);

2350 + 2351 +

// then

2352 +

assertEquals(outputFile, sink.getSink());

2353 +

assertTrue(outputFile.delete());

2354 +

}

2335 2355

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4