I am sorry let me rephrase this question. We can successfully put the key with null attributes, however we cannot search and remove by partial key using the null value. For example we want to remove all keys with a particular attribute as null. Here is the stack trace that we have
Code:
12:52:47,188 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/cf-test-webapp].[CacheServlet]] (http-/127.0.0.1:9080-1) JBWEB000236: Servlet.se
ice() for servlet CacheServlet threw exception: java.lang.NullPointerException
at net.sf.ehcache.search.expression.EqualTo.<init>(EqualTo.java:45) [ehcache-2.7.2.jar:2.7.2]
at net.sf.ehcache.search.Attribute.eq(Attribute.java:158) [ehcache-2.7.2.jar:2.7.2]
at com.MyApp.cache.EhCacheImpl.removeByMatchingKeyAttributes(EhCacheImpl.java:135) [optum-hie-framework-0.9.8.jar:]
at com.test.CacheServlet.doGet(CacheServlet.java:277) [classes:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.2.0.Final-redhat-1.jar:7.2.0.Final-redhat-1]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:322) [spring-security-web-3.1.1.RELEASE.jar:3.1.1.RELEASE
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116) [spring-security-web-3.1.1.RELEASE.jar
.1.1.RELEASE]
Is this some limitation imposed or is there any reason for disallowing this. As ehcache code is implemented this way to throw NPE if the attribute value is null.
Code:
public EqualTo(String attributeName, Object value) {
if (value == null || attributeName == null) {
throw new NullPointerException();
}
this.attributeName = attributeName;
this.value = value;
this.type = AttributeType.typeFor(attributeName, value);
}