mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
fix non closing "hg serve" processes
This commit is contained in:
@@ -35,6 +35,8 @@ package sonia.scm.api.rest.resources;
|
|||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import com.google.common.io.Closeables;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -42,6 +44,7 @@ import sonia.scm.repository.PathNotFoundException;
|
|||||||
import sonia.scm.repository.RepositoryException;
|
import sonia.scm.repository.RepositoryException;
|
||||||
import sonia.scm.repository.RevisionNotFoundException;
|
import sonia.scm.repository.RevisionNotFoundException;
|
||||||
import sonia.scm.repository.api.CatCommandBuilder;
|
import sonia.scm.repository.api.CatCommandBuilder;
|
||||||
|
import sonia.scm.repository.api.RepositoryService;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
@@ -72,11 +75,15 @@ public class BrowserStreamingOutput implements StreamingOutput
|
|||||||
* @param browser
|
* @param browser
|
||||||
* @param revision
|
* @param revision
|
||||||
*
|
*
|
||||||
|
* @param repositoryService
|
||||||
|
*
|
||||||
* @param builder
|
* @param builder
|
||||||
* @param path
|
* @param path
|
||||||
*/
|
*/
|
||||||
public BrowserStreamingOutput(CatCommandBuilder builder, String path)
|
public BrowserStreamingOutput(RepositoryService repositoryService,
|
||||||
|
CatCommandBuilder builder, String path)
|
||||||
{
|
{
|
||||||
|
this.repositoryService = repositoryService;
|
||||||
this.builder = builder;
|
this.builder = builder;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
}
|
}
|
||||||
@@ -125,6 +132,10 @@ public class BrowserStreamingOutput implements StreamingOutput
|
|||||||
throw new WebApplicationException(ex,
|
throw new WebApplicationException(ex,
|
||||||
Response.Status.INTERNAL_SERVER_ERROR);
|
Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Closeables.closeQuietly(repositoryService);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
@@ -134,4 +145,7 @@ public class BrowserStreamingOutput implements StreamingOutput
|
|||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private RepositoryService repositoryService;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ package sonia.scm.api.rest.resources;
|
|||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import com.google.common.io.Closeables;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -42,6 +44,7 @@ import sonia.scm.repository.PathNotFoundException;
|
|||||||
import sonia.scm.repository.RepositoryException;
|
import sonia.scm.repository.RepositoryException;
|
||||||
import sonia.scm.repository.RevisionNotFoundException;
|
import sonia.scm.repository.RevisionNotFoundException;
|
||||||
import sonia.scm.repository.api.DiffCommandBuilder;
|
import sonia.scm.repository.api.DiffCommandBuilder;
|
||||||
|
import sonia.scm.repository.api.RepositoryService;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
@@ -69,10 +72,14 @@ public class DiffStreamingOutput implements StreamingOutput
|
|||||||
* Constructs ...
|
* Constructs ...
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
* @param repositoryService
|
||||||
* @param builder
|
* @param builder
|
||||||
*/
|
*/
|
||||||
public DiffStreamingOutput(DiffCommandBuilder builder)
|
public DiffStreamingOutput(RepositoryService repositoryService,
|
||||||
|
DiffCommandBuilder builder)
|
||||||
{
|
{
|
||||||
|
this.repositoryService = repositoryService;
|
||||||
this.builder = builder;
|
this.builder = builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,10 +127,17 @@ public class DiffStreamingOutput implements StreamingOutput
|
|||||||
throw new WebApplicationException(ex,
|
throw new WebApplicationException(ex,
|
||||||
Response.Status.INTERNAL_SERVER_ERROR);
|
Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Closeables.closeQuietly(repositoryService);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private DiffCommandBuilder builder;
|
private DiffCommandBuilder builder;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private RepositoryService repositoryService;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -776,7 +776,7 @@ public class RepositoryResource
|
|||||||
builder.setRevision(revision);
|
builder.setRevision(revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
output = new BrowserStreamingOutput(builder, path);
|
output = new BrowserStreamingOutput(service, builder, path);
|
||||||
|
|
||||||
String contentDispositionName = getContentDispositionNameFromPath(path);
|
String contentDispositionName = getContentDispositionNameFromPath(path);
|
||||||
|
|
||||||
@@ -797,10 +797,6 @@ public class RepositoryResource
|
|||||||
logger.error("could not retrive content", ex);
|
logger.error("could not retrive content", ex);
|
||||||
response = createErrorResonse(ex);
|
response = createErrorResonse(ex);
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
Closeables.closeQuietly(service);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@@ -860,8 +856,8 @@ public class RepositoryResource
|
|||||||
revision).concat(".diff");
|
revision).concat(".diff");
|
||||||
String contentDispositionName = getContentDispositionName(name);
|
String contentDispositionName = getContentDispositionName(name);
|
||||||
|
|
||||||
response = Response.ok(new DiffStreamingOutput(builder)).header(
|
response = Response.ok(new DiffStreamingOutput(service,
|
||||||
"Content-Disposition", contentDispositionName).build();
|
builder)).header("Content-Disposition", contentDispositionName).build();
|
||||||
}
|
}
|
||||||
catch (RepositoryNotFoundException ex)
|
catch (RepositoryNotFoundException ex)
|
||||||
{
|
{
|
||||||
@@ -876,10 +872,6 @@ public class RepositoryResource
|
|||||||
logger.error("could not create diff", ex);
|
logger.error("could not create diff", ex);
|
||||||
response = createErrorResonse(ex);
|
response = createErrorResonse(ex);
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
Closeables.closeQuietly(service);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user