From 77c8719a26ebc410bd4bfc1a25d1a225d67d370e Mon Sep 17 00:00:00 2001 From: robokaso Date: Mon, 24 Nov 2008 10:30:33 +0000 Subject: [PATCH] findbugs fixes --- .../batch/item/file/FlatFileItemWriter.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemWriter.java index cd064f8e9..71658ba58 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/FlatFileItemWriter.java @@ -307,6 +307,8 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implement // default encoding for writing to output files - set to UTF-8. private static final String DEFAULT_CHARSET = "UTF-8"; + private FileOutputStream os; + // The bufferedWriter over the file channel that is actually written Writer outputBufferedWriter; @@ -325,6 +327,7 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implement boolean shouldDeleteIfExists = true; boolean initialized = false; + /** * Return the byte offset position of the cursor in the output file as a @@ -379,6 +382,7 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implement } outputBufferedWriter.close(); fileChannel.close(); + os.close(); } catch (IOException ioe) { throw new ItemStreamException("Unable to close the the ItemWriter", ioe); @@ -419,7 +423,8 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implement FileUtils.setUpOutputFile(file, restarted, shouldDeleteIfExists); - fileChannel = (new FileOutputStream(file.getAbsolutePath(), true)).getChannel(); + os = new FileOutputStream(file.getAbsolutePath(), true); + fileChannel = os.getChannel(); outputBufferedWriter = getBufferedWriter(fileChannel, encoding);