From b00a97700c70abf0d64470e27c28872a84a59fe8 Mon Sep 17 00:00:00 2001 From: Nikolay Izhikov Date: Mon, 24 Nov 2025 20:10:34 +0300 Subject: [PATCH 1/3] IGNITE-26860 Add configOnly flag to dump --- .../jmh/binary/JmhMapSerdesBenchmark.java | 193 ++++++++++++++++++ .../ignite/internal/binary/BinaryUtils.java | 15 +- .../internal/binary/BinaryWriterEx.java | 8 +- .../internal/binary/BinaryWriterExImpl.java | 29 ++- .../internal/binary/GridBinaryMarshaller.java | 4 +- .../builder/BinaryObjectBuilderImpl.java | 10 +- .../binary/BinaryMarshallerSelfTest.java | 3 +- .../binary/RawBinaryObjectExtractorTest.java | 4 +- 8 files changed, 231 insertions(+), 35 deletions(-) create mode 100644 modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/binary/JmhMapSerdesBenchmark.java diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/binary/JmhMapSerdesBenchmark.java b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/binary/JmhMapSerdesBenchmark.java new file mode 100644 index 0000000000000..79304a5d224eb --- /dev/null +++ b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/binary/JmhMapSerdesBenchmark.java @@ -0,0 +1,193 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.benchmarks.jmh.binary; + +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import org.apache.ignite.Ignition; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.binary.BinaryContext; +import org.apache.ignite.internal.binary.BinaryUtils; +import org.apache.ignite.internal.binary.BinaryWriterEx; +import org.apache.ignite.internal.binary.streams.BinaryOutputStream; +import org.apache.ignite.internal.binary.streams.BinaryStreams; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.infra.Blackhole; + +import static java.util.concurrent.TimeUnit.NANOSECONDS; +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.openjdk.jmh.annotations.Mode.AverageTime; +import static org.openjdk.jmh.annotations.Scope.Thread; + +/** */ +@State(Thread) +@OutputTimeUnit(NANOSECONDS) +@BenchmarkMode(AverageTime) +@Warmup(iterations = 5) +@Measurement(iterations = 5, time = 30, timeUnit = SECONDS) +public class JmhMapSerdesBenchmark { + /** */ + @Param({/*"Integer", "Date", "String",*/ "Object"}) + private String key; + + /** */ + @Param({/*"Integer", "Date", "String",*/ "Object"}) + private String value; + + /** */ + @Param({"10", /*"100", "1000", "10000"*/}) + private String size; + + /** */ + @Param({"HashMap", "ConcurrentHashMap", "LinkedHashMap"}) + private String mapType; + + /** */ + private BinaryContext bctx; + + /** */ + private BinaryOutputStream out; + + /** */ + private Map data; + + /** */ + public static void main(String[] args) throws Exception { + org.openjdk.jmh.Main.main(new String[]{JmhMapSerdesBenchmark.class.getName()}); + } + + /** */ + @Setup + public void setup() throws Exception { + IgniteEx node = (IgniteEx)Ignition.start(new IgniteConfiguration()); + + bctx = node.context().cacheObjects().binaryContext(); + out = BinaryStreams.outputStream((int)(100 * U.MB)); + + Ignition.stopAll(false); + + if ("HashMap".equals(mapType)) + data = new HashMap<>(); + else if ("ConcurrentHashMap".equals(mapType)) + data = new ConcurrentHashMap<>(); + else if ("LinkedHashMap".equals(mapType)) + data = new LinkedHashMap<>(); + else + throw new IllegalArgumentException("Unknown map type: " + mapType); + + int sz = Integer.parseInt(size); + for (int i = 0; i < sz; i++) + data.put(produce(i, key), produce(i, value)); + } + + /** */ + public Object produce(int i, String type) { + if ("Integer".equals(type)) + return i; + else if ("Date".equals(type)) + return new Date(System.currentTimeMillis() + i); + else if ("String".equals(type)) + return "" + i; + else if ("Object".equals(type)) { + return new Employee("Name" + i, 1000L * i, new Date()); + } + + throw new IllegalArgumentException("Unknown type: " + type); + } + + /** */ + @Benchmark + public void mapSerialization(Blackhole bh) { + BinaryWriterEx writer = BinaryUtils.writer(bctx, out); + + writer.writeMap(data); + + out.position(0); + } + + /** */ + public static class Employee { + /** */ + private String fio; + + /** */ + private long salary; + + /** */ + private Date created; + + /** */ + public Employee(String fio, long salary, Date created) { + this.fio = fio; + this.salary = salary; + this.created = created; + } + + /** */ + public Employee() { + } + + /** */ + public Employee(String fio, long salary) { + this.fio = fio; + this.salary = salary; + } + + /** */ + public String getFio() { + return fio; + } + + /** */ + public void setFio(String fio) { + this.fio = fio; + } + + /** */ + public long getSalary() { + return salary; + } + + /** */ + public void setSalary(long salary) { + this.salary = salary; + } + + /** */ + public Date getCreated() { + return created; + } + + /** */ + public void setCreated(Date created) { + this.created = created; + } + } +} diff --git a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java index 690e6c91f303d..d629eeae7ff9b 100644 --- a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java +++ b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java @@ -88,6 +88,7 @@ import static org.apache.ignite.IgniteCommonsSystemProperties.DFLT_IGNITE_USE_BINARY_ARRAYS; import static org.apache.ignite.IgniteCommonsSystemProperties.IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2; import static org.apache.ignite.IgniteCommonsSystemProperties.IGNITE_USE_BINARY_ARRAYS; +import static org.apache.ignite.internal.binary.BinaryWriterEx.DFLT_FAIL_IF_UNREGISTERED; import static org.apache.ignite.internal.util.GridUnsafe.align; /** @@ -2923,10 +2924,16 @@ static BinaryReaderEx reader(BinaryContext ctx, * @param ctx Context. * @return Writer instance. */ - public static BinaryWriterEx writer(BinaryContext ctx) { + public static BinaryWriterEx writer(BinaryContext ctx, boolean failIfUnregistered) { BinaryThreadLocalContext locCtx = BinaryThreadLocalContext.get(); - return new BinaryWriterExImpl(ctx, BinaryStreams.outputStream((int)CommonUtils.KB, locCtx.chunk()), locCtx.schemaHolder(), null); + return new BinaryWriterExImpl( + ctx, + BinaryStreams.outputStream((int)CommonUtils.KB, locCtx.chunk()), + locCtx.schemaHolder(), + null, + failIfUnregistered + ); } /** @@ -2935,7 +2942,7 @@ public static BinaryWriterEx writer(BinaryContext ctx) { * @return Writer instance. */ public static BinaryWriterEx writer(BinaryContext ctx, BinaryOutputStream out) { - return new BinaryWriterExImpl(ctx, out, BinaryThreadLocalContext.get().schemaHolder(), null); + return new BinaryWriterExImpl(ctx, out, BinaryThreadLocalContext.get().schemaHolder(), null, DFLT_FAIL_IF_UNREGISTERED); } /** @@ -2944,7 +2951,7 @@ public static BinaryWriterEx writer(BinaryContext ctx, BinaryOutputStream out) { * @return Writer instance. */ public static BinaryWriterEx writer(BinaryContext ctx, BinaryOutputStream out, BinaryWriterSchemaHolder schema) { - return new BinaryWriterExImpl(ctx, out, schema, null); + return new BinaryWriterExImpl(ctx, out, schema, null, DFLT_FAIL_IF_UNREGISTERED); } /** @return Instance of caching handler. */ diff --git a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterEx.java b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterEx.java index fdd8882b306f3..d980422ca72a0 100644 --- a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterEx.java +++ b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterEx.java @@ -29,6 +29,9 @@ * Extended writer interface. */ public interface BinaryWriterEx extends BinaryWriter, BinaryRawWriter, ObjectOutput { + /** Default value for {@link #failIfUnregistered()}. */ + public static final boolean DFLT_FAIL_IF_UNREGISTERED = false; + /** * @param obj Object to write. * @throws org.apache.ignite.binary.BinaryObjectException In case of error. @@ -66,11 +69,6 @@ public interface BinaryWriterEx extends BinaryWriter, BinaryRawWriter, ObjectOut */ public boolean failIfUnregistered(); - /** - * @param failIfUnregistered Fail if unregistered. - */ - public void failIfUnregistered(boolean failIfUnregistered); - /** * @param obj Object. * @throws org.apache.ignite.binary.BinaryObjectException In case of error. diff --git a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java index 4ab8eadac6091..ed1b092e9ad64 100644 --- a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java +++ b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java @@ -83,18 +83,26 @@ class BinaryWriterExImpl implements BinaryWriterEx { private BinaryInternalMapper mapper; /** */ - private boolean failIfUnregistered; + private final boolean failIfUnregistered; /** * @param ctx Context. * @param out Output stream. * @param handles Handles. + * @param failIfUnregistered Flag to fail while writing object of unregistered type. */ - public BinaryWriterExImpl(BinaryContext ctx, BinaryOutputStream out, BinaryWriterSchemaHolder schema, BinaryWriterHandles handles) { + public BinaryWriterExImpl( + BinaryContext ctx, + BinaryOutputStream out, + BinaryWriterSchemaHolder schema, + BinaryWriterHandles handles, + boolean failIfUnregistered + ) { this.ctx = ctx; this.out = out; this.schema = schema; this.handles = handles; + this.failIfUnregistered = failIfUnregistered; start = out.position(); } @@ -104,11 +112,6 @@ public BinaryWriterExImpl(BinaryContext ctx, BinaryOutputStream out, BinaryWrite return failIfUnregistered; } - /** {@inheritDoc} */ - @Override public void failIfUnregistered(boolean failIfUnregistered) { - this.failIfUnregistered = failIfUnregistered; - } - /** {@inheritDoc} */ @Override public void typeId(int typeId) { this.typeId = typeId; @@ -844,9 +847,7 @@ void writeBooleanField(@Nullable Boolean val) { if (obj == null) out.writeByte(GridBinaryMarshaller.NULL); else { - BinaryWriterExImpl writer = new BinaryWriterExImpl(ctx, out, schema, handles()); - - writer.failIfUnregistered(failIfUnregistered); + BinaryWriterExImpl writer = new BinaryWriterExImpl(ctx, out, schema, handles(), failIfUnregistered); writer.marshal(obj); } @@ -857,9 +858,7 @@ void writeBooleanField(@Nullable Boolean val) { if (obj == null) out.writeByte(GridBinaryMarshaller.NULL); else { - BinaryWriterExImpl writer = new BinaryWriterExImpl(ctx, out, schema, null); - - writer.failIfUnregistered(failIfUnregistered); + BinaryWriterExImpl writer = new BinaryWriterExImpl(ctx, out, schema, null, failIfUnregistered); writer.marshal(obj); } @@ -1538,9 +1537,7 @@ boolean tryWriteAsHandle(Object obj) { /** {@inheritDoc} */ @Override public BinaryWriterEx newWriter(int typeId) { - BinaryWriterExImpl res = new BinaryWriterExImpl(ctx, out, schema, handles()); - - res.failIfUnregistered(failIfUnregistered); + BinaryWriterExImpl res = new BinaryWriterExImpl(ctx, out, schema, handles(), failIfUnregistered); res.typeId(typeId); diff --git a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java index 311c629b5535e..eed925e070db6 100644 --- a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java +++ b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java @@ -250,9 +250,7 @@ public byte[] marshal(@Nullable Object obj, boolean failIfUnregistered) throws B if (obj == null) return new byte[] { NULL }; - try (BinaryWriterEx writer = BinaryUtils.writer(ctx)) { - writer.failIfUnregistered(failIfUnregistered); - + try (BinaryWriterEx writer = BinaryUtils.writer(ctx, failIfUnregistered)) { writer.marshal(obj); return writer.array(); diff --git a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java index 1993d1b01c151..3eca70ca1f6cd 100644 --- a/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java +++ b/modules/binary/impl/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java @@ -172,12 +172,12 @@ public BinaryObjectBuilderImpl(BinaryObjectEx obj) { /** {@inheritDoc} */ @Override public BinaryObject build() { - try (BinaryWriterEx writer = BinaryUtils.writer(ctx)) { - Thread curThread = Thread.currentThread(); - - if (curThread instanceof IgniteThread) - writer.failIfUnregistered(((IgniteThread)curThread).isForbiddenToRequestBinaryMetadata()); + Thread curThread = Thread.currentThread(); + try (BinaryWriterEx writer = BinaryUtils.writer( + ctx, + curThread instanceof IgniteThread && ((IgniteThread)curThread).isForbiddenToRequestBinaryMetadata()) + ) { writer.typeId(typeId); BinaryBuilderSerializer serializationCtx = new BinaryBuilderSerializer(); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java index 1423f520b5bc7..cfe47a5e33801 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java @@ -110,6 +110,7 @@ import org.junit.Test; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.apache.ignite.internal.binary.BinaryWriterEx.DFLT_FAIL_IF_UNREGISTERED; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertNotEquals; @@ -3019,7 +3020,7 @@ public void testThreadLocalArrayReleased() throws Exception { BinaryMarshaller marsh = binaryMarshaller(); - try (BinaryWriterEx writer = BinaryUtils.writer(binaryContext(marsh))) { + try (BinaryWriterEx writer = BinaryUtils.writer(binaryContext(marsh), DFLT_FAIL_IF_UNREGISTERED)) { assertEquals(true, BinaryStreamsTestUtils.threadLocalIsAcquired()); writer.writeString("Thread local test"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/RawBinaryObjectExtractorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/RawBinaryObjectExtractorTest.java index 1f4fe14c8fac9..92af46aed4554 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/RawBinaryObjectExtractorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/RawBinaryObjectExtractorTest.java @@ -38,6 +38,8 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Test; +import static org.apache.ignite.internal.binary.BinaryWriterEx.DFLT_FAIL_IF_UNREGISTERED; + /** */ public class RawBinaryObjectExtractorTest extends GridCommonAbstractTest { /** */ @@ -49,7 +51,7 @@ public void test() throws Exception { byte[] serializedTestObjectsBytes; - try (BinaryWriterEx writer = BinaryUtils.writer(ctx)) { + try (BinaryWriterEx writer = BinaryUtils.writer(ctx, DFLT_FAIL_IF_UNREGISTERED)) { testObjects.forEach(writer::writeObject); serializedTestObjectsBytes = writer.array(); From 69b4428216ac32bc9c68a688b39912a47f6faef7 Mon Sep 17 00:00:00 2001 From: Nikolay Izhikov Date: Mon, 24 Nov 2025 20:12:33 +0300 Subject: [PATCH 2/3] IGNITE-27155 BinaryWriterExImpl#failIfUnregistered can be final --- .../jmh/binary/JmhMapSerdesBenchmark.java | 193 ------------------ 1 file changed, 193 deletions(-) delete mode 100644 modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/binary/JmhMapSerdesBenchmark.java diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/binary/JmhMapSerdesBenchmark.java b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/binary/JmhMapSerdesBenchmark.java deleted file mode 100644 index 79304a5d224eb..0000000000000 --- a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/binary/JmhMapSerdesBenchmark.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.benchmarks.jmh.binary; - -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import org.apache.ignite.Ignition; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.binary.BinaryContext; -import org.apache.ignite.internal.binary.BinaryUtils; -import org.apache.ignite.internal.binary.BinaryWriterEx; -import org.apache.ignite.internal.binary.streams.BinaryOutputStream; -import org.apache.ignite.internal.binary.streams.BinaryStreams; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.BenchmarkMode; -import org.openjdk.jmh.annotations.Measurement; -import org.openjdk.jmh.annotations.OutputTimeUnit; -import org.openjdk.jmh.annotations.Param; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; -import org.openjdk.jmh.annotations.Warmup; -import org.openjdk.jmh.infra.Blackhole; - -import static java.util.concurrent.TimeUnit.NANOSECONDS; -import static java.util.concurrent.TimeUnit.SECONDS; -import static org.openjdk.jmh.annotations.Mode.AverageTime; -import static org.openjdk.jmh.annotations.Scope.Thread; - -/** */ -@State(Thread) -@OutputTimeUnit(NANOSECONDS) -@BenchmarkMode(AverageTime) -@Warmup(iterations = 5) -@Measurement(iterations = 5, time = 30, timeUnit = SECONDS) -public class JmhMapSerdesBenchmark { - /** */ - @Param({/*"Integer", "Date", "String",*/ "Object"}) - private String key; - - /** */ - @Param({/*"Integer", "Date", "String",*/ "Object"}) - private String value; - - /** */ - @Param({"10", /*"100", "1000", "10000"*/}) - private String size; - - /** */ - @Param({"HashMap", "ConcurrentHashMap", "LinkedHashMap"}) - private String mapType; - - /** */ - private BinaryContext bctx; - - /** */ - private BinaryOutputStream out; - - /** */ - private Map data; - - /** */ - public static void main(String[] args) throws Exception { - org.openjdk.jmh.Main.main(new String[]{JmhMapSerdesBenchmark.class.getName()}); - } - - /** */ - @Setup - public void setup() throws Exception { - IgniteEx node = (IgniteEx)Ignition.start(new IgniteConfiguration()); - - bctx = node.context().cacheObjects().binaryContext(); - out = BinaryStreams.outputStream((int)(100 * U.MB)); - - Ignition.stopAll(false); - - if ("HashMap".equals(mapType)) - data = new HashMap<>(); - else if ("ConcurrentHashMap".equals(mapType)) - data = new ConcurrentHashMap<>(); - else if ("LinkedHashMap".equals(mapType)) - data = new LinkedHashMap<>(); - else - throw new IllegalArgumentException("Unknown map type: " + mapType); - - int sz = Integer.parseInt(size); - for (int i = 0; i < sz; i++) - data.put(produce(i, key), produce(i, value)); - } - - /** */ - public Object produce(int i, String type) { - if ("Integer".equals(type)) - return i; - else if ("Date".equals(type)) - return new Date(System.currentTimeMillis() + i); - else if ("String".equals(type)) - return "" + i; - else if ("Object".equals(type)) { - return new Employee("Name" + i, 1000L * i, new Date()); - } - - throw new IllegalArgumentException("Unknown type: " + type); - } - - /** */ - @Benchmark - public void mapSerialization(Blackhole bh) { - BinaryWriterEx writer = BinaryUtils.writer(bctx, out); - - writer.writeMap(data); - - out.position(0); - } - - /** */ - public static class Employee { - /** */ - private String fio; - - /** */ - private long salary; - - /** */ - private Date created; - - /** */ - public Employee(String fio, long salary, Date created) { - this.fio = fio; - this.salary = salary; - this.created = created; - } - - /** */ - public Employee() { - } - - /** */ - public Employee(String fio, long salary) { - this.fio = fio; - this.salary = salary; - } - - /** */ - public String getFio() { - return fio; - } - - /** */ - public void setFio(String fio) { - this.fio = fio; - } - - /** */ - public long getSalary() { - return salary; - } - - /** */ - public void setSalary(long salary) { - this.salary = salary; - } - - /** */ - public Date getCreated() { - return created; - } - - /** */ - public void setCreated(Date created) { - this.created = created; - } - } -} From c4f5a0af7390b9489558dfb87be5a995295a784f Mon Sep 17 00:00:00 2001 From: Nikolay Izhikov Date: Mon, 24 Nov 2025 21:24:27 +0300 Subject: [PATCH 3/3] IGNITE-27155 BinaryWriterExImpl#failIfUnregistered can be final --- .../java/org/apache/ignite/internal/binary/BinaryUtils.java | 6 +++--- .../org/apache/ignite/internal/binary/BinaryWriterEx.java | 3 --- .../ignite/internal/binary/BinaryMarshallerSelfTest.java | 3 +-- .../internal/binary/RawBinaryObjectExtractorTest.java | 4 +--- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java index d629eeae7ff9b..4ce858fca0e34 100644 --- a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java +++ b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java @@ -88,7 +88,6 @@ import static org.apache.ignite.IgniteCommonsSystemProperties.DFLT_IGNITE_USE_BINARY_ARRAYS; import static org.apache.ignite.IgniteCommonsSystemProperties.IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2; import static org.apache.ignite.IgniteCommonsSystemProperties.IGNITE_USE_BINARY_ARRAYS; -import static org.apache.ignite.internal.binary.BinaryWriterEx.DFLT_FAIL_IF_UNREGISTERED; import static org.apache.ignite.internal.util.GridUnsafe.align; /** @@ -2922,6 +2921,7 @@ static BinaryReaderEx reader(BinaryContext ctx, /** * @param ctx Context. + * @param failIfUnregistered Flag to fail while writing object of unregistered type. * @return Writer instance. */ public static BinaryWriterEx writer(BinaryContext ctx, boolean failIfUnregistered) { @@ -2942,7 +2942,7 @@ public static BinaryWriterEx writer(BinaryContext ctx, boolean failIfUnregistere * @return Writer instance. */ public static BinaryWriterEx writer(BinaryContext ctx, BinaryOutputStream out) { - return new BinaryWriterExImpl(ctx, out, BinaryThreadLocalContext.get().schemaHolder(), null, DFLT_FAIL_IF_UNREGISTERED); + return new BinaryWriterExImpl(ctx, out, BinaryThreadLocalContext.get().schemaHolder(), null, false); } /** @@ -2951,7 +2951,7 @@ public static BinaryWriterEx writer(BinaryContext ctx, BinaryOutputStream out) { * @return Writer instance. */ public static BinaryWriterEx writer(BinaryContext ctx, BinaryOutputStream out, BinaryWriterSchemaHolder schema) { - return new BinaryWriterExImpl(ctx, out, schema, null, DFLT_FAIL_IF_UNREGISTERED); + return new BinaryWriterExImpl(ctx, out, schema, null, false); } /** @return Instance of caching handler. */ diff --git a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterEx.java b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterEx.java index d980422ca72a0..5c73676c6bf28 100644 --- a/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterEx.java +++ b/modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterEx.java @@ -29,9 +29,6 @@ * Extended writer interface. */ public interface BinaryWriterEx extends BinaryWriter, BinaryRawWriter, ObjectOutput { - /** Default value for {@link #failIfUnregistered()}. */ - public static final boolean DFLT_FAIL_IF_UNREGISTERED = false; - /** * @param obj Object to write. * @throws org.apache.ignite.binary.BinaryObjectException In case of error. diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java index cfe47a5e33801..955826b8f3fa4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java @@ -110,7 +110,6 @@ import org.junit.Test; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.apache.ignite.internal.binary.BinaryWriterEx.DFLT_FAIL_IF_UNREGISTERED; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertNotEquals; @@ -3020,7 +3019,7 @@ public void testThreadLocalArrayReleased() throws Exception { BinaryMarshaller marsh = binaryMarshaller(); - try (BinaryWriterEx writer = BinaryUtils.writer(binaryContext(marsh), DFLT_FAIL_IF_UNREGISTERED)) { + try (BinaryWriterEx writer = BinaryUtils.writer(binaryContext(marsh), false)) { assertEquals(true, BinaryStreamsTestUtils.threadLocalIsAcquired()); writer.writeString("Thread local test"); diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/RawBinaryObjectExtractorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/RawBinaryObjectExtractorTest.java index 92af46aed4554..3cf2d7b570f3b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/binary/RawBinaryObjectExtractorTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/RawBinaryObjectExtractorTest.java @@ -38,8 +38,6 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Test; -import static org.apache.ignite.internal.binary.BinaryWriterEx.DFLT_FAIL_IF_UNREGISTERED; - /** */ public class RawBinaryObjectExtractorTest extends GridCommonAbstractTest { /** */ @@ -51,7 +49,7 @@ public void test() throws Exception { byte[] serializedTestObjectsBytes; - try (BinaryWriterEx writer = BinaryUtils.writer(ctx, DFLT_FAIL_IF_UNREGISTERED)) { + try (BinaryWriterEx writer = BinaryUtils.writer(ctx, false)) { testObjects.forEach(writer::writeObject); serializedTestObjectsBytes = writer.array();