Azure / azure-libraries-for-java

Azure Management Libraries for Java
https://docs.microsoft.com/en-us/java/azure/
MIT License
94 stars 98 forks source link

[BUG] NPE from virtualMachineScaleSets().list() #1229

Closed daveagill closed 4 years ago

daveagill commented 4 years ago

Describe the bug Invoking virtualMachineScaleSets().list() throws a NullPointerException

Exception or Stack Trace

java.lang.NullPointerException
    at com.microsoft.azure.management.compute.implementation.VirtualMachineScaleSetImpl.initializeChildrenFromInner(VirtualMachineScaleSetImpl.java:195)
    at com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableParentResourceImpl.<init>(GroupableParentResourceImpl.java:40)
    at com.microsoft.azure.management.compute.implementation.VirtualMachineScaleSetImpl.<init>(VirtualMachineScaleSetImpl.java:175)
    at com.microsoft.azure.management.compute.implementation.VirtualMachineScaleSetsImpl.wrapModel(VirtualMachineScaleSetsImpl.java:235)
    at com.microsoft.azure.management.compute.implementation.VirtualMachineScaleSetsImpl.wrapModel(VirtualMachineScaleSetsImpl.java:37)
    at com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl$1.typeConvertAsync(ReadableWrappersImpl.java:35)
    at com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter$4.call(PagedListConverter.java:91)
    at com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter$4.call(PagedListConverter.java:88)
    at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69)
    at rx.internal.operators.OnSubscribeFilter$FilterSubscriber.onNext(OnSubscribeFilter.java:76)
    at rx.internal.operators.OnSubscribeFromIterable$IterableProducer.fastPath(OnSubscribeFromIterable.java:173)
    at rx.internal.operators.OnSubscribeFromIterable$IterableProducer.request(OnSubscribeFromIterable.java:86)
    at rx.Subscriber.setProducer(Subscriber.java:211)
    at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
    at rx.internal.operators.OnSubscribeFilter$FilterSubscriber.setProducer(OnSubscribeFilter.java:104)
    at rx.internal.operators.OnSubscribeFromIterable.call(OnSubscribeFromIterable.java:63)
    at rx.internal.operators.OnSubscribeFromIterable.call(OnSubscribeFromIterable.java:34)
    at rx.Observable.unsafeSubscribe(Observable.java:10327)
    at rx.internal.operators.OnSubscribeFilter.call(OnSubscribeFilter.java:45)
    at rx.internal.operators.OnSubscribeFilter.call(OnSubscribeFilter.java:30)
    at rx.Observable.unsafeSubscribe(Observable.java:10327)
    at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48)
    at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
    at rx.Observable.unsafeSubscribe(Observable.java:10327)
    at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48)
    at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33)
    at rx.Observable.subscribe(Observable.java:10423)
    at rx.Observable.subscribe(Observable.java:10390)
    at rx.observables.BlockingObservable.subscribe(BlockingObservable.java:477)
    at com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter.loadConvertedList(PagedListConverter.java:100)
    at com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter.convert(PagedListConverter.java:66)
    at com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ReadableWrappersImpl.wrapList(ReadableWrappersImpl.java:43)
    at com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.TopLevelModifiableResourcesImpl.list(TopLevelModifiableResourcesImpl.java:118)

To Reproduce Simply making the call triggered the NPE. It definitely does not happen in every subscription and is (as yet) unclear if this is a transient or permanent issue in the subscription where this was encountered.

Code Snippet

Azure azure = Azure.configure().authenticate(azureTokCreds).withSubscription(subID);
azure.virtualMachineScaleSets().list();

Expected behavior To not throw.

Screenshots N/A

Setup (please complete the following information):

Additional context No additional info known at this time.

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

yungezz commented 4 years ago

hi @xccc-msft could you pls have a look? thanks

xseeseesee commented 4 years ago

@daveagill Can you try to capture the request/response and check if any properties.virtualMachineProfile inside the vmss is empty there? Thanks.

daveagill commented 4 years ago

@daveagill Can you try to capture the request/response and check if any properties.virtualMachineProfile inside the vmss is empty there? Thanks.

Yes I will try to get that. If that was the issue is there any workaround we could do in the short-term to mitigate? Maybe filter them out from someplace?

xseeseesee commented 4 years ago

@daveagill You may try below code instead. azure.virtualMachineScaleSets().inner().list()

daveagill commented 4 years ago

An update on this: This exception was reported to us by a customer and we have not been able to reproduce it ourselves. We have since put the workaround suggested by @xccc-msft into production and not had any issues reported to us.

All I can suggest is to add a defensive handling of null vmprofiles if that's likely to be the culprit?

xseeseesee commented 4 years ago

@daveagill Thanks for the suggestion! Please feel free to reopen if you got any issues again.