Skip to content

Commit

Permalink
fix(jans-auth-server): fixed status pool index joining
Browse files Browse the repository at this point in the history
#8562
Signed-off-by: YuriyZ <yzabrovarniy@gmail.com>
  • Loading branch information
yuriyz committed Jun 27, 2024
1 parent ccf2306 commit a143dd0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public StatusIndexPool allocate(int nodeId) {
return lockedPool;
}
} catch (EntryPersistenceException ex) {
log.trace("Unexpected error happened during entry lock, node " + nodeId, ex);
log.debug("Unexpected error happened during entry lock, node " + nodeId, ex);
}
}

Expand Down Expand Up @@ -255,7 +255,7 @@ public StatusIndexPool allocate(int nodeId) {
log.debug("Failed to create new status index pool {}, node {}", lockedPool.getId(), nodeId);
}
} catch (EntryPersistenceException ex) {
log.trace("Unexpected error happened during entry lock, node " + nodeId, ex);
log.debug("Unexpected error happened during entry lock, node " + nodeId, ex);
}
attempt++;
} while (attempt <= ATTEMPT_LIMIT);
Expand All @@ -265,6 +265,10 @@ public StatusIndexPool allocate(int nodeId) {
}

private StatusIndexPool setIndexes(StatusIndexPool pool) {
return setIndexes(pool, indexAllocationBlockSize);
}

public static StatusIndexPool setIndexes(StatusIndexPool pool, int indexAllocationBlockSize) {
if (pool == null) {
return pool;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
import io.jans.as.server.service.cluster.StatusIndexPoolService;
import io.jans.model.token.StatusIndexPool;
import io.jans.model.tokenstatus.StatusList;
import io.jans.model.tokenstatus.TokenStatus;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.apache.commons.lang.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;

Expand Down Expand Up @@ -100,11 +102,19 @@ public StatusList join(List<StatusIndexPool> pools) {
StatusList result = new StatusList(bitSize);
for (StatusIndexPool pool : pools) {
try {
StatusList poolStatusList = StatusList.fromEncoded(pool.getData(), bitSize);
for (int i = 0; i < poolStatusList.getBitSetLength(); i++) {
result.set(pool.getStartIndex() + i, poolStatusList.get(i));
final String data = pool.getData();
if (StringUtils.isBlank(data)) {
continue;
}

StatusList poolStatusList = StatusList.fromEncoded(data, bitSize);
for (int i = 0; i < poolStatusList.getBitSetLength(); i++) {
int value = poolStatusList.get(i);
boolean isNotDefault = value != TokenStatus.VALID.getValue();
if (isNotDefault) {
result.set(i, value);
}
}
} catch (Exception e) {
String msg = String.format("Failed to process status list from pool: %s, nodeId: %s", pool.getId(), pool.getNodeId());
log.error(msg, e);
Expand Down

0 comments on commit a143dd0

Please sign in to comment.