Merge lp:~pbeaman/akiban-persistit/close-dump-task-test-streams into lp:akiban-persistit

Proposed by Peter Beaman
Status: Merged
Approved by: Nathan Williams
Approved revision: 400
Merged at revision: 402
Proposed branch: lp:~pbeaman/akiban-persistit/close-dump-task-test-streams
Merge into: lp:akiban-persistit
Diff against target: 40 lines (+16/-7)
1 file modified
src/test/java/com/persistit/DumpTaskTest.java (+16/-7)
To merge this branch: bzr merge lp:~pbeaman/akiban-persistit/close-dump-task-test-streams
Reviewer Review Type Date Requested Status
Nathan Williams Approve
Review via email: mp+136802@code.launchpad.net

Description of the change

Adds code to close ZipInputStream and DataInputStrem in DumpTaskTest.

This is motivated by bug https://bugs.launchpad.net/akiban-persistit/+bug/1084260 which is a recurring annoyance. These changes probably won't fix that bug, but since we we think everything else is cleaned up properly this is an experiment to just to see whether there's some mechanism we don't understand going on here.

And anyway, it can't hurt...

To post a comment you must log in.
Revision history for this message
Nathan Williams (nwilliams) wrote :

Simple enough.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/test/java/com/persistit/DumpTaskTest.java'
2--- src/test/java/com/persistit/DumpTaskTest.java 2012-11-25 20:14:58 +0000
3+++ src/test/java/com/persistit/DumpTaskTest.java 2012-11-28 21:53:20 +0000
4@@ -67,8 +67,6 @@
5 @Test
6 public void testDumpCommand() throws Exception {
7 store1();
8- final Volume volume = _persistit.getVolume("persistit");
9- final Buffer buffer = _persistit.getBufferPool(16384).getBufferCopy(volume, 1);
10 final CLI cli = new CLI(_persistit, null, null);
11 final File file = File.createTempFile("DumpTaskTest", ".zip");
12 file.deleteOnExit();
13@@ -76,11 +74,22 @@
14 task.setPersistit(_persistit);
15 task.run();
16
17- final ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(file)));
18- final ZipEntry ze = zis.getNextEntry();
19- System.out.println(ze);
20- final DataInputStream stream = new DataInputStream(new BufferedInputStream(zis));
21-
22+ ZipInputStream zis = null;
23+ DataInputStream stream = null;
24+ try {
25+ zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(file)));
26+ final ZipEntry ze = zis.getNextEntry();
27+ System.out.println(ze);
28+ stream = new DataInputStream(new BufferedInputStream(zis));
29+ } finally {
30+ if (stream != null) {
31+ stream.close();
32+ }
33+ if (zis != null) {
34+ zis.close();
35+ }
36+ file.delete();
37+ }
38 }
39
40 private void store1() throws PersistitException {

Subscribers

People subscribed via source and target branches