Skip to content

Commit 9fb1e5d

Browse files
committed
IGNITE-26863 Fixed broken Binary Object size calculation for enum objects
1 parent 3455af6 commit 9fb1e5d

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,7 @@ private <T> T uncachedValue(Class<?> cls) throws BinaryObjectException {
323323

324324
/** {@inheritDoc} */
325325
@Override public byte[] valueBytes(CacheObjectValueContext cacheCtx) throws IgniteCheckedException {
326-
if (valBytes != null)
327-
return valBytes;
328-
329-
valBytes = Marshallers.marshal(ctx.marshaller(), this);
330-
331-
return valBytes;
326+
return valueBytes();
332327
}
333328

334329
/** {@inheritDoc} */
@@ -382,15 +377,21 @@ private <T> T uncachedValue(Class<?> cls) throws BinaryObjectException {
382377

383378
/** {@inheritDoc} */
384379
@Override public int size() {
385-
if (valBytes == null) {
386-
try {
387-
valBytes = Marshallers.marshal(ctx.marshaller(), this);
388-
}
389-
catch (IgniteCheckedException e) {
390-
throw CommonUtils.convertException(e);
391-
}
380+
try {
381+
return valueBytes().length;
382+
}
383+
catch (IgniteCheckedException e) {
384+
throw CommonUtils.convertException(e);
392385
}
386+
}
387+
388+
/** */
389+
private byte[] valueBytes() throws IgniteCheckedException {
390+
if (valBytes != null)
391+
return valBytes;
392+
393+
valBytes = Marshallers.marshal(ctx.marshaller(), this);
393394

394-
return BinaryPrimitives.readInt(valBytes, ord + GridBinaryMarshaller.TOTAL_LEN_POS);
395+
return valBytes;
395396
}
396397
}

0 commit comments

Comments
 (0)