Skip to content

Commit

Permalink
fix: sync bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gb-cic committed Dec 19, 2023
1 parent 5fd3b25 commit 37f4164
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void postConstruct() {
public Integer getExpirationDate() {
long lastUpdate = props.get(PROPS_NAME_EXP_DAYS).getKey();
if (new Date().getTime() - lastUpdate >= DELTA_MS) {
synchronized(PROPS_NAME_EXP_DAYS) {
synchronized(Locks.EXP_DAYS) {
if (new Date().getTime() - lastUpdate >= DELTA_MS) {
refresh(PROPS_NAME_EXP_DAYS);
}
Expand All @@ -77,7 +77,7 @@ public Integer getExpirationDate() {
public Boolean isSubjectNotAllowed() {
long lastUpdate = props.get(PROPS_NAME_SUBJECT).getKey();
if (new Date().getTime() - lastUpdate >= DELTA_MS) {
synchronized (PROPS_NAME_SUBJECT) {
synchronized (Locks.SUBJECT_CLEANING) {
if (new Date().getTime() - lastUpdate >= DELTA_MS) {
refresh(PROPS_NAME_SUBJECT);
}
Expand All @@ -92,7 +92,7 @@ public Boolean isSubjectNotAllowed() {
public Boolean isCfOnIssuerNotAllowed() {
long lastUpdate = props.get(PROPS_NAME_ISSUER_CF).getKey();
if (new Date().getTime() - lastUpdate >= DELTA_MS) {
synchronized(PROPS_NAME_ISSUER_CF) {
synchronized(Locks.ISSUER_CF_CLEANING) {
if (new Date().getTime() - lastUpdate >= DELTA_MS) {
refresh(PROPS_NAME_ISSUER_CF);
}
Expand Down Expand Up @@ -136,4 +136,12 @@ private void init() {
}
integrity();
}

private static final class Locks {
public static final Object EXP_DAYS = new Object();
public static final Object SUBJECT_CLEANING = new Object();
public static final Object ISSUER_CF_CLEANING = new Object();
}


}

0 comments on commit 37f4164

Please sign in to comment.