Improving the load time of a commit list for a specific branch and tag from a SVN repo My app lists commits from a specific branch and tag on a SVN repo.
The commit list is afterwards transferred to the front end which is a web app.

The method for retrieving the commits takes a rather long time, around half a minute when there are around 100 commits associated with a tag.

I am using SVNKit to communicate with the SVN repository.

&lt;dependency&gt;
    &lt;groupId&gt;org.tmatesoft.svnkit&lt;/groupId&gt;
    &lt;artifactId&gt;svnkit&lt;/artifactId&gt;
    &lt;version&gt;1.2.3.5521&lt;/version&gt;
&lt;/dependency&gt;


Here are the 2 methods responsible for getting the commit list:

/**
 * get a list of all commits associated with a branch and a specific tag
 * @param branch
 * @param tag
 * @return list&lt;Commit&gt;
 * @throws SVNException
 */
public List&lt;Commit&gt; getBranchCommits(String branch, Tag tag) throws SVNException{

    List&lt;Commit&gt; commitList=new ArrayList&lt;Commit&gt;();
    @SuppressWarnings("unchecked")
    Collection&lt;SVNLogEntry&gt; logEntries = repository.log(new String[] {"/Assurance/branches/"+ branch }, null, -1, tag.getRevision(), true, true);

    for (Iterator&lt;SVNLogEntry&gt; entries = logEntries.iterator(); entries.hasNext();) {
        SVNLogEntry logEntry = (SVNLogEntry) entries.next();
        if(logEntry.getAuthor() == null || "SVN_LOGON".equals(logEntry.getAuthor().toUpperCase()))
            continue;
        Commit commit=constructCommit(logEntry);
        commitList.add(commit);
    }
    return commitList;
}

/**
 * construct the object Commit from a svn log entry
 * 
 * @param logEntry
 *            a svn log entry
 * @return a constructed object Commit
 * @throws SVNException 
 */
private Commit constructCommit(SVNLogEntry logEntry) throws SVNException {

    Commit commit = new Commit(logEntry.getRevision(), logEntry.getDate(), logEntry.getAuthor(), logEntry.getMessage());

    @SuppressWarnings("unchecked")
    Iterator&lt;SVNLogEntryPath&gt; changedPaths = logEntry.getChangedPaths().values().iterator();
    while (changedPaths.hasNext()) {
        SVNLogEntryPath entryPath = changedPaths.next();
        SVNNodeKind nodeKind=repository.checkPath(entryPath.getPath(), -1);
        if ( nodeKind != SVNNodeKind.DIR) {
            commit.getChangedPathList().add(new ChangedPath(entryPath.getPath(), entryPath.getType(), entryPath.getCopyPath()));
        }
    }
    commit.getChangedPathList().sort( new Comparator&lt;ChangedPath&gt;() {
        public int compare(ChangedPath o1, ChangedPath o2) {
            return o1.getPath().compareTo(o2.getPath());
        }
    });

    return commit;
}


Waiting for half a minute or even more is rather unpleasant.
Do you have any suggestions for improving this code to make it work faster?
First of all, please check whether it is possible to use a newer version of SVNKit. According to mvnrepository, the used version 1.2.3.5521 is dated of March 2009, which is quite dinosaurian in our days.

The obsolete version might explain the long delays you are experiencing (I underline might explain, because there might have been a lot of optimisations compared with the most recent version, but I don't have any precise idea about it).

Another explanation may be the network communication lags with the SVN server the app is connecting to. It hugely depends on your network conditions and it is possible that there is no remedy for that.

To prove that the problem is related with networks, roughly and manually, the calls of methods on  repository field can be surrounded with time measurements, as well as method entries and exit points, for example:

public List&lt;Commit&gt; getBranchCommits(String branch, Tag tag) throws SVNException {
  final long methodStart = System.nanoTime();
  // other code

  final long repoStart = System.nanoTime();
  Collection&lt;SVNLogEntry&gt; logEntries = repository.log(...);
  final long repoEnd = System.nanoTime();

  // other code

  final long methodEnd = System.nanoTime();

  System.out.println(String.format("Total time: %1$s ms.", (methodEnd - methodStart) / 1_000_000));
  System.out.println(String.format("Repo call time: %1$s ms.", (repoEnd - repoStart) / 1_000_000));
  return commitList;
}


If repository call times take most part of total execution times, the problem is definitely related with network communications.

As for the code you are trying to improve, I can say that there should not be problems with the code itself. Although the style is a bit oldish, it does not look problematic. Here are some suggestions, using Java 8 and functional style:

public List&lt;Commit&gt; getBranchCommits(String branch, Tag tag) throws SVNException {
  @SuppressWarnings("unchecked")
  Collection&lt;SVNLogEntry&gt; logEntries = repository.log(/* no changes in args */);
  return logEntries.stream()
      .filter(this::shouldSkipEntryByAuthor)
      .map(this::constructCommit)
      .collect(Collectors.toList());
}

private boolean shouldSkipEntryByAuthor(SVNLogEntry logEntry) {
  return !(logEntry.getAuthor() == null || "SVN_LOGON".equalsIgnoreCase(logEntry.getAuthor()));
}

private Commit constructCommit(SVNLogEntry logEntry) {

  final Commit commit = new Commit(logEntry.getRevision(), logEntry.getDate(), logEntry.getAuthor(), logEntry.getMessage());

  // the problem with this obsolete API is that getChangedPaths() returns an untyped Map, we need to cast it properly.
  final List&lt;ChangedPath&gt; changedPaths = ((Map&lt;Object, SVNLogEntryPath&gt;) logEntry.getChangedPaths()).values().stream()
                                                .map(entry -&gt; extractChangedPath(entry))
                                                .filter(Optional::isPresent)
                                                .map(Optional::get)
                                                .sorted(Comparator.comparing(ChangedPath::getPath))
                                                .collect(Collectors.toList());
  commit.setChangedPathList(changedPaths);
  return commit;
}

private Optional&lt;ChangedPath&gt; extractChangedPath(SVNLogEntryPath entry) {
  // we need to wrap SVNException into an unchecked one in order to make it compile in lambdas
  try {
    SVNNodeKind nodeKind = repository.checkPath(entry.getPath(), -1);
    if (!SVNNodeKind.DIR.equals(nodeKind)) {
      return Optional.of(new ChangedPath(entry.getPath(), entry.getType(), entry.getCopyPath()));
    }
    return Optional.empty();
  } catch (SVNException ex) {
    throw new IllegalStateException(ex);
  }
}