We sometimes get an NPE error from the RedisCache ...
# box-products
b
We sometimes get an NPE error from the RedisCache extension. We are using version:2.0.0-snapshot . The problem occurs with
queryExecute
while using the
cachedWithin
parameter I'll put the stacktrace in a reply.
lucee.runtime.exp.NativeException: java.lang.NullPointerException at ortus.extension.cache.redis.RedisCache.put(RedisCache.java:231) at lucee.runtime.cache.tag.timespan.TimespanCacheHandler.set(TimespanCacheHandler.java:90) at lucee.runtime.tag.Query._doEndTag(Query.java:734) at lucee.runtime.tag.Query.doEndTag(Query.java:565) at lucee.runtime.functions.query.QueryExecute.call(QueryExecute.java:86) at deviant.studiereader.service.classcodes_cfc$cf$7x.udfCall(/nl/deviant/studiereader/service/ClassCodes.cfc:230) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350) at lucee.runtime.type.UDFImpl.call(UDFImpl.java:223) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:697) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:585) at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1932) at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787) at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1765) at deviant.studiereader.service.users_cfc$cf$7y.udfCall1(/nl/deviant/studiereader/service/Users.cfc:77) at deviant.studiereader.service.users_cfc$cf$7y.udfCall(/nl/deviant/studiereader/service/Users.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350) at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:213) at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:804) at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:866) at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1784) at deviant.studiereader.service.users_cfc$cf$7y.udfCall1(/nl/deviant/studiereader/service/Users.cfc:32) at deviant.studiereader.service.users_cfc$cf$7y.udfCall(/nl/deviant/studiereader/service/Users.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350) at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:213) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:698) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:585) at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1951) at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:866) at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1784) at deviant.studiereader.service.results_cfc$cf$86.udfCall(/nl/deviant/studiereader/service/Results.cfc:34) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350) at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:213) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:698) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:585) at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1951) at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:866) at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1784) at deviant.studiereader.rest.schools_cfc$cf$8r.udfCall(/nl/deviant/studiereader/rest/Schools.cfc:84) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:112) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:350) at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:213) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:698) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:593) at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1960) at lucee.runtime.ComponentSpecificAccess.callWithNamedValues(ComponentSpecificAccess.java:156) at lucee.runtime.ComponentPageImpl._callRest(ComponentPageImpl.java:443) at lucee.runtime.ComponentPageImpl.callRest(ComponentPageImpl.java:361) at lucee.runtime.ComponentPageImpl.call(ComponentPageImpl.java:174) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1046) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:938) at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:219) at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:44) at lucee.runtime.PageContextImpl.executeRest(PageContextImpl.java:2398) at lucee.runtime.engine.Request.exe(Request.java:47) at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1198) at lucee.runtime.engine.CFMLEngineImpl.serviceRest(CFMLEngineImpl.java:1149) at lucee.loader.engine.CFMLEngineWrapper.serviceRest(CFMLEngineWrapper.java:112) at lucee.loader.servlet.RestServlet.service(RestServlet.java:51) at javax.servlet.http.HttpServlet.service(HttpServlet.java:590) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129) at org.cfmlprojects.regexpathinfofilter.RegexPathInfoFilter.doFilter(RegexPathInfoFilter.java:47) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at com.intergral.fusionreactor.j2ee.filterchain.WrappedFilterChain.doFilter(WrappedFilterChain.java:134) at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.doNext(FusionReactorRequestHandler.java:772) at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.doHttpServletRequest(FusionReactorRequestHandler.java:344) at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.doFusionRequest(FusionReactorRequestHandler.java:207) at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.handle(FusionReactorRequestHandler.java:809) at com.intergral.fusionreactor.j2ee.filter.FusionReactorCoreFilter.doFilter(FusionReactorCoreFilter.java:36) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at com.intergral.fusionreactor.j2ee.filterchain.WrappedFilterChain.doFilter(WrappedFilterChain.java:71) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at com.intergral.fusionreactor.agent.filter.FusionReactorStaticFilter.doFilter(FusionReactorStaticFilter.java:54) at com.intergral.fusionreactor.agent.pointcuts.NewFilterChainPointCut$1.invoke(NewFilterChainPointCut.java:42) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:117) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.SendErrorPageHandler.handleRequest(SendErrorPageHandler.java:52) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:275) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:79) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:134) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:131) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:255) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:79) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:100) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:387) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:852) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1423) at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1280) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.lang.NullPointerException ... 124 more
l
Thanks I'll look this up
Can you make sure you are using the latest snapshot please
ok, back in my office
checking your info
what is the offending cfml code?
ok, yes that’s the latest snapshot
That line is when it’s trying to get a connection from redis
so something did not allow it to get the connection
hmmm, for some reason, I can’t make lucee store cached queries in any external cache provider
this might be a bug in lucee
Copy code
q = queryExecute(
			"select * from types",
			{},
			{
				cachedwithin : createTimespan( 0, 0, 0, 30 ),
				cacheRegion : "sessions",
				cacheId : "queryTests"
			}
		);
