Fixed "IGNITE-6360: NPE occurs if object with null indexed field is added". This closes #2739.
Signed-off-by: nikolay_tikhonov <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2929acef Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2929acef Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2929acef Branch: refs/heads/ignite-3478 Commit: 2929acef591a6309438cd46e11751bf86a11bf8b Parents: 12cbf75 Author: mcherkasov <[email protected]> Authored: Wed Sep 27 13:39:20 2017 +0300 Committer: nikolay_tikhonov <[email protected]> Committed: Wed Sep 27 13:40:01 2017 +0300 ---------------------------------------------------------------------- .../processors/query/h2/database/InlineIndexHelper.java | 3 +++ .../processors/query/h2/database/InlineIndexHelperTest.java | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/2929acef/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelper.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelper.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelper.java index 8ae3bc9..5c42d0d 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelper.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelper.java @@ -383,6 +383,9 @@ public class InlineIndexHelper { if (type == Value.NULL) return Integer.MIN_VALUE; + if (v == ValueNull.INSTANCE) + return fixSort(1, sortType()); + if (this.type != type) throw new UnsupportedOperationException("Invalid fast index type: " + type); http://git-wip-us.apache.org/repos/asf/ignite/blob/2929acef/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java index 6828218..4a69887 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/database/InlineIndexHelperTest.java @@ -207,7 +207,7 @@ public class InlineIndexHelperTest extends GridCommonAbstractTest { InlineIndexHelper ih = new InlineIndexHelper(Value.STRING, 1, 0, CompareMode.getInstance(null, 0)); - ih.put(pageAddr, off, ValueString.get(v1), maxSize); + ih.put(pageAddr, off, v1 == null ? ValueNull.INSTANCE : ValueString.get(v1), maxSize); Comparator<Value> comp = new Comparator<Value>() { @Override public int compare(Value o1, Value o2) { @@ -215,7 +215,7 @@ public class InlineIndexHelperTest extends GridCommonAbstractTest { } }; - return ih.compare(pageAddr, off, maxSize, ValueString.get(v2), comp); + return ih.compare(pageAddr, off, maxSize, v2 == null ? ValueNull.INSTANCE : ValueString.get(v2), comp); } finally { if (page != 0L) @@ -378,6 +378,10 @@ public class InlineIndexHelperTest extends GridCommonAbstractTest { /** */ public void testNull() throws Exception { testPutGet(ValueInt.get(-1), ValueNull.INSTANCE, ValueInt.get(3)); + testPutGet(ValueInt.get(-1), ValueNull.INSTANCE, ValueInt.get(3)); + + int maxSize = 3 + 2; // 2 ascii chars + 3 bytes header. + assertEquals(1, putAndCompare("aa", null, maxSize)); } /** */
