Azure / azure-service-bus-java

☁️ Java client library for Azure Service Bus
https://azure.microsoft.com/services/service-bus
MIT License
60 stars 59 forks source link

Azure service bus jar changing default Spring Boot behavior #416

Open RobOhRob opened 3 years ago

RobOhRob commented 3 years ago

I am currently using Spring Boot version 2.1.3.RELEASE with version 7.1.0 of Azure service bus.

implementation group: 'com.azure', name: 'azure-messaging-servicebus', version: '7.1.0' Simply adding the line above to my build.gradle script alters default Spring Boot behavior. Hitting a GET endpoint without any Accept header specified is returning XML instead of JSON and creating a RestTemplate now has a bunch of different Accept types. This is causing existing legacy code to break. It appears to be an issue with all versions of azure-messaging-servicebus after it was moved to the new package.

It appears that the issue is the jackson-dataformat-xml package that comes along with the jar. Excluding this package from the build returns to normal behavior. I am not sure if this is an issue with how you guys are packaging the library or if it is an issue with Spring just automatically consuming it.

Actual Behavior

  1. Hitting a GET endpoint with no Accept type specified defaults to application/xml being returned
  2. Creating a new RestTemplate() defaults the Accept types in the template to [application/xml, text/xml, application/json, application/+xml, application/+json]

Expected Behavior

  1. Hitting a GET endpoint with no Accept type specified defaults to application/json being returned
  2. Creating a new RestTemplate() defaults the Accept types in the template to [application/json, application/*+json]

Versions

KnyGoo commented 2 years ago

Experiencing the same issues...

MappingJackson2XmlHttpMessageConverter is added to our resttemplate after including Azure Service Bus library...This is because Spring will add it to resttemplate when there exists an XmlMapper.class...

edwinjames07 commented 2 years ago

Issue still exists in the latest version(7.8.0)

@KnyGoo @RobOhRob Have you got any solution for this?

RobOhRob commented 2 years ago

Issue still exists in the latest version(7.8.0)

@KnyGoo @RobOhRob Have you got any solution for this?

Exclude the jackson-dataformat-xml package from the service bus package in the gradle or pom

dhyanivikas commented 2 years ago

@RobOhRob What do you specifically mean when you mention "Exclude the jackson-dataformat-xml package from the service bus package in the gradle or pom" ? We have included only following in our gradle: implementation group: 'com.azure', name: 'azure-messaging-servicebus', version: '7.1.0' There's no specific dependency mentioned for jackson-dataformat-xml

conniey commented 2 years ago

Hey.

azure-messaging-servicebus depends on azure-core, which has a dependency on jackson-dataformat-xml (https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core/pom.xml#L114-L118).

The endpoints used by ServiceBusAdministrationClient and ServiceBusAdministrationAsyncClient return/consume XML. However, if you are not going to use those clients, you can exclude jackson-dataformat-xml.

conniey commented 2 years ago

I moved the bug to our repository. This repo references our legacy library.

dhyanivikas commented 2 years ago

We have already tried the exclusion option in following two ways:

compile (group: 'com.azure', name: 'azure-core', version: '1.18.0') { exclude group: 'com.fasterxml.jackson.dataformat', module: 'jackson-dataformat-xml' } And configurations.implementation { exclude group: 'com.fasterxml.jackson.dataformat', module: 'jackson-dataformat-xml' }

And then the application fails at the receiver startup.

ki1729 commented 2 years ago

@RobOhRob, @dhyanivikas : the problematic jackson xml library has been made an optional dependency. This should fix the issue. Please let us know if that is not the case.

lemontagnolli commented 1 year ago

i had the same problem. Thanks. These comments helped me