close subversion context, if the service provider is closed

This commit is contained in:
Sebastian Sdorra
2014-04-03 21:48:35 +02:00
parent 014220a45b
commit 02b5eadb02

View File

@@ -30,18 +30,23 @@
*/ */
package sonia.scm.repository.spi; package sonia.scm.repository.spi;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.io.Closeables;
import sonia.scm.repository.Repository; import sonia.scm.repository.Repository;
import sonia.scm.repository.SvnRepositoryHandler; import sonia.scm.repository.SvnRepositoryHandler;
import sonia.scm.repository.SvnUtil;
import sonia.scm.repository.api.Command; import sonia.scm.repository.api.Command;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.util.Set; import java.util.Set;
/** /**
@@ -53,8 +58,8 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
/** Field description */ /** Field description */
public static final Set<Command> COMMANDS = ImmutableSet.of(Command.BLAME, public static final Set<Command> COMMANDS = ImmutableSet.of(Command.BLAME,
Command.BROWSE, Command.CAT, Command.BROWSE, Command.CAT,
Command.DIFF, Command.LOG); Command.DIFF, Command.LOG);
//~--- constructors --------------------------------------------------------- //~--- constructors ---------------------------------------------------------
@@ -66,12 +71,26 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
* @param repository * @param repository
*/ */
SvnRepositoryServiceProvider(SvnRepositoryHandler handler, SvnRepositoryServiceProvider(SvnRepositoryHandler handler,
Repository repository) Repository repository)
{ {
this.repository = repository; this.repository = repository;
this.context = new SvnContext(handler.getDirectory(repository)); this.context = new SvnContext(handler.getDirectory(repository));
} }
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @throws IOException
*/
@Override
public void close() throws IOException
{
Closeables.close(context, true);
}
//~--- get methods ---------------------------------------------------------- //~--- get methods ----------------------------------------------------------
/** /**
@@ -149,8 +168,8 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
//~--- fields --------------------------------------------------------------- //~--- fields ---------------------------------------------------------------
/** Field description */ /** Field description */
private SvnContext context; private final SvnContext context;
/** Field description */ /** Field description */
private Repository repository; private final Repository repository;
} }