Skip to content

Commit

Permalink
KAA-1650: Don't set the body present flag in extension options if bod…
Browse files Browse the repository at this point in the history
…y size is equal to zero
  • Loading branch information
RostakaGmfun committed Dec 8, 2016
1 parent c869ebc commit 849bacb
Showing 1 changed file with 12 additions and 6 deletions.
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 849bacb

Please sign in to comment.