Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] getByResourceGroup throws an NPE when the resource is a Gallery, GalleryImage or GalleryImageVersion #15097

Closed
3 tasks done
Shanky2304 opened this issue Sep 11, 2020 · 4 comments · Fixed by Azure/azure-libraries-for-java#1280
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Compute customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@Shanky2304
Copy link

Shanky2304 commented Sep 11, 2020

Describe the bug
getByResourceGroup throws an NPE when the resource is a Gallery, GalleryImage or GalleryImageVersion which it shouldn't. I am just using this function to check whether the resource exists.

Exception or Stack Trace
java.lang.NullPointerException: null
at com.microsoft.azure.management.compute.implementation.GalleryImageImpl.(GalleryImageImpl.java:56)
at com.microsoft.azure.management.compute.implementation.GalleryImagesImpl.wrapModel(GalleryImagesImpl.java:42)
at com.microsoft.azure.management.compute.implementation.GalleryImagesImpl.access$000(GalleryImagesImpl.java:24)
at com.microsoft.azure.management.compute.implementation.GalleryImagesImpl$4.call(GalleryImagesImpl.java:84)
at com.microsoft.azure.management.compute.implementation.GalleryImagesImpl$4.call(GalleryImagesImpl.java:81)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:77)
at rx.internal.operators.OperatorMerge$MergeSubscriber.emitScalar(OperatorMerge.java:511)
at rx.internal.operators.OperatorMerge$MergeSubscriber.tryEmit(OperatorMerge.java:466)
at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:244)
at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:148)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:77)
at retrofit2.adapter.rxjava.CallArbiter.deliverResponse(CallArbiter.java:120)
at retrofit2.adapter.rxjava.CallArbiter.emitResponse(CallArbiter.java:102)
at retrofit2.adapter.rxjava.CallExecuteOnSubscribe.call(CallExecuteOnSubscribe.java:46)
at retrofit2.adapter.rxjava.CallExecuteOnSubscribe.call(CallExecuteOnSubscribe.java:24)
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.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.unsafeSubscribe(Observable.java:10327)
at rx.internal.operators.DeferredScalarSubscriber.subscribeTo(DeferredScalarSubscriber.java:153)
at rx.internal.operators.OnSubscribeTakeLastOne.call(OnSubscribeTakeLastOne.java:32)
at rx.internal.operators.OnSubscribeTakeLastOne.call(OnSubscribeTakeLastOne.java:22)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
at rx.Observable.subscribe(Observable.java:10423)
at rx.Observable.subscribe(Observable.java:10390)
at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:443)
at rx.observables.BlockingObservable.last(BlockingObservable.java:226)
at com.microsoft.azure.management.compute.implementation.GalleryImagesImpl.getByGallery(GalleryImagesImpl.java:91)
at com.some.package.AzureClient.getGalleryImage(MyAzureClient.java:348)

To Reproduce
Just use the below code and ensure the gallery doesn't exist:

azure.galleries().getByResourceGroup(targetRg, galleryName);

Code Snippet
Added above.

Expected behavior
It should return null and let the consumer work with it how it does for other resource types.
For e.g. when I do the same for a public IP address, the below code will print null.

PublicIPAddress pubIp = azure.publicIPAddresses().getByResourceGroup(targetRg, "tempPip");
System.out.println("Public IP:" + pubIp);

Screenshots
N/A

Setup (please complete the following information):

  • OS: iOS
  • IDE : IntelliJ
  • 1.36

Additional Context
Btw the below code works just fine if I supply the resourceId of a Gallery or GalleryImage and prints null but isn't an ideal workaround if I want to only work with the resource group name and the resource name.

GenericResource genericResource = azure.genericResources().getById(sigResourceId);
System.out.println("Some resource:" + genericResource);

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

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
@ghost ghost added needs-triage This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 11, 2020
@joshfree joshfree added bug This issue requires a change to an existing behavior in the product in order to be resolved. Compute Mgmt This issue is related to a management-plane library. labels Sep 11, 2020
@ghost ghost removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Sep 11, 2020
@joshfree
Copy link
Member

Thanks for reporting this issue. Someone from the Mgmt plane SDK team will follow up shortly.

/cc @yungezz

@xseeseesee
Copy link
Contributor

@Shanky2304 Thanks for reporting this. I have created PR to fix this. Before it got released, you may try below code:

azure.galleries().inner().getByResourceGroup(targetRg, galleryName);

@knspatavardhan
Copy link

@Shanky2304 Thanks for reporting this. I have created PR to fix this. Before it got released, you may try below code:

azure.galleries().inner().getByResourceGroup(targetRg, galleryName);

Hi @xccc-msft ,
I see that your fix includes changes to GalleryImagesImpl and GalleryImageVersionsImpl, should this suggested change be applied when fetching GalleryImage and GalleryImageVersion as well?

@xseeseesee
Copy link
Contributor

@knspatavardhan yes

openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-java that referenced this issue Jul 13, 2021
[Hub Generated] Review request for Microsoft.Media to add version stable/2021-06-01- Part 2 (Azure#15097)

* Copy 2020-05-01 version of the encoding swagger.

* Update encoder swagger to 2021-06-01 version.

* fix 404 response on Encoding swagger

* fixed a description and removed 404 reponses from examples.

* update example files.
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Compute customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants