Skip to content

cache.put("key",null) fails [DATACOUCH-628] #939

Closed
@spring-projects-issues

Description

@spring-projects-issues

achoice opened DATACOUCH-628 and commented

Caching of null values fail with exception thrown by Couchbase client.

CouchbaseCacheConfiguration.defaultCacheConfig() seems that null valus should be cachable. https://github.com/spring-projects/spring-data-couchbase/blob/master/src/main/java/org/springframework/data/couchbase/cache/CouchbaseCacheConfiguration.java#L54

 

@Test
public void cacheNull() {
    final String CACHE_NAME = "CACHE_TEST";
    
    final CouchbaseCacheConfiguration defaultCacheConfig = CouchbaseCacheConfiguration.defaultCacheConfig();
    assertTrue(defaultCacheConfig.getAllowCacheNullValues()); // expect null values to be cachable now

    final CouchbaseCacheManager cacheManager = CouchbaseCacheManager
            .builder(couchbaseClientFactory)
            .cacheDefaults(defaultCacheConfig)
            .initialCacheNames(Set.of(CACHE_NAME))
            .build();
    cacheManager.afterPropertiesSet();

    // TEST cache null
    final Cache cache = cacheManager.getCache(CACHE_NAME);
    cache.put("KEY", null); // exception thrown by couchbase client
}

 


Affects: 4.0.4 (Neumann SR4)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions