This is an automated email from the ASF dual-hosted git repository.

shishkovilja 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 2af5b180e1b IGNITE-26716 Refactor serialization of 
CacheEntryPredicateAdapter and CacheEntrySerializablePredicate (#12424)
2af5b180e1b is described below

commit 2af5b180e1bb58f5b8f4299ce3596f7d2bd6076b
Author: Vladimir Steshin <[email protected]>
AuthorDate: Fri Oct 24 09:52:37 2025 +0300

    IGNITE-26716 Refactor serialization of CacheEntryPredicateAdapter and 
CacheEntrySerializablePredicate (#12424)
---
 .../communication/GridIoMessageFactory.java        |   7 +-
 .../cache/CacheEntryPredicateAdapter.java          | 172 +++++++++++++++++----
 .../cache/CacheEntryPredicateContainsValue.java    | 148 ------------------
 .../cache/CacheEntryPredicateHasValue.java         |  31 ----
 .../cache/CacheEntryPredicateNoValue.java          |  31 ----
 .../cache/CacheEntrySerializablePredicate.java     | 146 -----------------
 .../processors/cache/GridCacheContext.java         |  10 +-
 .../internal/processors/cache/GridCacheUtils.java  |  18 +--
 .../main/resources/META-INF/classnames.properties  |   4 -
 .../CacheEntryPredicateAdapterMessageTest.java     |  88 +++++++++++
 .../ignite/testsuites/IgniteBasicTestSuite.java    |   4 +-
 11 files changed, 243 insertions(+), 416 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
index ada9c952c68..294670f1c83 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
@@ -29,6 +29,7 @@ import 
org.apache.ignite.internal.codegen.AtomicApplicationAttributesAwareReques
 import org.apache.ignite.internal.codegen.BinaryMetadataVersionInfoSerializer;
 import 
org.apache.ignite.internal.codegen.CacheContinuousQueryBatchAckSerializer;
 import org.apache.ignite.internal.codegen.CacheEntryInfoCollectionSerializer;
+import org.apache.ignite.internal.codegen.CacheEntryPredicateAdapterSerializer;
 import org.apache.ignite.internal.codegen.CacheEvictionEntrySerializer;
 import org.apache.ignite.internal.codegen.CacheGroupAffinityMessageSerializer;
 import 
org.apache.ignite.internal.codegen.CachePartitionPartialCountersMapSerializer;
@@ -139,8 +140,7 @@ import 
org.apache.ignite.internal.processors.authentication.UserAuthenticateRequ
 import 
org.apache.ignite.internal.processors.authentication.UserAuthenticateResponseMessage;
 import 
org.apache.ignite.internal.processors.authentication.UserManagementOperationFinishedMessage;
 import org.apache.ignite.internal.processors.cache.CacheEntryInfoCollection;
-import 
org.apache.ignite.internal.processors.cache.CacheEntryPredicateContainsValue;
-import 
org.apache.ignite.internal.processors.cache.CacheEntrySerializablePredicate;
+import org.apache.ignite.internal.processors.cache.CacheEntryPredicateAdapter;
 import org.apache.ignite.internal.processors.cache.CacheEvictionEntry;
 import org.apache.ignite.internal.processors.cache.CacheInvokeDirectResult;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
@@ -369,8 +369,7 @@ public class GridIoMessageFactory implements 
MessageFactoryProvider {
         factory.register((short)95, DataStreamerEntry::new);
         factory.register((short)96, CacheContinuousQueryEntry::new);
         factory.register((short)97, CacheEvictionEntry::new, new 
CacheEvictionEntrySerializer());
-        factory.register((short)98, CacheEntryPredicateContainsValue::new);
-        factory.register((short)99, CacheEntrySerializablePredicate::new);
+        factory.register((short)98, CacheEntryPredicateAdapter::new, new 
CacheEntryPredicateAdapterSerializer());
         factory.register((short)100, IgniteTxEntry::new);
         factory.register((short)101, TxEntryValueHolder::new);
         factory.register((short)102, CacheVersionedValue::new, new 
CacheVersionedValueSerializer());
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
index 89c39e2eef7..c58bdba9400 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
@@ -17,30 +17,55 @@
 
 package org.apache.ignite.internal.processors.cache;
 
-import java.nio.ByteBuffer;
+import java.util.Objects;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.plugin.extensions.communication.MessageReader;
-import org.apache.ignite.plugin.extensions.communication.MessageWriter;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.internal.Order;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.jetbrains.annotations.Nullable;
 
-/**
- *
- */
-public abstract class CacheEntryPredicateAdapter implements 
CacheEntryPredicate {
+/** A unified container for common, typical cache entry predicates. */
+public class CacheEntryPredicateAdapter implements CacheEntryPredicate {
     /** */
     private static final long serialVersionUID = 4647110502545358709L;
 
+    /** */
+    public static final CacheEntryPredicateAdapter ALWAYS_FALSE = new 
CacheEntryPredicateAdapter(PredicateType.ALWAYS_FALSE);
+
     /** */
     protected transient boolean locked;
 
-    /** {@inheritDoc} */
-    @Override public void finishUnmarshal(GridCacheContext ctx, ClassLoader 
ldr) throws IgniteCheckedException {
-        // No-op.
+    /** */
+    @GridToStringInclude
+    private PredicateType type;
+
+    /** Type value serialization holder. */
+    @Order(0)
+    protected transient byte code;
+
+    /** */
+    @GridToStringInclude
+    @Order(value = 1, method = "value")
+    @Nullable private CacheObject val;
+
+    /** */
+    public CacheEntryPredicateAdapter() {
+        type = PredicateType.OTHER;
     }
 
-    /** {@inheritDoc} */
-    @Override public void prepareMarshal(GridCacheContext ctx) throws 
IgniteCheckedException {
-        // No-op.
+    /** */
+    public CacheEntryPredicateAdapter(PredicateType type) {
+        assert type != null;
+
+        this.type = type;
+    }
+
+    /** */
+    public CacheEntryPredicateAdapter(@Nullable CacheObject val) {
+        this.type = PredicateType.VALUE;
+
+        this.val = val;
     }
 
     /** {@inheritDoc} */
@@ -50,37 +75,122 @@ public abstract class CacheEntryPredicateAdapter 
implements CacheEntryPredicate
 
     /** {@inheritDoc} */
     @Override public short directType() {
-        assert false : this;
+        return 98;
+    }
+
+    /** */
+    public PredicateType type() {
+        return type;
+    }
 
-        return 0;
+    /**
+     * @param entry Entry.
+     * @return Value.
+     */
+    @Nullable private CacheObject peekVisibleValue(GridCacheEntryEx entry) {
+        return locked ? entry.rawGet() : entry.peekVisibleValue();
     }
 
     /** {@inheritDoc} */
-    @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
-        reader.setBuffer(buf);
+    @Override public boolean apply(GridCacheEntryEx e) {
+        switch (type) {
+            case VALUE: {
+                CacheObject val = peekVisibleValue(e);
+
+                if (this.val == null && val == null)
+                    return true;
+
+                if (this.val == null || val == null)
+                    return false;
+
+                GridCacheContext<?, ?> cctx = e.context();
 
-        return true;
+                if (this.val instanceof BinaryObject && val instanceof 
BinaryObject)
+                    return Objects.equals(val, this.val);
+
+                Object thisVal = CU.value(this.val, cctx, false);
+                Object cacheVal = CU.value(val, cctx, false);
+
+                if (thisVal.getClass().isArray())
+                    return Objects.deepEquals(thisVal, cacheVal);
+
+                return Objects.equals(thisVal, cacheVal);
+            }
+
+            case HAS_VALUE:
+                return peekVisibleValue(e) != null;
+
+            case HAS_NO_VALUE:
+                return peekVisibleValue(e) == null;
+
+            case ALWAYS_FALSE:
+                return false;
+        }
+
+        throw new IllegalStateException("Unknown cache entry predicate type: " 
+ type);
     }
 
     /** {@inheritDoc} */
-    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
-        writer.setBuffer(buf);
+    @Override public void finishUnmarshal(GridCacheContext ctx, ClassLoader 
ldr) throws IgniteCheckedException {
+        if (type == PredicateType.VALUE)
+            val.finishUnmarshal(ctx.cacheObjectContext(), ldr);
+    }
 
-        if (!writer.isHeaderWritten()) {
-            if (!writer.writeHeader(directType()))
-                return false;
+    /** {@inheritDoc} */
+    @Override public void prepareMarshal(GridCacheContext ctx) throws 
IgniteCheckedException {
+        if (type == PredicateType.VALUE)
+            val.prepareMarshal(ctx.cacheObjectContext());
+    }
 
-            writer.onHeaderWritten();
+    /** */
+    public @Nullable CacheObject value() {
+        return val;
+    }
+
+    /** */
+    public void value(@Nullable CacheObject val) {
+        this.val = val;
+    }
+
+    /** */
+    public byte code() {
+        assert type != null;
+
+        switch (type) {
+            case OTHER: return 0;
+            case VALUE: return 1;
+            case HAS_VALUE: return 2;
+            case HAS_NO_VALUE: return 3;
+            case ALWAYS_FALSE: return 4;
         }
 
-        return true;
+        throw new IllegalArgumentException("Unknown cache entry predicate 
type: " + type);
     }
 
-    /**
-     * @param entry Entry.
-     * @return Value.
-     */
-    @Nullable protected CacheObject peekVisibleValue(GridCacheEntryEx entry) {
-        return locked ? entry.rawGet() : entry.peekVisibleValue();
+    /** */
+    public void code(byte code) {
+        switch (code) {
+            case 0: type = PredicateType.OTHER; break;
+            case 1: type = PredicateType.VALUE; break;
+            case 2: type = PredicateType.HAS_VALUE; break;
+            case 3: type = PredicateType.HAS_NO_VALUE; break;
+            case 4: type = PredicateType.ALWAYS_FALSE; break;
+            default:
+                throw new IllegalArgumentException("Unknown cache entry 
predicate type code: " + code);
+        }
+    }
+
+    /** Common predicate type. */
+    public enum PredicateType {
+        /** Other custom predicate. */
+        OTHER,
+        /** Entry has certain equal value. */
+        VALUE,
+        /** Entry has any value. */
+        HAS_VALUE,
+        /** Entry has no value. */
+        HAS_NO_VALUE,
+        /** Is always false. */
+        ALWAYS_FALSE
     }
 }
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java
deleted file mode 100644
index 5a39c212b9b..00000000000
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateContainsValue.java
+++ /dev/null
@@ -1,148 +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.processors.cache;
-
-import java.nio.ByteBuffer;
-import java.util.Objects;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.internal.CU;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.plugin.extensions.communication.MessageReader;
-import org.apache.ignite.plugin.extensions.communication.MessageWriter;
-
-/**
- *
- */
-public class CacheEntryPredicateContainsValue extends 
CacheEntryPredicateAdapter {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** */
-    @GridToStringInclude
-    private CacheObject val;
-
-    /**
-     * Required by {@link 
org.apache.ignite.plugin.extensions.communication.Message}.
-     */
-    public CacheEntryPredicateContainsValue() {
-        // No-op.
-    }
-
-    /**
-     *
-     * @param val Value to compare with.
-     */
-    public CacheEntryPredicateContainsValue(CacheObject val) {
-        assert val != null;
-
-        this.val = val;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean apply(GridCacheEntryEx e) {
-        CacheObject val = peekVisibleValue(e);
-
-        if (this.val == null && val == null)
-            return true;
-
-        if (this.val == null || val == null)
-            return false;
-
-        GridCacheContext cctx = e.context();
-
-        if (this.val instanceof BinaryObject && val instanceof BinaryObject)
-            return Objects.equals(val, this.val);
-
-        Object thisVal = CU.value(this.val, cctx, false);
-        Object cacheVal = CU.value(val, cctx, false);
-
-        if (thisVal.getClass().isArray())
-            return Objects.deepEquals(thisVal, cacheVal);
-
-        return Objects.equals(thisVal, cacheVal);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void finishUnmarshal(GridCacheContext ctx, ClassLoader 
ldr) throws IgniteCheckedException {
-        val.finishUnmarshal(ctx.cacheObjectContext(), ldr);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void prepareMarshal(GridCacheContext ctx) throws 
IgniteCheckedException {
-        val.prepareMarshal(ctx.cacheObjectContext());
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
-        writer.setBuffer(buf);
-
-        if (!super.writeTo(buf, writer))
-            return false;
-
-        if (!writer.isHeaderWritten()) {
-            if (!writer.writeHeader(directType()))
-                return false;
-
-            writer.onHeaderWritten();
-        }
-
-        switch (writer.state()) {
-            case 0:
-                if (!writer.writeCacheObject(val))
-                    return false;
-
-                writer.incrementState();
-
-        }
-
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
-        reader.setBuffer(buf);
-
-        if (!super.readFrom(buf, reader))
-            return false;
-
-        switch (reader.state()) {
-            case 0:
-                val = reader.readCacheObject();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-        }
-
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public short directType() {
-        return 98;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(CacheEntryPredicateContainsValue.class, this);
-    }
-}
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateHasValue.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateHasValue.java
deleted file mode 100644
index 210cc7059b2..00000000000
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateHasValue.java
+++ /dev/null
@@ -1,31 +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.processors.cache;
-
-/**
- *
- */
-public class CacheEntryPredicateHasValue extends CacheEntryPredicateAdapter {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** {@inheritDoc} */
-    @Override public boolean apply(GridCacheEntryEx e) {
-        return peekVisibleValue(e) != null;
-    }
-}
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateNoValue.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateNoValue.java
deleted file mode 100644
index 4c8917fcc68..00000000000
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateNoValue.java
+++ /dev/null
@@ -1,31 +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.processors.cache;
-
-/**
- *
- */
-public class CacheEntryPredicateNoValue extends CacheEntryPredicateAdapter {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** {@inheritDoc} */
-    @Override public boolean apply(GridCacheEntryEx e) {
-        return peekVisibleValue(e) == null;
-    }
-}
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
deleted file mode 100644
index b9ad7a62c7d..00000000000
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntrySerializablePredicate.java
+++ /dev/null
@@ -1,146 +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.processors.cache;
-
-import java.nio.ByteBuffer;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridDirectTransient;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.plugin.extensions.communication.MessageReader;
-import org.apache.ignite.plugin.extensions.communication.MessageWriter;
-
-/**
- *
- */
-public class CacheEntrySerializablePredicate implements CacheEntryPredicate {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** */
-    @GridToStringInclude
-    @GridDirectTransient
-    private CacheEntryPredicate p;
-
-    /** */
-    private byte[] bytes;
-
-    /**
-     * Required by {@link 
org.apache.ignite.plugin.extensions.communication.Message}.
-     */
-    public CacheEntrySerializablePredicate() {
-        // No-op.
-    }
-
-    /**
-     * @param p Serializable predicate.
-     */
-    public CacheEntrySerializablePredicate(CacheEntryPredicate p) {
-        assert p != null;
-
-        this.p = p;
-    }
-
-    /**
-     * @return Predicate.
-     */
-    public CacheEntryPredicate predicate() {
-        return p;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void entryLocked(boolean locked) {
-        assert p != null;
-
-        p.entryLocked(locked);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void finishUnmarshal(GridCacheContext ctx, ClassLoader 
ldr) throws IgniteCheckedException {
-        assert p != null || bytes != null;
-
-        if (p == null) {
-            p = U.unmarshal(ctx.marshaller(), bytes, U.resolveClassLoader(ldr, 
ctx.gridConfig()));
-
-            p.finishUnmarshal(ctx, ldr);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void prepareMarshal(GridCacheContext ctx) throws 
IgniteCheckedException {
-        assert p != null;
-
-        p.prepareMarshal(ctx);
-
-        if (bytes == null)
-            bytes = U.marshal(ctx.marshaller(), p);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean apply(GridCacheEntryEx e) {
-        assert p != null;
-
-        return p.apply(e);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
-        writer.setBuffer(buf);
-
-        if (!writer.isHeaderWritten()) {
-            if (!writer.writeHeader(directType()))
-                return false;
-
-            writer.onHeaderWritten();
-        }
-
-        switch (writer.state()) {
-            case 0:
-                if (!writer.writeByteArray(bytes))
-                    return false;
-
-                writer.incrementState();
-
-        }
-
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
-        reader.setBuffer(buf);
-
-        switch (reader.state()) {
-            case 0:
-                bytes = reader.readByteArray();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-        }
-
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public short directType() {
-        return 99;
-    }
-}
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index 8e13add0fac..b900f5e1bf3 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -1205,8 +1205,8 @@ public class GridCacheContext<K, V> implements 
Externalizable {
             return false;
 
         for (CacheEntryPredicate p0 : p) {
-            if ((p0 instanceof CacheEntrySerializablePredicate) &&
-                ((CacheEntrySerializablePredicate)p0).predicate() instanceof 
CacheEntryPredicateNoValue)
+            if ((p0 instanceof CacheEntryPredicateAdapter) &&
+                ((CacheEntryPredicateAdapter)p0).type() == 
CacheEntryPredicateAdapter.PredicateType.HAS_NO_VALUE)
                 return true;
         }
 
@@ -1217,14 +1217,14 @@ public class GridCacheContext<K, V> implements 
Externalizable {
      * @return No value filter.
      */
     public CacheEntryPredicate noVal() {
-        return new CacheEntrySerializablePredicate(new 
CacheEntryPredicateNoValue());
+        return new 
CacheEntryPredicateAdapter(CacheEntryPredicateAdapter.PredicateType.HAS_NO_VALUE);
     }
 
     /**
      * @return Has value filter.
      */
     public CacheEntryPredicate hasVal() {
-        return new CacheEntrySerializablePredicate(new 
CacheEntryPredicateHasValue());
+        return new 
CacheEntryPredicateAdapter(CacheEntryPredicateAdapter.PredicateType.HAS_VALUE);
     }
 
     /**
@@ -1232,7 +1232,7 @@ public class GridCacheContext<K, V> implements 
Externalizable {
      * @return Predicate that checks for value.
      */
     public CacheEntryPredicate equalsVal(V val) {
-        return new CacheEntryPredicateContainsValue(toCacheObject(val));
+        return new CacheEntryPredicateAdapter(toCacheObject(val));
     }
 
     /**
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index 2d406198854..4da8e1acd91 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -235,28 +235,16 @@ public class GridCacheUtils {
     public static final long EXPIRE_TIME_CALCULATE = -1L;
 
     /** Empty predicate array. */
-    private static final IgnitePredicate[] EMPTY = new IgnitePredicate[0];
+    private static final IgnitePredicate<?>[] EMPTY = new IgnitePredicate[0];
 
     /** Default transaction config. */
     private static final TransactionConfiguration DEFAULT_TX_CFG = new 
TransactionConfiguration();
 
-    /** Empty predicate array. */
-    private static final IgnitePredicate[] EMPTY_FILTER = new 
IgnitePredicate[0];
-
     /** Empty predicate array. */
     private static final CacheEntryPredicate[] EMPTY_FILTER0 = new 
CacheEntryPredicate[0];
 
     /** */
-    private static final CacheEntryPredicate ALWAYS_FALSE0 = new 
CacheEntrySerializablePredicate(
-        new CacheEntryPredicateAdapter() {
-            @Override public boolean apply(GridCacheEntryEx e) {
-                return false;
-            }
-        }
-    );
-
-    /** */
-    private static final CacheEntryPredicate[] ALWAYS_FALSE0_ARR = new 
CacheEntryPredicate[] {ALWAYS_FALSE0};
+    private static final CacheEntryPredicate[] ALWAYS_FALSE0_ARR = new 
CacheEntryPredicate[] {CacheEntryPredicateAdapter.ALWAYS_FALSE};
 
     /** Read filter. */
     public static final IgnitePredicate<IgniteTxEntry> READ_FILTER = new 
P1<IgniteTxEntry>() {
@@ -487,7 +475,7 @@ public class GridCacheUtils {
      * @return Empty filter.
      */
     public static <K, V> IgnitePredicate<Cache.Entry<K, V>>[] empty() {
-        return (IgnitePredicate<Cache.Entry<K, V>>[])EMPTY_FILTER;
+        return (IgnitePredicate<Cache.Entry<K, V>>[])EMPTY;
     }
 
     /**
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties 
b/modules/core/src/main/resources/META-INF/classnames.properties
index c578fc5101c..36bd6336136 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -817,10 +817,6 @@ 
org.apache.ignite.internal.processors.cache.CacheEntryImplEx
 org.apache.ignite.internal.processors.cache.CacheEntryInfoCollection
 org.apache.ignite.internal.processors.cache.CacheEntryPredicate
 org.apache.ignite.internal.processors.cache.CacheEntryPredicateAdapter
-org.apache.ignite.internal.processors.cache.CacheEntryPredicateContainsValue
-org.apache.ignite.internal.processors.cache.CacheEntryPredicateHasValue
-org.apache.ignite.internal.processors.cache.CacheEntryPredicateNoValue
-org.apache.ignite.internal.processors.cache.CacheEntrySerializablePredicate
 org.apache.ignite.internal.processors.cache.CacheEvictionEntry
 org.apache.ignite.internal.processors.cache.CacheGroupContext$2
 org.apache.ignite.internal.processors.cache.CacheGroupData
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/CacheEntryPredicateAdapterMessageTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/CacheEntryPredicateAdapterMessageTest.java
new file mode 100644
index 00000000000..6697942a1dc
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/managers/communication/CacheEntryPredicateAdapterMessageTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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.managers.communication;
+
+import org.apache.ignite.internal.processors.cache.CacheEntryPredicateAdapter;
+import org.apache.ignite.internal.processors.cache.CacheObject;
+import org.apache.ignite.internal.util.typedef.F;
+import org.junit.Test;
+
+import static 
org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class CacheEntryPredicateAdapterMessageTest {
+    /** */
+    @Test
+    public void testCacheEntryPredicateAdapterCode() {
+        assertEquals(0, new CacheEntryPredicateAdapter().code());
+        assertEquals(0, new 
CacheEntryPredicateAdapter(CacheEntryPredicateAdapter.PredicateType.OTHER).code());
+        assertEquals(1, new 
CacheEntryPredicateAdapter(CacheEntryPredicateAdapter.PredicateType.VALUE).code());
+        assertEquals(1, new 
CacheEntryPredicateAdapter((CacheObject)null).code());
+        assertEquals(2, new 
CacheEntryPredicateAdapter(CacheEntryPredicateAdapter.PredicateType.HAS_VALUE).code());
+        assertEquals(3, new 
CacheEntryPredicateAdapter(CacheEntryPredicateAdapter.PredicateType.HAS_NO_VALUE).code());
+        assertEquals(4, new 
CacheEntryPredicateAdapter(CacheEntryPredicateAdapter.PredicateType.ALWAYS_FALSE).code());
+
+        for (CacheEntryPredicateAdapter.PredicateType t : 
CacheEntryPredicateAdapter.PredicateType.values()) {
+            assertTrue(new CacheEntryPredicateAdapter(t).code() >= 0);
+            assertTrue(new CacheEntryPredicateAdapter(t).code() < 5);
+        }
+    }
+
+    /** */
+    @Test
+    public void testCacheEntryPredicateAdapterFromCode() {
+        CacheEntryPredicateAdapter msg = new 
CacheEntryPredicateAdapter((CacheObject)null);
+        assertSame(CacheEntryPredicateAdapter.PredicateType.VALUE, msg.type());
+
+        msg.code((byte)0);
+        assertSame(CacheEntryPredicateAdapter.PredicateType.OTHER, msg.type());
+
+        msg.code((byte)1);
+        assertSame(CacheEntryPredicateAdapter.PredicateType.VALUE, msg.type());
+
+        msg.code((byte)2);
+        assertSame(CacheEntryPredicateAdapter.PredicateType.HAS_VALUE, 
msg.type());
+
+        msg.code((byte)3);
+        assertSame(CacheEntryPredicateAdapter.PredicateType.HAS_NO_VALUE, 
msg.type());
+
+        msg.code((byte)4);
+        assertSame(CacheEntryPredicateAdapter.PredicateType.ALWAYS_FALSE, 
msg.type());
+
+        Throwable t = assertThrowsWithCause(() -> msg.code((byte)5), 
IllegalArgumentException.class);
+        assertEquals("Unknown cache entry predicate type code: 5", 
t.getMessage());
+    }
+
+    /** */
+    @Test
+    public void testConversionConsistency() {
+        for (CacheEntryPredicateAdapter.PredicateType t : 
F.concat(CacheEntryPredicateAdapter.PredicateType.values())) {
+            CacheEntryPredicateAdapter msg = new CacheEntryPredicateAdapter(t);
+
+            assertEquals(t, msg.type());
+
+            CacheEntryPredicateAdapter newMsg = new 
CacheEntryPredicateAdapter();
+            newMsg.code(msg.code());
+
+            assertEquals(msg.type(), newMsg.type());
+        }
+    }
+}
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index aadd5c46f84..83c66539bc2 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -37,6 +37,7 @@ import 
org.apache.ignite.internal.IgniteLocalNodeMapBeforeStartTest;
 import org.apache.ignite.internal.IgniteSlowClientDetectionSelfTest;
 import org.apache.ignite.internal.TransactionsMXBeanImplTest;
 import org.apache.ignite.internal.codegen.MessageProcessorTest;
+import 
org.apache.ignite.internal.managers.communication.CacheEntryPredicateAdapterMessageTest;
 import 
org.apache.ignite.internal.managers.communication.CacheWriteSynchroizationModeMessageTest;
 import org.apache.ignite.internal.managers.communication.ErrorMessageSelfTest;
 import 
org.apache.ignite.internal.managers.communication.GridCacheOperationModeMessageTest;
@@ -151,7 +152,8 @@ import org.junit.runners.Suite;
     ErrorMessageSelfTest.class,
     TransactionIsolationMessageTest.class,
     GridCacheOperationModeMessageTest.class,
-    CacheWriteSynchroizationModeMessageTest.class
+    CacheWriteSynchroizationModeMessageTest.class,
+    CacheEntryPredicateAdapterMessageTest.class
 })
 public class IgniteBasicTestSuite {
 }


Reply via email to