From bc39915aa9a5efc71298f0b481cacf6f1bb078d3 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Fri, 14 Apr 2017 12:48:59 -0700 Subject: [PATCH] Catch null error in key vault --- .../management/keyvault/implementation/VaultImpl.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultImpl.java b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultImpl.java index cc7be998d79e9..b34f5c59d5292 100644 --- a/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultImpl.java +++ b/azure-mgmt-keyvault/src/main/java/com/microsoft/azure/management/keyvault/implementation/VaultImpl.java @@ -6,6 +6,7 @@ package com.microsoft.azure.management.keyvault.implementation; +import com.microsoft.azure.CloudException; import com.microsoft.azure.management.apigeneration.LangDefinition; import com.microsoft.azure.management.graphrbac.ServicePrincipal; import com.microsoft.azure.management.graphrbac.User; @@ -206,6 +207,10 @@ private Observable> populateAccessPolicies() { .doOnNext(new Action1() { @Override public void call(User user) { + if (user == null) { + throw new CloudException(String.format("User principal name %s is not found in tenant %s", + accessPolicy.userPrincipalName(), graphRbacManager.tenantId()), null); + } accessPolicy.forObjectId(user.objectId()); } })); @@ -215,6 +220,10 @@ public void call(User user) { .doOnNext(new Action1() { @Override public void call(ServicePrincipal sp) { + if (sp == null) { + throw new CloudException(String.format("User principal name %s is not found in tenant %s", + accessPolicy.userPrincipalName(), graphRbacManager.tenantId()), null); + } accessPolicy.forObjectId(sp.objectId()); } }));