Fix some unemitted alerts in druid-basic-security. (#5327)

This commit is contained in:
Gian Merlino 2018-02-02 11:39:21 -08:00 committed by Jonathan Wei
parent c9e7c0a817
commit de7f28e6d9
2 changed files with 10 additions and 8 deletions

View File

@ -24,8 +24,6 @@ import com.google.common.base.Preconditions;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Injector; import com.google.inject.Injector;
import io.druid.java.util.emitter.EmittingLogger;
import io.druid.java.util.http.client.Request;
import io.druid.client.coordinator.Coordinator; import io.druid.client.coordinator.Coordinator;
import io.druid.concurrent.LifecycleLock; import io.druid.concurrent.LifecycleLock;
import io.druid.discovery.DruidLeaderClient; import io.druid.discovery.DruidLeaderClient;
@ -38,6 +36,8 @@ import io.druid.java.util.common.concurrent.Execs;
import io.druid.java.util.common.concurrent.ScheduledExecutors; import io.druid.java.util.common.concurrent.ScheduledExecutors;
import io.druid.java.util.common.lifecycle.LifecycleStart; import io.druid.java.util.common.lifecycle.LifecycleStart;
import io.druid.java.util.common.lifecycle.LifecycleStop; import io.druid.java.util.common.lifecycle.LifecycleStop;
import io.druid.java.util.emitter.EmittingLogger;
import io.druid.java.util.http.client.Request;
import io.druid.security.basic.BasicAuthCommonCacheConfig; import io.druid.security.basic.BasicAuthCommonCacheConfig;
import io.druid.security.basic.BasicAuthUtils; import io.druid.security.basic.BasicAuthUtils;
import io.druid.security.basic.authentication.BasicHTTPAuthenticator; import io.druid.security.basic.authentication.BasicHTTPAuthenticator;
@ -195,7 +195,7 @@ public class CoordinatorPollingBasicAuthenticatorCacheManager implements BasicAu
); );
} }
catch (Exception e) { catch (Exception e) {
LOG.makeAlert(e, "Encountered exception while fetching user map for authenticator [%s]", prefix); LOG.makeAlert(e, "Encountered exception while fetching user map for authenticator [%s]", prefix).emit();
if (isInit) { if (isInit) {
if (commonCacheConfig.getCacheDirectory() != null) { if (commonCacheConfig.getCacheDirectory() != null) {
try { try {
@ -204,7 +204,8 @@ public class CoordinatorPollingBasicAuthenticatorCacheManager implements BasicAu
} }
catch (Exception e2) { catch (Exception e2) {
e2.addSuppressed(e); e2.addSuppressed(e);
LOG.makeAlert(e2, "Encountered exception while loading user map snapshot for authenticator [%s]", prefix); LOG.makeAlert(e2, "Encountered exception while loading user map snapshot for authenticator [%s]", prefix)
.emit();
} }
} }
} }

View File

@ -24,8 +24,6 @@ import com.google.common.base.Preconditions;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Injector; import com.google.inject.Injector;
import io.druid.java.util.emitter.EmittingLogger;
import io.druid.java.util.http.client.Request;
import io.druid.client.coordinator.Coordinator; import io.druid.client.coordinator.Coordinator;
import io.druid.concurrent.LifecycleLock; import io.druid.concurrent.LifecycleLock;
import io.druid.discovery.DruidLeaderClient; import io.druid.discovery.DruidLeaderClient;
@ -38,6 +36,8 @@ import io.druid.java.util.common.concurrent.Execs;
import io.druid.java.util.common.concurrent.ScheduledExecutors; import io.druid.java.util.common.concurrent.ScheduledExecutors;
import io.druid.java.util.common.lifecycle.LifecycleStart; import io.druid.java.util.common.lifecycle.LifecycleStart;
import io.druid.java.util.common.lifecycle.LifecycleStop; import io.druid.java.util.common.lifecycle.LifecycleStop;
import io.druid.java.util.emitter.EmittingLogger;
import io.druid.java.util.http.client.Request;
import io.druid.security.basic.BasicAuthCommonCacheConfig; import io.druid.security.basic.BasicAuthCommonCacheConfig;
import io.druid.security.basic.BasicAuthUtils; import io.druid.security.basic.BasicAuthUtils;
import io.druid.security.basic.authentication.BytesFullResponseHandler; import io.druid.security.basic.authentication.BytesFullResponseHandler;
@ -228,7 +228,7 @@ public class CoordinatorPollingBasicAuthorizerCacheManager implements BasicAutho
); );
} }
catch (Exception e) { catch (Exception e) {
LOG.makeAlert(e, "Encountered exception while fetching user and role map for authorizer [%s]", prefix); LOG.makeAlert(e, "Encountered exception while fetching user and role map for authorizer [%s]", prefix).emit();
if (isInit) { if (isInit) {
if (commonCacheConfig.getCacheDirectory() != null) { if (commonCacheConfig.getCacheDirectory() != null) {
try { try {
@ -237,7 +237,8 @@ public class CoordinatorPollingBasicAuthorizerCacheManager implements BasicAutho
} }
catch (Exception e2) { catch (Exception e2) {
e2.addSuppressed(e); e2.addSuppressed(e);
LOG.makeAlert(e2, "Encountered exception while loading user-role map snapshot for authorizer [%s]", prefix); LOG.makeAlert(e2, "Encountered exception while loading user-role map snapshot for authorizer [%s]", prefix)
.emit();
} }
} }
} }