DBZ-713 Extracting constaint for expected exception message

This commit is contained in:
Gunnar Morling 2018-07-03 13:40:45 +02:00 committed by Jiri Pechanec
parent c5f9d99644
commit e1cf34dc43

View File

@ -86,6 +86,9 @@
public class Replicator {
private final Logger logger = LoggerFactory.getLogger(getClass());
private static final String AUTHORIZATION_FAILURE_MESSAGE = "Command failed with error 13";
private final MongoDbTaskContext context;
private final ExecutorService copyThreads;
private final ReplicaSet replicaSet;
@ -168,7 +171,7 @@ protected boolean establishConnectionToPrimary() {
context.filters(),
(desc, error) -> {
// propagate authorization failures
if (error.getMessage() != null && error.getMessage().startsWith("Command failed with error 13")) {
if (error.getMessage() != null && error.getMessage().startsWith(AUTHORIZATION_FAILURE_MESSAGE)) {
throw new ConnectException("Error while attempting to " + desc, error);
}
else {