Source:
public void synchronizeToLocalDirectory(final File localDirectory, final int maxFetchSize) { final String remoteDirectory = this.remoteDirectoryExpression.getValue(this.evaluationContext, String.class); try { int transferred = this.remoteFileTemplate.execute(new SessionCallback<F, Integer>() { @Override public Integer doInSession(Session<F> session) throws IOException { F[] files = session.list(remoteDirectory); if (!ObjectUtils.isEmpty(files)) { List<F> filteredFiles = filterFiles(files); if (maxFetchSize >= 0 && filteredFiles.size() > maxFetchSize) { rollbackFromFileToListEnd(filteredFiles, filteredFiles.get(maxFetchSize)); List<F> newList = new ArrayList<>(maxFetchSize); for (int i = 0; i < maxFetchSize; i++) { newList.add(filteredFiles.get(0)); } filteredFiles = newList; } for (F file : filteredFiles) { try { if (file != null) { copyFileToLocalDirectory( remoteDirectory, file, localDirectory, session); } } catch (RuntimeException e) { rollbackFromFileToListEnd(filteredFiles, file); throw e; } catch (IOException e) { rollbackFromFileToListEnd(filteredFiles, file); throw e; } } return filteredFiles.size(); } else { return 0; } } public void rollbackFromFileToListEnd(List<F> filteredFiles, F file) { if (AbstractInboundFileSynchronizer.this.filter instanceof ReversibleFileListFilter) { ((ReversibleFileListFilter<F>) AbstractInboundFileSynchronizer.this.filter) .rollback(file, filteredFiles); } } }); if (this.logger.isDebugEnabled()) { this.logger.debug(transferred + " files transferred"); } } catch (Exception e) { throw new MessagingException("Problem occurred while synchronizing remote to local directory", e); } }

Target:
public void synchronizeToLocalDirectory(final File localDirectory, final int maxFetchSize) { if (maxFetchSize == 0) { if (logger.isDebugEnabled()) { logger.debug("Max Fetch Size is zero - fetch to " + localDirectory.getAbsolutePath() + " ignored"); } return; } final String remoteDirectory = this.remoteDirectoryExpression.getValue(this.evaluationContext, String.class); try { int transferred = this.remoteFileTemplate.execute(new SessionCallback<F, Integer>() { @Override public Integer doInSession(Session<F> session) throws IOException { F[] files = session.list(remoteDirectory); if (!ObjectUtils.isEmpty(files)) { List<F> filteredFiles = filterFiles(files); if (maxFetchSize >= 0 && filteredFiles.size() > maxFetchSize) { rollbackFromFileToListEnd(filteredFiles, filteredFiles.get(maxFetchSize)); List<F> newList = new ArrayList<>(maxFetchSize); for (int i = 0; i < maxFetchSize; i++) { newList.add(filteredFiles.get(i)); } filteredFiles = newList; } for (F file : filteredFiles) { try { if (file != null) { copyFileToLocalDirectory( remoteDirectory, file, localDirectory, session); } } catch (RuntimeException e) { rollbackFromFileToListEnd(filteredFiles, file); throw e; } catch (IOException e) { rollbackFromFileToListEnd(filteredFiles, file); throw e; } } return filteredFiles.size(); } else { return 0; } } public void rollbackFromFileToListEnd(List<F> filteredFiles, F file) { if (AbstractInboundFileSynchronizer.this.filter instanceof ReversibleFileListFilter) { ((ReversibleFileListFilter<F>) AbstractInboundFileSynchronizer.this.filter) .rollback(file, filteredFiles); } } }); if (this.logger.isDebugEnabled()) { this.logger.debug(transferred + " files transferred"); } } catch (Exception e) { throw new MessagingException("Problem occurred while synchronizing remote to local directory", e); } }