Skip to content

Commit

Permalink
GUI PRofile Invalidation: Fixed NPE in tests when sessionRegistry is …
Browse files Browse the repository at this point in the history
…unavailable

Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
  • Loading branch information
tonydamage committed Jul 13, 2022
1 parent 99abf3d commit c1dee8b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.evolveum.midpoint.CacheInvalidationContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.repo.api.Cache;
import com.evolveum.midpoint.repo.api.CacheInvalidationEventSpecification;
import com.evolveum.midpoint.repo.api.CacheRegistry;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.schema.expression.ExpressionProfile;
Expand Down Expand Up @@ -73,6 +74,12 @@ public class ArchetypeManager implements Cache {
ObjectTemplateType.class
);

private static final Set<CacheInvalidationEventSpecification> CACHE_SPECIFICATION = Collections.unmodifiableSet(
CacheInvalidationEventSpecification.setOf(
ArchetypeType.class,
SystemConfigurationType.class,
ObjectTemplateType.class));

@Autowired private SystemObjectCache systemObjectCache;
@Autowired private CacheRegistry cacheRegistry;
@Autowired private ArchetypeDeterminer archetypeDeterminer;
Expand Down Expand Up @@ -375,6 +382,11 @@ public <O extends ObjectType> ExpressionProfile determineExpressionProfile(Prism
return systemObjectCache.getExpressionProfile(expressionProfileId, result);
}

@Override
public Collection<CacheInvalidationEventSpecification> getEventSpecifications() {
return CACHE_SPECIFICATION;
}

@Override
public void invalidate(Class<?> type, String oid, CacheInvalidationContext context) {
// This seems to be harsh (and probably is), but a policy can really depend on a mix of objects. So we have to play
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@ public Collection<CacheInvalidationEventSpecification> getEventSpecifications()
@Override
public <O extends ObjectType> void invalidate(Class<O> type, String oid, boolean clusterwide,
CacheInvalidationContext context) {
if (sessionRegistry == null) {
// In tests sessionRegistry is null.
return;
}

List<Object> loggedInUsers = sessionRegistry.getAllPrincipals();
for (Object principal : loggedInUsers) {

Expand Down

0 comments on commit c1dee8b

Please sign in to comment.