fix #537 : remove npe from ContainerNotAvailableException
This commit is contained in:
parent
453db85ac3
commit
26df9e49b0
3 changed files with 40 additions and 3 deletions
|
@ -19,8 +19,24 @@ public class ContainerNotAvailableException extends FessSystemException {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String componentName;
|
||||
|
||||
public ContainerNotAvailableException(final String componentName) {
|
||||
super(componentName + " is not available.");
|
||||
}
|
||||
|
||||
public ContainerNotAvailableException(final String componentName, final Throwable cause) {
|
||||
super(componentName + " is not available.", cause);
|
||||
this.componentName = componentName;
|
||||
}
|
||||
|
||||
public ContainerNotAvailableException(final Throwable cause) {
|
||||
super(cause);
|
||||
super("Container is not avaiable.");
|
||||
this.componentName = "container";
|
||||
}
|
||||
|
||||
public String getComponentName() {
|
||||
return componentName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.codelibs.fess.crawler.util.EsResultList;
|
|||
import org.codelibs.fess.es.client.FessEsClient;
|
||||
import org.codelibs.fess.es.log.exbhv.ClickLogBhv;
|
||||
import org.codelibs.fess.es.log.exbhv.FavoriteLogBhv;
|
||||
import org.codelibs.fess.exception.ContainerNotAvailableException;
|
||||
import org.codelibs.fess.exception.FessSystemException;
|
||||
import org.codelibs.fess.helper.IndexingHelper;
|
||||
import org.codelibs.fess.helper.IntervalControlHelper;
|
||||
|
@ -287,9 +288,18 @@ public class IndexUpdater extends Thread {
|
|||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Finished indexUpdater.");
|
||||
}
|
||||
} catch (final ContainerNotAvailableException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.error("IndexUpdater is terminated.", e);
|
||||
} else if (logger.isInfoEnabled()) {
|
||||
logger.info("IndexUpdater is terminated.");
|
||||
}
|
||||
forceStop();
|
||||
} catch (final Throwable t) {
|
||||
if (ComponentUtil.available()) {
|
||||
logger.error("IndexUpdater is terminated.", t);
|
||||
} else if (logger.isDebugEnabled()) {
|
||||
logger.error("IndexUpdater is terminated.", t);
|
||||
} else if (logger.isInfoEnabled()) {
|
||||
logger.info("IndexUpdater is terminated.");
|
||||
}
|
||||
|
|
|
@ -61,8 +61,11 @@ import org.lastaflute.di.core.factory.SingletonLaContainerFactory;
|
|||
import org.lastaflute.di.core.smart.hot.HotdeployUtil;
|
||||
import org.lastaflute.job.JobManager;
|
||||
import org.lastaflute.web.servlet.request.RequestManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class ComponentUtil {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ComponentUtil.class);
|
||||
|
||||
private static final String PERMISSION_HELPER = "permissionHelper";
|
||||
|
||||
|
@ -345,7 +348,11 @@ public final class ComponentUtil {
|
|||
try {
|
||||
return SingletonLaContainer.getComponent(clazz);
|
||||
} catch (final NullPointerException e) {
|
||||
throw new ContainerNotAvailableException(e);
|
||||
if (logger.isDebugEnabled()) {
|
||||
throw new ContainerNotAvailableException(clazz.getCanonicalName(), e);
|
||||
} else {
|
||||
throw new ContainerNotAvailableException(clazz.getCanonicalName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,7 +360,11 @@ public final class ComponentUtil {
|
|||
try {
|
||||
return SingletonLaContainer.getComponent(componentName);
|
||||
} catch (final NullPointerException e) {
|
||||
throw new ContainerNotAvailableException(e);
|
||||
if (logger.isDebugEnabled()) {
|
||||
throw new ContainerNotAvailableException(componentName, e);
|
||||
} else {
|
||||
throw new ContainerNotAvailableException(componentName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue