#153 SerializationUtils.readLong - wrong results

v2.5.1
closed-fixed
Node (41)
5
2011-07-22
2011-07-10
No

NODE: org.jppf.utils.SerializationUtils

254: public static long readLong(byte[] data, int offset)
289: public static long readLong(InputStream is) throws IOException

- long result = convertByte(data[pos++]) << 56;
- result += convertByte(data[pos++]) << 48;

add explicit type conversion to long

+ long result = (long)convertByte(data[pos++]) << 56;
+ result += (long)convertByte(data[pos++]) << 48;

convertByte optimization:

private static int convertByte\(int b\)
\{
    return b &lt; 0 ? b + 256 : b;
\}

OPTIMIZED
private static int convertByte(int b)
{
return b & 0xFF;
}

Discussion

  • Laurent Cohen

    Laurent Cohen - 2011-07-21
    • assigned_to: nobody --> lolocohen
     
  • Laurent Cohen

    Laurent Cohen - 2011-07-22
    • milestone: --> v2.5.1
    • status: open --> closed-fixed
     
  • Laurent Cohen

    Laurent Cohen - 2011-07-22

    Fixed. I also got read of this stupid method convertByte() while I was at it.
    Changes committed to SVN:
    trunk: revision 1740
    branch b2.5: revision 1741

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks