~pbeaman/akiban-persistit/fix-1157809-aioobe-on-append-key-segment

« back to all changes in this revision

Viewing changes to src/test/java/com/persistit/DumpTaskTest.java

merge pbeaman: Adds code to close ZipInputStream and DataInputStrem in DumpTaskTest.

https://code.launchpad.net/~pbeaman/akiban-persistit/close-dump-task-test-streams/+merge/136802

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
    @Test
68
68
    public void testDumpCommand() throws Exception {
69
69
        store1();
70
 
        final Volume volume = _persistit.getVolume("persistit");
71
 
        final Buffer buffer = _persistit.getBufferPool(16384).getBufferCopy(volume, 1);
72
70
        final CLI cli = new CLI(_persistit, null, null);
73
71
        final File file = File.createTempFile("DumpTaskTest", ".zip");
74
72
        file.deleteOnExit();
76
74
        task.setPersistit(_persistit);
77
75
        task.run();
78
76
 
79
 
        final ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(file)));
80
 
        final ZipEntry ze = zis.getNextEntry();
81
 
        System.out.println(ze);
82
 
        final DataInputStream stream = new DataInputStream(new BufferedInputStream(zis));
83
 
 
 
77
        ZipInputStream zis = null;
 
78
        DataInputStream stream = null;
 
79
        try {
 
80
            zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(file)));
 
81
            final ZipEntry ze = zis.getNextEntry();
 
82
            System.out.println(ze);
 
83
            stream = new DataInputStream(new BufferedInputStream(zis));
 
84
        } finally {
 
85
            if (stream != null) {
 
86
                stream.close();
 
87
            }
 
88
            if (zis != null) {
 
89
                zis.close();
 
90
            }
 
91
            file.delete();
 
92
        }
84
93
    }
85
94
 
86
95
    private void store1() throws PersistitException {