If I do that, it works, that it tells me it caches, but it caches it in local ram
not external
@bdw429s ahve you seen this before
ok
finally made it work
had to restart
weird
FYI, using the
cacheRegion
as the param DOESN”T work
only if you use it in
Application.cfc
this.cache.query = 'name'
I will log a bug
Ok bug logged
b
the "offending code" would look something like this
Copy code
var sSql="
			select		b.id	as bookId
					  , b.title	as bookTitle
			  from		dbo.book as b
			 where		b.method_id = :methodId ; ";
	var stSqlParams={methodId: {value: arguments.methodId, cfsqltype: "INTEGER"}};
	var qGetBook=queryExecute(sSql, stSqlParams, {cachedWithin: CreateTimeSpan(1, 0, 0, 0)});
in out cfconfig.json file we have defined the QUERY cache as follows
Copy code
"cacheDefaultQuery": "QUERY",
"caches": {
    "QUERY": {
        "class": "ortus.extension.cache.redis.RedisCache",
        "custom": {
            "database": "15",
            "host": "x.x.x.x",
            "idleConnections": "5",
            "keyprefix": "${cfconfig_caches_QUERY_custom_keyprefix}",
            "maxConnections": "50",
            "password": "",
            "port": "6379",
            "timeout": "2000",
            "useSSL": "false"
        },
        "storage": "false"
    }
}
This works fine, but sometimes we get the afore mentioned error.
we run on lucee 5.3.9+146
In the application.log of lucee-web I found the following lines, which happend to be around the same time of the NPE
Copy code
"INFO","XNIO-1 task-2","08/05/2022","10:14:59","application","Creating Redis connection with the following arguments: {idleConnections={5}, maxConnections={50}, host={x.x.x.x}, keyprefix={userinfo}, useSSL={false}, password={}, database={13}, port={6379}, timeout={2000}}"
"INFO","XNIO-1 task-3","08/05/2022","10:14:59","application","Creating Redis connection with the following arguments: {idleConnections={5}, maxConnections={50}, host={x.x.x.x}, keyprefix={userinfo}, useSSL={false}, password={}, database={13}, port={6379}, timeout={2000}}"
"INFO","XNIO-1 task-4","08/05/2022","10:14:59","application","Creating Redis connection with the following arguments: {idleConnections={5}, maxConnections={50}, host={x.x.x.x}, keyprefix={userinfo}, useSSL={false}, password={}, database={13}, port={6379}, timeout={2000}}"
"INFO","XNIO-1 task-1","08/05/2022","10:14:59","application","Creating Redis connection with the following arguments: {idleConnections={5}, maxConnections={50}, host={x.x.x.x}, keyprefix={userinfo}, useSSL={false}, password={}, database={13}, port={6379}, timeout={2000}}"
"INFO","XNIO-1 task-1","08/05/2022","10:14:59","application","Redis Cache [userinfo] accepted, connection built and ready to rock"
"INFO","XNIO-1 task-2","08/05/2022","10:14:59","application","Redis Cache [userinfo] accepted, connection built and ready to rock"
"INFO","XNIO-1 task-3","08/05/2022","10:14:59","application","Redis Cache [userinfo] accepted, connection built and ready to rock"
"INFO","XNIO-1 task-4","08/05/2022","10:14:59","application","Redis Cache [userinfo] accepted, connection built and ready to rock"
also worth mentioning: the lucee service was just restarted