mirror of https://github.com/halo-dev/halo
Resolve implicit concurrency problem
parent
dfec650f79
commit
2184102c68
|
@ -8,7 +8,6 @@ import cc.ryanc.halo.service.OptionService;
|
|||
import cc.ryanc.halo.utils.HaloUtils;
|
||||
import cc.ryanc.halo.utils.ThemeUtils;
|
||||
import cc.ryanc.halo.web.controller.content.base.BaseContentController;
|
||||
import cc.ryanc.halo.web.controller.support.PageJacksonSerializer;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import freemarker.template.TemplateModelException;
|
||||
|
@ -67,7 +66,8 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
|
|||
* Cache options to map
|
||||
*/
|
||||
private void cacheOptions() {
|
||||
HaloConst.OPTIONS = optionService.listOptions();
|
||||
OPTIONS.clear();
|
||||
OPTIONS.putAll(optionService.listOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,10 +2,10 @@ package cc.ryanc.halo.model.support;
|
|||
|
||||
import cn.hutool.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
|
@ -36,7 +36,7 @@ public class HaloConst {
|
|||
/**
|
||||
* All of the options
|
||||
*/
|
||||
public static Map<String, String> OPTIONS;
|
||||
public final static ConcurrentMap<String, String> OPTIONS = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* All of the Owo
|
||||
|
|
|
@ -95,11 +95,9 @@ public class HaloUtils {
|
|||
* @return default page size
|
||||
*/
|
||||
public static int getDefaultPageSize() {
|
||||
if (StrUtil.isNotBlank(OPTIONS.get(BlogProperties.INDEX_POSTS))) {
|
||||
return Integer.parseInt(OPTIONS.get(BlogProperties.INDEX_POSTS));
|
||||
}
|
||||
|
||||
return DEFAULT_PAGE_SIZE;
|
||||
return Integer.valueOf(OPTIONS.getOrDefault(
|
||||
BlogProperties.INDEX_POSTS.getValue(),
|
||||
String.valueOf(DEFAULT_PAGE_SIZE)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -62,7 +62,7 @@ public class ThemeController {
|
|||
optionService.saveProperties(properties);
|
||||
BaseContentController.THEME = themeName;
|
||||
OPTIONS.clear();
|
||||
OPTIONS = optionService.listOptions();
|
||||
OPTIONS.putAll(optionService.listOptions());
|
||||
configuration.setSharedVariable("themeName", themeName);
|
||||
configuration.setSharedVariable("options", OPTIONS);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public abstract class BaseController {
|
|||
try {
|
||||
OPTIONS.clear();
|
||||
THEMES.clear();
|
||||
OPTIONS = optionService.listOptions();
|
||||
OPTIONS.putAll(optionService.listOptions());
|
||||
THEMES = ThemeUtils.getThemes();
|
||||
configuration.setSharedVariable("options", OPTIONS);
|
||||
} catch (TemplateModelException e) {
|
||||
|
|
|
@ -295,7 +295,7 @@ public class InstallController {
|
|||
menuService.create(menuArchive);
|
||||
|
||||
OPTIONS.clear();
|
||||
OPTIONS = optionService.listOptions();
|
||||
OPTIONS.putAll(optionService.listOptions());
|
||||
configuration.setSharedVariable("options", OPTIONS);
|
||||
// configuration.setSharedVariable("user", userService.findUser());
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in New Issue