RESOLVED - BATCH-843: FlatFileItemWriter handling of failure in LineAggregator

This commit is contained in:
robokaso
2008-09-22 09:05:17 +00:00
parent a793fd87b4
commit b1f211509a
2 changed files with 55 additions and 18 deletions

View File

@@ -186,15 +186,19 @@ public class FlatFileItemWriter<T> extends ExecutionContextUserSupport implement
OutputState state = getOutputState();
StringBuilder lines = new StringBuilder();
int lineCount = 0;
for (T item : items) {
String line = lineAggregator.aggregate(item) + lineSeparator;
try {
state.write(line);
}
catch (IOException e) {
throw new FlushFailedException("Could not write data. The file may be corrupt.", e);
}
lines.append(lineAggregator.aggregate(item) + lineSeparator);
lineCount++;
}
try {
state.write(lines.toString());
}
catch (IOException e) {
throw new FlushFailedException("Could not write data. The file may be corrupt.", e);
}
state.linesWritten += lineCount;
}
/**
@@ -394,7 +398,6 @@ public class FlatFileItemWriter<T> extends ExecutionContextUserSupport implement
outputBufferedWriter.write(line);
outputBufferedWriter.flush();
linesWritten++;
}
/**