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

Listing app service certificates fails #670

Open nilscodes opened 5 years ago

nilscodes commented 5 years ago

I have the following code that tries to list existing app service certificates (3rd party) via the REST API:

Optional<AppServiceCertificate> existingAppCert = azure.appServices().certificates().list().stream().filter(c -> c.thumbprint().equalsIgnoreCase(MY_THUMBPRINT)).findFirst();

This code errors out because the REST API as documented here https://docs.microsoft.com/en-us/rest/api/appservice/certificates/list returns a plain list of certificates, while the list() call is expecting a PagedList<>.

As is, this API is not usable for me via the Java SDK :(

The exception is as follows:

Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of com.microsoft.azure.management.appservice.implementation.PageImpl out of START_ARRAY token at [Source: (String)"[]"; line: 1, column: 1] at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63) at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1342) at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1138) at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1092) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromArray(BeanDeserializerBase.java:1454) at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:185) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:161) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4001) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3030) at com.microsoft.rest.serializer.JacksonAdapter.deserialize(JacksonAdapter.java:131) at com.microsoft.rest.ServiceResponseBuilder.buildBody(ServiceResponseBuilder.java:216) at com.microsoft.rest.ServiceResponseBuilder.build(ServiceResponseBuilder.java:110) at com.microsoft.azure.AzureResponseBuilder.build(AzureResponseBuilder.java:56) at com.microsoft.azure.management.appservice.implementation.CertificatesInner.listDelegate(CertificatesInner.java:213) at com.microsoft.azure.management.appservice.implementation.CertificatesInner.access$000(CertificatesInner.java:48) at com.microsoft.azure.management.appservice.implementation.CertificatesInner$5.call(CertificatesInner.java:200) at com.microsoft.azure.management.appservice.implementation.CertificatesInner$5.call(CertificatesInner.java:196) at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69) 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.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) ... 7 more

praries880 commented 5 years ago

@npeuser The operation returns a (CertificateCollection)[https://docs.microsoft.com/en-us/rest/api/appservice/certificates/list#response]... which has a next page link...

The API is paginated. Fluent Java SDK API for listing certificates in turn returns a paged list.

What is the version of the SDK that you are using?

yungezz commented 4 years ago

hi @npeuser could you pls provide detail for questions above to help investigation? thanks