@@ -42,6 +42,7 @@ public class SftpFileOutput
4242 private final int taskIndex ;
4343 private int fileIndex = 0 ;
4444 private FileObject currentRamFile ;
45+ private OutputStream currentRamFileOutputStream ;
4546
4647 private StandardFileSystemManager initializeStandardFileSystemManager ()
4748 {
@@ -109,6 +110,7 @@ public void nextFile()
109110
110111 try {
111112 currentRamFile = newRamFile (getRamUri (getOutputFilePath ()));
113+ currentRamFileOutputStream = getCurrentRamFileOutputStream ();
112114 logger .info ("new ram file: {}" , currentRamFile .getPublicURIString ());
113115 }
114116 catch (FileSystemException e ) {
@@ -129,7 +131,7 @@ public void add(Buffer buffer)
129131 }
130132
131133 try {
132- getCurrentRamFileOutputStream () .write (buffer .array (), buffer .offset (), buffer .limit ());
134+ currentRamFileOutputStream .write (buffer .array (), buffer .offset (), buffer .limit ());
133135 }
134136 catch (IOException e ) {
135137 logger .error (e .getMessage ());
@@ -169,11 +171,11 @@ private void closeCurrentWithUpload()
169171 uploadCurrentRamFileToSftp ();
170172 closeCurrentRamFile ();
171173 }
172- catch (FileSystemException e ) {
174+ catch (URISyntaxException e ) {
173175 logger .error (e .getMessage ());
174176 Throwables .propagate (e );
175177 }
176- catch (URISyntaxException e ) {
178+ catch (IOException e ) {
177179 logger .error (e .getMessage ());
178180 Throwables .propagate (e );
179181 }
@@ -182,11 +184,12 @@ private void closeCurrentWithUpload()
182184 }
183185
184186 private void closeCurrentRamFileContent ()
185- throws FileSystemException
187+ throws IOException
186188 {
187189 if (currentRamFile == null ) {
188190 return ;
189191 }
192+ currentRamFileOutputStream .close ();
190193 currentRamFile .getContent ().close ();
191194 }
192195
0 commit comments