Skip to content

Commit

Permalink
Merge pull request #1369 from RostakaGmfun/KAA-1650
Browse files Browse the repository at this point in the history
KAA-1650: Don't set the body present flag in extension options if body size is equal to zero
  • Loading branch information
rasendubi authored Dec 9, 2016
2 parents 59d45da + 849bacb commit 7ab238e
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,14 @@ private void encode(GrowingByteBuffer buf, LogServerSync logSync) {

private void encode(GrowingByteBuffer buf, ConfigurationServerSync configurationSync) {
int option = 0;
boolean confSchemaPresent = configurationSync.getConfSchemaBody() != null;
boolean confBodyPresent = configurationSync.getConfDeltaBody() != null;
ByteBuffer confSchemaBody = configurationSync.getConfSchemaBody();
ByteBuffer confDeltaBody = configurationSync.getConfDeltaBody();
boolean confSchemaPresent = confSchemaBody != null
&& confSchemaBody.hasArray()
&& confSchemaBody.array().length != 0;
boolean confBodyPresent = confDeltaBody != null
&& confDeltaBody.hasArray()
&& confDeltaBody.array().length != 0;
if (confSchemaPresent) {
option |= 0x01;
}
Expand All @@ -435,16 +441,16 @@ private void encode(GrowingByteBuffer buf, ConfigurationServerSync configuration
final int extPosition = buf.position();

if (confSchemaPresent) {
buf.putInt(configurationSync.getConfSchemaBody().array().length);
buf.putInt(confSchemaBody.array().length);
}
if (confBodyPresent) {
buf.putInt(configurationSync.getConfDeltaBody().array().length);
buf.putInt(confDeltaBody.array().length);
}
if (confSchemaPresent) {
put(buf, configurationSync.getConfSchemaBody().array());
put(buf, confSchemaBody.array());
}
if (confBodyPresent) {
put(buf, configurationSync.getConfDeltaBody().array());
put(buf, confDeltaBody.array());
}

buf.putInt(extPosition - SIZE_OF_INT, buf.position() - extPosition);
Expand Down

0 comments on commit 7ab238e

Please sign in to comment.