mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
fix mercurial out of scope exception on startup
This commit is contained in:
@@ -35,8 +35,11 @@ package sonia.scm.repository;
|
|||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.OutOfScopeException;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
import com.google.inject.ProvisionException;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -151,7 +154,7 @@ public class HgHookManager implements ConfigChangedListener<ScmConfiguration>
|
|||||||
|
|
||||||
if (url == null)
|
if (url == null)
|
||||||
{
|
{
|
||||||
HttpServletRequest request = httpServletRequestProvider.get();
|
HttpServletRequest request = getHttpServletRequest();
|
||||||
|
|
||||||
if (request != null)
|
if (request != null)
|
||||||
{
|
{
|
||||||
@@ -159,10 +162,10 @@ public class HgHookManager implements ConfigChangedListener<ScmConfiguration>
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.warn(
|
|
||||||
"created hook url {} without request, in some cases this could cause problems",
|
|
||||||
hookUrl);
|
|
||||||
url = createConfiguredUrl();
|
url = createConfiguredUrl();
|
||||||
|
logger.warn(
|
||||||
|
"created url {} without request, in some cases this could cause problems",
|
||||||
|
url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,8 +271,14 @@ public class HgHookManager implements ConfigChangedListener<ScmConfiguration>
|
|||||||
*/
|
*/
|
||||||
private String createConfiguredUrl()
|
private String createConfiguredUrl()
|
||||||
{
|
{
|
||||||
|
//J-
|
||||||
return HttpUtil.getUriWithoutEndSeperator(
|
return HttpUtil.getUriWithoutEndSeperator(
|
||||||
configuration.getBaseUrl()).concat("/hook/hg/");
|
Objects.firstNonNull(
|
||||||
|
configuration.getBaseUrl(),
|
||||||
|
"http://localhost:8080/scm"
|
||||||
|
)
|
||||||
|
).concat("/hook/hg/");
|
||||||
|
//J+
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -308,6 +317,32 @@ public class HgHookManager implements ConfigChangedListener<ScmConfiguration>
|
|||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private HttpServletRequest getHttpServletRequest()
|
||||||
|
{
|
||||||
|
HttpServletRequest request = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
request = httpServletRequestProvider.get();
|
||||||
|
}
|
||||||
|
catch (ProvisionException ex)
|
||||||
|
{
|
||||||
|
logger.debug("http servlet request is not available");
|
||||||
|
}
|
||||||
|
catch (OutOfScopeException ex)
|
||||||
|
{
|
||||||
|
logger.debug("http servlet request is not available");
|
||||||
|
}
|
||||||
|
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user