Skip to content

Change # of bits ValueWriter checks for BigDecimal #618

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

Merged
merged 4 commits into from
Jun 28, 2019

Conversation

changlinli
Copy link
Contributor

Proposed Changes

Fixes #617 by changing the number of bits from 32 to 31.

Types of Changes

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

Checklist

Put an x in the boxes that apply. You can also fill these out after creating
the PR. If you're unsure about any of them, don't hesitate to ask on the
mailing list. We're here to help! This is simply a reminder of what we are
going to look for before merging your code.

  • 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

Further Comments

I've included a test, but I can't actually run it because

make deps
./mvnw -Ddeps.dir=$(pwd)/deps verify -Dit.test=ValueWriterTest

blows up with

[INFO] --- maven-bundle-plugin:3.2.0:manifest (bundle-manifest) @ amqp-client ---
[INFO] 
[INFO] --- groovy-maven-plugin:2.0:execute (remove-old-test-keystores) @ amqp-client ---
[INFO] 
[INFO] --- groovy-maven-plugin:2.0:execute (query-test-tls-certs-dir) @ amqp-client ---
GEN    /tmp/rabbitmq-test-instances/tls-certs GEN    /tmp/rabbitmq-test-instances/tls-certs/testca/cacert.pemmake[1]: *** [Makefile:41: /tmp/rabbitmq-test-instances/tls-certs/testca/cacert.pem] Error 1make: *** [/home/changlin/Projects/rabbitmq-java-client/deps/rabbit_common/mk/rabbitmq-run.mk:238: /tmp/rabbitmq-test-instances/tls-certs] Error 2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.019 s
[INFO] Finished at: 2019-06-27T22:58:59-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.gmaven:groovy-maven-plugin:2.0:execute (query-test-tls-certs-dir) on project amqp-client: Execution query-test-tls-certs-dir of goal org.codehaus.gmaven:groovy-maven-plugin:2.0:execute failed: org.apache.maven.plugin.MojoExecutionException: Failed to query test TLS certs directory with command: make -C /home/changlin/Projects/rabbitmq-java-client/deps/rabbit --no-print-directory show-test-tls-certs-dir DEPS_DIR=/home/changlin/Projects/rabbitmq-java-client/deps -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Move from 32 to 31 because bitLength ignores the sign bit.
@pivotal-issuemaster
Copy link

@changlinli Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@changlinli changlinli changed the title Change # of bits ValueWriter checks for BigDecimal (Obvious Fix) Change # of bits ValueWriter checks for BigDecimal Jun 28, 2019
@pivotal-issuemaster
Copy link

@changlinli Thank you for signing the Contributor License Agreement!

The scale of a BigDecimal must also be checked because it must be a
signed octet
@changlinli changlinli changed the title (Obvious Fix) Change # of bits ValueWriter checks for BigDecimal Change # of bits ValueWriter checks for BigDecimal Jun 28, 2019
@changlinli
Copy link
Contributor Author

Oh and it looks like scale wasn't be checked either, which would cause a similar class of bugs.

They're not actually used at all during the test
@acogoluegnes acogoluegnes merged commit 8e790d3 into rabbitmq:master Jun 28, 2019
@acogoluegnes
Copy link
Contributor

@changlinli Thanks!

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.

ValueWriter.writeFieldValue allows BigDecimals that are too big to be written
4 participants