-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe the bug
Running com.azure.resourcemanager.eventhubs.EventHubTests#canManageGeoDisasterRecoveryPairing throws a NullPointerException. The stack trace shows the exception happens when creating DisasterRecoveryPairingAuthorizationRuleImpl, specifically inside Ancestors.TwoAncestor constructor, which suggests one of the ancestor parameters is null.
Exception stack trace
java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:233)
at com.azure.resourcemanager.eventhubs.implementation.Ancestors$TwoAncestor.<init>(Ancestors.java:52)
at com.azure.resourcemanager.eventhubs.implementation.Ancestors$TwoAncestor.<init>(Ancestors.java:58)
at com.azure.resourcemanager.eventhubs.implementation.DisasterRecoveryPairingAuthorizationRuleImpl.<init>(DisasterRecoveryPairingAuthorizationRuleImpl.java:29)
at com.azure.resourcemanager.eventhubs.implementation.DisasterRecoveryPairingAuthorizationRulesImpl.wrapModel(DisasterRecoveryPairingAuthorizationRulesImpl.java:83)
at com.azure.resourcemanager.resources.fluentcore.utils.PagedConverter$IteratorImpl.next(PagedConverter.java:255)
at com.azure.resourcemanager.test.utils.TestUtilities.getSize(TestUtilities.java:58)
at com.azure.resourcemanager.eventhubs.EventHubTests.canManageGeoDisasterRecoveryPairing(EventHubTests.java:533)
...
Code location
Test class: com/azure/resourcemanager/eventhubs/EventHubTests.java
Failing test: canManageGeoDisasterRecoveryPairing
In the test, the failure happens when iterating pairing.listAuthorizationRules():
PagedIterable<DisasterRecoveryPairingAuthorizationRule> rules = pairing.listAuthorizationRules();
Assertions.assertTrue(TestUtilities.getSize(rules) > 0);
for (DisasterRecoveryPairingAuthorizationRule rule : rules) {
DisasterRecoveryPairingAuthorizationKey keys = rule.getKeys();
...
}The NPE is thrown during TestUtilities.getSize(rules) when the first item is materialized.
Suspected cause
DisasterRecoveryPairingAuthorizationRulesImpl.wrapModel constructs a DisasterRecoveryPairingAuthorizationRuleImpl using ancestor information extracted from the inner model or parent context. One of the values passed into Ancestors.TwoAncestor is null, causing Objects.requireNonNull(...) to throw NullPointerException.
Most likely:
resourceGroupNameornamespaceNameis not correctly derived fromDisasterRecoveryPairingAuthorizationRuleInneror the pairing context, or- the parsing logic for
inner.id()/parent ID does not match the actual Event Hubs Geo-DR authorization rule resource ID format.
Expected behavior
pairing.listAuthorizationRules() should not throw NullPointerException during wrapModel. It should return an iterable (possibly empty) or, if required data is missing, fail with a clearer, validated error instead of a null ancestor.
To Reproduce
-
Create two Event Hubs namespaces (primary and secondary) and enable Geo-DR:
EventHubNamespace primaryNamespace = eventHubsManager.namespaces() .define(primaryName) .withRegion(Region.US_SOUTH_CENTRAL) .withNewResourceGroup(rgName) .disableLocalAuth() .create(); EventHubNamespace secondaryNamespace = eventHubsManager.namespaces() .define(secondaryName) .withRegion(Region.US_NORTH_CENTRAL) .withExistingResourceGroup(rgName) .disableLocalAuth() .create(); EventHubDisasterRecoveryPairing pairing = eventHubsManager.eventHubDisasterRecoveryPairings() .define(geodrName) .withExistingPrimaryNamespace(primaryNamespace) .withExistingSecondaryNamespace(secondaryNamespace) .create();
-
Poll until the pairing reaches
ProvisioningStateDR.SUCCEEDED. -
Call:
PagedIterable<DisasterRecoveryPairingAuthorizationRule> rules = pairing.listAuthorizationRules(); TestUtilities.getSize(rules); // NPE here