Check if leader election is complete during tests

This commit is contained in:
Marius Bogoevici
2015-10-22 15:03:43 -04:00
committed by Artem Bilan
parent 108197cffd
commit 9ddc4e6d12

View File

@@ -19,6 +19,7 @@ package org.springframework.integration.kafka.util;
import java.util.List;
import java.util.Properties;
import kafka.common.LeaderNotAvailableException;
import org.I0Itec.zkclient.ZkClient;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -142,6 +143,9 @@ public class TopicUtils {
if (partitionMetadata.errorCode() != ErrorMapping.NoError()) {
throw (Exception) ErrorMapping.exceptionFor(partitionMetadata.errorCode());
}
if (partitionMetadata.leader() == null) {
throw new LeaderNotAvailableException();
}
}
return topicMetadata;
}