Commit 18344477 authored by Andre Freyssinet's avatar Andre Freyssinet
Browse files

Fixes a potential bug in encoding: removes useless boolean in encode.

parent b8049ffb
......@@ -309,15 +309,13 @@ public class Notification implements Serializable, Cloneable, Encodable {
*/
@Override
public int getEncodedSize() throws Exception {
int encodedSize = 0;
encodedSize += BYTE_ENCODED_SIZE;
int encodedSize = BYTE_ENCODED_SIZE;
if (expiration > 0)
encodedSize += LONG_ENCODED_SIZE;
if (context != null) {
if (context instanceof Encodable) {
Encodable encodable = (Encodable) context;
encodedSize += INT_ENCODED_SIZE;
encodedSize += encodable.getEncodedSize();
encodedSize += ((Encodable) context).getEncodedSize();
} else {
throw new Exception("Context is not Encodable");
}
......@@ -344,7 +342,6 @@ public class Notification implements Serializable, Cloneable, Encodable {
encoder.encodeUnsignedLong(expiration);
if (context != null) {
if (context instanceof Encodable) {
encoder.encodeBoolean(true);
Encodable encodable = (Encodable) context;
encoder.encodeUnsignedInt(encodable.getEncodableClassId());
encodable.encode(encoder);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment