Skip to content

Commit

Permalink
Fix #3047: OpenMetadata Server fails to run when updating config from…
Browse files Browse the repository at this point in the history
… Environment Variable (#3049)
  • Loading branch information
harshach committed Mar 1, 2022
1 parent c65cdbb commit 58df9f1
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.openmetadata.catalog.entity.teams.User;
import org.openmetadata.catalog.exception.EntityNotFoundException;
import org.openmetadata.catalog.jdbi3.CollectionDAO;
import org.openmetadata.catalog.jdbi3.RoleRepository;
import org.openmetadata.catalog.jdbi3.UserRepository;
import org.openmetadata.catalog.resources.teams.UserResource;
import org.openmetadata.catalog.security.policyevaluator.PolicyEvaluator;
Expand All @@ -47,6 +48,7 @@ public class DefaultAuthorizer implements Authorizer {

private String principalDomain;
private UserRepository userRepository;
private RoleRepository roleRepository;

private PolicyEvaluator policyEvaluator;
private static final String FIELDS_PARAM = "roles,teams";
Expand All @@ -60,6 +62,10 @@ public void init(AuthorizerConfiguration config, Jdbi dbi) throws IOException {
LOG.debug("Admin users: {}", adminUsers);
CollectionDAO collectionDAO = dbi.onDemand(CollectionDAO.class);
this.userRepository = new UserRepository(collectionDAO);
// RoleRepository needs to be instantiated for Entity.DAO_MAP to populated.
// As we create default admin/bots we need to have RoleRepository available in DAO_MAP.
// This needs to be handled better in future releases.
this.roleRepository = new RoleRepository(collectionDAO);
mayBeAddAdminUsers();
mayBeAddBotUsers();
this.policyEvaluator = PolicyEvaluator.getInstance();
Expand Down

0 comments on commit 58df9f1

Please sign in to comment.