This is an automated email from the ASF dual-hosted git repository.
mpetrov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new a4312940737 IGNITE-26863 Fixed broken Binary Object size calculation
for enum objects (#12482)
a4312940737 is described below
commit a4312940737d1da9a1e6755e146c0869d95c3358
Author: Mikhail Petrov <[email protected]>
AuthorDate: Sat Nov 1 18:07:55 2025 +0300
IGNITE-26863 Fixed broken Binary Object size calculation for enum objects
(#12482)
---
.../internal/binary/BinaryEnumObjectImpl.java | 29 +++++++++++-----------
.../internal/binary/BinaryEnumsSelfTest.java | 5 ++--
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git
a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
index 08e928b1955..813ff1ca112 100644
---
a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
+++
b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
@@ -323,12 +323,7 @@ class BinaryEnumObjectImpl implements BinaryObjectEx,
Externalizable, CacheObjec
/** {@inheritDoc} */
@Override public byte[] valueBytes(CacheObjectValueContext cacheCtx)
throws IgniteCheckedException {
- if (valBytes != null)
- return valBytes;
-
- valBytes = Marshallers.marshal(ctx.marshaller(), this);
-
- return valBytes;
+ return valueBytes();
}
/** {@inheritDoc} */
@@ -382,15 +377,21 @@ class BinaryEnumObjectImpl implements BinaryObjectEx,
Externalizable, CacheObjec
/** {@inheritDoc} */
@Override public int size() {
- if (valBytes == null) {
- try {
- valBytes = Marshallers.marshal(ctx.marshaller(), this);
- }
- catch (IgniteCheckedException e) {
- throw CommonUtils.convertException(e);
- }
+ try {
+ return valueBytes().length;
+ }
+ catch (IgniteCheckedException e) {
+ throw CommonUtils.convertException(e);
}
+ }
+
+ /** */
+ private byte[] valueBytes() throws IgniteCheckedException {
+ if (valBytes != null)
+ return valBytes;
+
+ valBytes = Marshallers.marshal(ctx.marshaller(), this);
- return BinaryPrimitives.readInt(valBytes, ord +
GridBinaryMarshaller.TOTAL_LEN_POS);
+ return valBytes;
}
}
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java
index b9586800998..ac51add9596 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java
@@ -32,7 +32,6 @@ import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.IgniteKernal;
import
org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.marshaller.Marshaller;
@@ -227,8 +226,7 @@ public class BinaryEnumsSelfTest extends
AbstractBinaryArraysTest {
public void testInstanceFromBytes() throws Exception {
startUp(true);
- BinaryContext binCtx =
-
((CacheObjectBinaryProcessorImpl)((IgniteKernal)node1).context().cacheObjects()).binaryContext();
+ BinaryContext binCtx =
((IgniteEx)node1).context().cacheObjects().binaryContext();
int ord = EnumType.ONE.ordinal();
@@ -256,6 +254,7 @@ public class BinaryEnumsSelfTest extends
AbstractBinaryArraysTest {
BinaryEnumObjectImpl binEnum = new BinaryEnumObjectImpl(binCtx, bytes);
+ assertEquals(bytes.length, srcBinEnum.size());
assertEquals(srcBinEnum.size(), binEnum.size());
assertEquals(clsName, binEnum.enumClassName());
assertEquals(typeId, binEnum.typeId());