Java API for ServiceBusAdministrationClient's method getTopicRuntimeProperties throws Exception when SizeInBytes excceds java Integer max

Gupta, Rajesh 81 Reputation points
2021-04-29T23:26:59.27+00:00

I am using the following Azure Service Bus Java client library:

<dependency>
        <groupId>com.azure</groupId>
        <artifactId>azure-messaging-servicebus</artifactId>
        <version>7.2.0</version>
</dependency>

When using getTopicRuntimeProperties with an instance of ServiceBusAdministrationClient, I get an exception when SizeInBytes excceds java Integer max. Can someone suggest a solution to this?

The exception is:

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Numeric value (null) out of range of int
at [Source: (StringReader); line: 1, column: 978] (through reference chain: com.azure.messaging.servicebus.implementation.models.TopicDescriptionEntry["content"]->com.azure.messaging.servicebus.implementation.models.TopicDescriptionEntryContent["TopicDescription"]->com.azure.messaging.servicebus.implementation.models.TopicDescription["SizeInBytes"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:390)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:349)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1822)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:326)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:187)
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:324)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:187)
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:324)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:187)
at com.fasterxml.jackson.dataformat.xml.deser.XmlDeserializationContext.readRootValue(XmlDeserializationContext.java:91)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4593)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3548)
at com.azure.core.util.serializer.JacksonAdapter.deserialize(JacksonAdapter.java:267)
at com.azure.messaging.servicebus.implementation.ServiceBusManagementSerializer.deserialize(ServiceBusManagementSerializer.java:101)
at com.azure.messaging.servicebus.administration.ServiceBusAdministrationAsyncClient.deserialize(ServiceBusAdministrationAsyncClient.java:2192)
... 101 more
Caused by: com.fasterxml.jackson.core.JsonParseException: Numeric value (null) out of range of int
at [Source: (StringReader); line: 1, column: 978]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:2337)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:710)
at com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser._convertNumberToInt(FromXmlParser.java:1216)
at com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser.getIntValue(FromXmlParser.java:1119)
at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$IntegerDeserializer.deserialize(NumberDeserializers.java:526)
at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$IntegerDeserializer.deserialize(NumberDeserializers.java:506)
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:324)
... 114 more

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
594 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Gupta, Rajesh 81 Reputation points
    2021-05-03T21:32:07.847+00:00

    @Pramod Valavala I locally modified the following two classes to change int to long (Integer to Long) and recompiled azure-messaging-servicebus 7.3.0-beta.2 (https://github.com/Azure/azure-sdk-for-java):

    servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/administration/models/TopicProperties.java
    servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/implementation/models/TopicDescription.java

    This change worked and I am able to get the correct value of SizeInBytes.

    It would be great if this change can be incorporated into the next release of azure-messaging-servicebus.

    1 person found this answer helpful.
    0 comments No comments

  2. Pramod Valavala 20,611 Reputation points Microsoft Employee
    2021-05-03T17:13:39.643+00:00

    @Gupta, Rajesh After a quick look, the problem seems to be with the TopicProperties class (here) and not the TopicRuntimeProperties class itself. The underlying ARM REST API can be used as a workaround to fetch as a generic resource.