Bug #2360

Long types are not serialized correctly.

Added by B. Errouane over 8 years ago. Updated almost 8 years ago.

Status:ResolvedStart date:08/13/2015
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:Java
Target version:rsb-0.14

Description

A bug in the LongConverter.java file causes variables of type Long to be serialized and thereby be transmitted incorrectly.

The error is in this code snipped:

[...] (MASK << (i * BYTE_LENGTH)) [...]

Because MASK is of type int, the shift can cause unwanted results.

A quick fix could be to change MASK to type long, but the proposed solution in the patch file additionally reduces the number of operations and shortens the line of code.

longConverter.patch Magnifier (947 Bytes) B. Errouane, 08/13/2015 07:54 PM

longConverterWithTest.patch Magnifier - Patch for the LongConverter and the LongConverterTest (1.6 KB) B. Errouane, 08/17/2015 12:40 PM

Associated revisions

Revision a4ca315e
Added by J. Moringen about 8 years ago

Fixed LongConverter in rsb-java/src/main/java/rsb/converter/LongConverter.java

fixes #2360

  • rsb-java/src/main/java/rsb/converter/LongConverter.java
    (LongConverter::serialize): handle large value correctly
  • rsb-java/src/test/java/rsb/converter/LongConverterTest.java
    (LongConverterTest::roundtripLargeValue): test 6172840431323434035L in
    addition to 130236144L

Reported-by: Benjamin Errouane <>
Patch-by: Benjamin Errouane <>

History

#1 Updated by J. Moringen over 8 years ago

  • Status changed from New to In Progress
  • Target version set to rsb-0.13

Thanks for the patch. Please extend it such that the unit tests fail without the correction.

#2 Updated by B. Errouane over 8 years ago

Added the test changes to the patch.

#3 Updated by J. Moringen about 8 years ago

  • Target version changed from rsb-0.13 to rsb-0.14

#4 Updated by J. Moringen almost 8 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF