From 4a54633577e9fc36b01847cbb6b49b8c5e0e83ae Mon Sep 17 00:00:00 2001 From: leventov Date: Mon, 15 Dec 2014 22:49:53 +0700 Subject: [PATCH] ChronicleMapBuilder.defaultValue() shouldn't be null because ChronicleMap generally doesn't support neither null key nor null values --- .../chronicle/map/ChronicleMapBuilder.java | 4 +-- .../chronicle/map/NullValueProvider.java | 28 ------------------- 2 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 src/main/java/net/openhft/chronicle/map/NullValueProvider.java diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java index 1e33d9446..fe198c8b2 100755 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java @@ -940,10 +940,10 @@ public final class ChronicleMapBuilder implements Cloneable, * @see #prepareDefaultValueBytes(PrepareValueBytes) */ public ChronicleMapBuilder defaultValue(V defaultValue) { + if (defaultValue == null) + throw new IllegalArgumentException("default ChronicleMap value couldn't be null"); this.defaultValue = defaultValue; this.defaultValueProvider = null; - if (defaultValue == null) - defaultValueProvider = NullValueProvider.INSTANCE; this.prepareValueBytes = null; return this; } diff --git a/src/main/java/net/openhft/chronicle/map/NullValueProvider.java b/src/main/java/net/openhft/chronicle/map/NullValueProvider.java deleted file mode 100644 index 9e79889e8..000000000 --- a/src/main/java/net/openhft/chronicle/map/NullValueProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2014 Higher Frequency Trading - * - * http://www.higherfrequencytrading.com - * - * Licensed 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 net.openhft.chronicle.map; - -enum NullValueProvider implements DefaultValueProvider { - INSTANCE; - - @Override - public Object get(Object key) { - return null; - } -}