From 58142d5e5ccbf259fa25e07bccb237b0545a8921 Mon Sep 17 00:00:00 2001 From: Connie Yau Date: Wed, 14 Aug 2019 15:10:32 -0700 Subject: [PATCH] Add null check to fix spotbugs warning. (#4998) --- .../java/com/azure/messaging/eventhubs/ConsumeEvent.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/ConsumeEvent.java b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/ConsumeEvent.java index 89f7b0f632578..2f33f372ba321 100644 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/ConsumeEvent.java +++ b/sdk/eventhubs/azure-messaging-eventhubs/src/samples/java/com/azure/messaging/eventhubs/ConsumeEvent.java @@ -51,6 +51,11 @@ public static void main(String[] args) throws InterruptedException, IOException // TimeoutException is thrown. String firstPartition = client.getPartitionIds().blockFirst(OPERATION_TIMEOUT); + // This shouldn't happen, but if we are unable to get the partitions within the timeout period. + if (firstPartition == null) { + firstPartition = "0"; + } + // Create a consumer. // The "$Default" consumer group is created by default. This value can be found by going to the Event Hub // instance you are connecting to, and selecting the "Consumer groups" page. EventPosition.latest() tells the