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.
|
||||
*/
|
||||
private String activatedThemeId;
|
||||
private volatile String activatedThemeId;
|
||||
|
||||
/**
|
||||
* Activated theme property.
|
||||
*/
|
||||
private ThemeProperty activatedTheme;
|
||||
private volatile ThemeProperty activatedTheme;
|
||||
|
||||
public ThemeServiceImpl(HaloProperties haloProperties,
|
||||
OptionService optionService,
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.*;
|
|||
*/
|
||||
public class ValidationUtils {
|
||||
|
||||
private static Validator VALIDATOR;
|
||||
private static volatile Validator VALIDATOR;
|
||||
|
||||
private ValidationUtils() {
|
||||
}
|
||||
|
@ -33,8 +33,10 @@ public class ValidationUtils {
|
|||
public static Validator getValidatorOrCreate() {
|
||||
if (VALIDATOR == null) {
|
||||
synchronized (ValidationUtils.class) {
|
||||
// Init the validation
|
||||
VALIDATOR = Validation.buildDefaultValidatorFactory().getValidator();
|
||||
if (VALIDATOR == null) {
|
||||
// Init the validation
|
||||
VALIDATOR = Validation.buildDefaultValidatorFactory().getValidator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue