mirror of https://github.com/halo-dev/halo
fix: volatile in double-checked locking (#799)
parent
5eb47b617e
commit
532b7f0532
|
@ -81,12 +81,12 @@ public class ThemeServiceImpl implements ThemeService {
|
||||||
/**
|
/**
|
||||||
* Activated theme id.
|
* Activated theme id.
|
||||||
*/
|
*/
|
||||||
private String activatedThemeId;
|
private volatile String activatedThemeId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activated theme property.
|
* Activated theme property.
|
||||||
*/
|
*/
|
||||||
private ThemeProperty activatedTheme;
|
private volatile ThemeProperty activatedTheme;
|
||||||
|
|
||||||
public ThemeServiceImpl(HaloProperties haloProperties,
|
public ThemeServiceImpl(HaloProperties haloProperties,
|
||||||
OptionService optionService,
|
OptionService optionService,
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.util.*;
|
||||||
*/
|
*/
|
||||||
public class ValidationUtils {
|
public class ValidationUtils {
|
||||||
|
|
||||||
private static Validator VALIDATOR;
|
private static volatile Validator VALIDATOR;
|
||||||
|
|
||||||
private ValidationUtils() {
|
private ValidationUtils() {
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,12 @@ public class ValidationUtils {
|
||||||
public static Validator getValidatorOrCreate() {
|
public static Validator getValidatorOrCreate() {
|
||||||
if (VALIDATOR == null) {
|
if (VALIDATOR == null) {
|
||||||
synchronized (ValidationUtils.class) {
|
synchronized (ValidationUtils.class) {
|
||||||
|
if (VALIDATOR == null) {
|
||||||
// Init the validation
|
// Init the validation
|
||||||
VALIDATOR = Validation.buildDefaultValidatorFactory().getValidator();
|
VALIDATOR = Validation.buildDefaultValidatorFactory().getValidator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return VALIDATOR;
|
return VALIDATOR;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue