Skip to content

Commit 0fa284e

Browse files
author
Maciej Zasada
committed
Merge branch 'master' into DATACOUCH-27
Conflicts: .gitignore
2 parents c62ad42 + 270f573 commit 0fa284e

File tree

4 files changed

+27
-20
lines changed

4 files changed

+27
-20
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ target/
55
.project
66
.settings/*
77

8-
# IntelliJ IDEA
98
*.iml
10-
.idea
9+
.idea/*

pom.xml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
</parent>
1919

2020
<properties>
21-
<couchbase>1.1.9</couchbase>
22-
<jackson>2.2.2</jackson>
21+
<couchbase>1.2.0</couchbase>
22+
<jackson>2.2.3</jackson>
2323
<springdata.commons>1.6.1.RELEASE</springdata.commons>
2424
</properties>
2525

@@ -48,7 +48,7 @@
4848
</dependency>
4949

5050
<dependency>
51-
<groupId>couchbase</groupId>
51+
<groupId>com.couchbase.client</groupId>
5252
<artifactId>couchbase-client</artifactId>
5353
<version>${couchbase}</version>
5454
</dependency>
@@ -90,14 +90,6 @@
9090
</dependencies>
9191

9292
<repositories>
93-
<repository>
94-
<id>couchbase</id>
95-
<name>Couchbase Maven Repository</name>
96-
<url>http://files.couchbase.com/maven2/</url>
97-
<snapshots>
98-
<enabled>false</enabled>
99-
</snapshots>
100-
</repository>
10193
<repository>
10294
<id>spring-lib-release</id>
10395
<url>http://repo.springsource.org/libs-release-local</url>

src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseDocument.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public CouchbaseDocument(final String id, final int expiration) {
104104
* @return the {@link CouchbaseDocument} for chaining.
105105
*/
106106
public final CouchbaseDocument put(final String key, final Object value) {
107-
verifyValueType(value.getClass());
107+
verifyValueType(value);
108108

109109
payload.put(key, value);
110110
return this;
@@ -259,15 +259,19 @@ public CouchbaseDocument setId(String id) {
259259
* <p>If this is not the case, a {@link IllegalArgumentException} is
260260
* thrown.</p>
261261
*
262-
* @param clazz the class type to check and verify.
262+
* Objects that are NULL cannot be stored.
263+
*
264+
* @param value the object to verify its type.
263265
*/
264-
private void verifyValueType(final Class<?> clazz) {
266+
private void verifyValueType(final Object value) {
267+
if(value == null) {
268+
throw new IllegalArgumentException("Attribute of type null cannot be stored.");
269+
}
270+
final Class<?> clazz = value.getClass();
265271
if (simpleTypeHolder.isSimpleType(clazz)) {
266-
return;
272+
return;
267273
}
268-
269-
throw new IllegalArgumentException("Attribute of type "
270-
+ clazz.getCanonicalName() + " can not be stored and must be converted.");
274+
throw new IllegalArgumentException("Attribute of type " + clazz.getCanonicalName() + " cannot be stored and must be converted.");
271275
}
272276

273277
/**

src/test/java/org/springframework/data/couchbase/core/CouchbaseTemplateTests.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,18 @@ public void shouldLoadAndMapViewDocs() {
179179
assertNotNull(beer.getActive());
180180
}
181181
}
182+
183+
@Test
184+
public void shouldNotSaveNull() {
185+
final Map<String, String> things = new HashMap<String, String>();
186+
things.put("key", null);
187+
try {
188+
template.save(things);
189+
fail("We should not be able to store a NULL!");
190+
} catch(final IllegalArgumentException e) {
191+
assertTrue(true);
192+
}
193+
}
182194

183195
/**
184196
* A sample document with just an id and property.

0 commit comments

Comments
 (0)