Skip to content

Fix warnings in ClientVersion when amqp-client is relocated #437

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

Conversation

astei
Copy link
Contributor

@astei astei commented Dec 26, 2018

Proposed Changes

This pull request fixes spurious warnings emitted by the com.rabbitmq.client.impl.ClientVersion class when amqp-client is relocated. This problem happens because the key com.rabbitmq.client.version is rewritten to use a different prefix by whatever produces the uberjar (maven-shade-plugin or Gradle Shadow, for instance), but the rabbitmq-amqp-client.properties key is not rewritten.

In order to prevent this rewriting, the property key is now stored in a char[] and we create a String from it. This is unusual, but required if we want to retain backwards-compatibility. Doing so allows us to defeat the rewriting done during relocation.

This behavior has been broken for a while: prior to bd1d73f, the version returned could be null.

This issue fixes #436.

While we're here, I also fixed a typo in the exception message thrown by getVersionFromPropertyFile().

Types of Changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

Checklist

  • I have read the CONTRIBUTING.md document
  • I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
  • All tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in related repositories

@michaelklishin
Copy link
Contributor

@astei may I ask you to clarify how instantiating a string from a character array addresses this? I’m afraid I haven’t used Gradle Shadow.

@astei
Copy link
Contributor Author

astei commented Dec 26, 2018

@michaelklishin A very good question to ask!

Gradle Shadow uses ASM for relocating classes. By default, ASM remaps just Class<?> and Handle. Gradle Shadow adds mappings for String.

Obviously, char[] is not remapped in either case, so we can use it to avoid this mapping step.

@acogoluegnes acogoluegnes merged commit dd53240 into rabbitmq:master Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spurious warnings emitted by ClientVersion when the library is relocated
3 participants