Fix #56
diff --git a/pom.xml b/pom.xml
index 632b83b..bf6c6b0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<name>Jackson-annotations</name>
- <version>2.5.3-SNAPSHOT</version>
+ <version>2.6.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<description>Core annotations used for value types, used by Jackson data binding package.
</description>
diff --git a/release-notes/VERSION b/release-notes/VERSION
index a3de549..e72bdec 100644
--- a/release-notes/VERSION
+++ b/release-notes/VERSION
@@ -11,6 +11,10 @@
=== Releases ===
------------------------------------------------------------------------
+2.6.0 (not yet released)
+
+#56: Improve `ObjectIdGenerators.key()` to handle `null` appropriately by returning `null`
+
2.5.0 (01-Jan-2015)
#47: Add `@JsonCreator.mode` property to explicitly choose between delegating-
diff --git a/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerator.java b/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerator.java
index 163fbfe..5897cd1 100644
--- a/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerator.java
+++ b/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerator.java
@@ -151,6 +151,9 @@
private final int hashCode;
public IdKey(Class<?> type, Class<?> scope, Object key) {
+ if (key == null) {
+ throw new IllegalArgumentException("Can not construct IdKey for null key");
+ }
this.type = type;
this.scope = scope;
this.key = key;
diff --git a/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerators.java b/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerators.java
index 516437f..6f9504b 100644
--- a/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerators.java
+++ b/src/main/java/com/fasterxml/jackson/annotation/ObjectIdGenerators.java
@@ -92,11 +92,19 @@
@Override
public IdKey key(Object key) {
+ // 02-Apr-2015, tatu: As per [annotations#56], should check for null
+ if (key == null) {
+ return null;
+ }
return new IdKey(getClass(), _scope, key);
}
@Override
public Integer generateId(Object forPojo) {
+ // 02-Apr-2015, tatu: As per [annotations#56], should check for null
+ if (forPojo == null) {
+ return null;
+ }
int id = _nextValue;
++_nextValue;
return id;
@@ -144,6 +152,10 @@
@Override
public IdKey key(Object key) {
+ // 02-Apr-2015, tatu: As per [annotations#56], should check for null
+ if (key == null) {
+ return null;
+ }
return new IdKey(getClass(), null, key);
}