#vulnerable code 
                                private void writeKryo(String fileName, GraphDatabaseService db, SubGraph graph, ProgressReporter reporter, Config config) throws Exception {
        OutputStream outputStream = new DeflaterOutputStream(new FileOutputStream(fileName, true));
        com.esotericsoftware.kryo.io.Output output = new com.esotericsoftware.kryo.io.Output(outputStream);
        try (Transaction tx = db.beginTx()) {
            KryoWriter kryoWriter = new KryoWriter();
            kryoWriter.write(graph, output, reporter, config);
            tx.success();
        } finally {
            output.close();
        }
    } 
                            #location 3 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                private void writeKryo(String fileName, GraphDatabaseService db, SubGraph graph, ProgressReporter reporter, Config config) throws Exception {
        OutputStream outputStream = new BufferedOutputStream(new DeflaterOutputStream(new FileOutputStream(fileName, true), false), FileUtils.MEGABYTE);
        com.esotericsoftware.kryo.io.Output output = new com.esotericsoftware.kryo.io.Output(outputStream, FileUtils.MEGABYTE);
        try (Transaction tx = db.beginTx()) {
            KryoWriter kryoWriter = new KryoWriter();
            kryoWriter.write(graph, output, reporter, config);
            tx.success();
        } finally {
            output.close();
        }
    }