Redis fails to store a UDF

Description

When you try to store an UDF into Redis you get this exception

 

java.io.IOException: type [lucee.runtime.type.UDFImpl] cannot be converted to BSON yet! at lucee.extension.io.cache.util.BSON.toBsonValue(BSON.java:344) at lucee.extension.io.cache.util.BSON._toBsonDocumentStruct(BSON.java:374) at lucee.extension.io.cache.util.BSON.toBsonDocument(BSON.java:256) at lucee.extension.io.cache.util.Coder.serialize(Coder.java:123) at lucee.extension.io.cache.redis.RedisCache.put(RedisCache.java:405) at lucee.extension.io.cache.redis.RedisCache.access$100(RedisCache.java:37) at lucee.extension.io.cache.redis.RedisCache$Storage.run(RedisCache.java:995)

Environment

None

Activity

Show:

Julian Halliwell 13 May 2022 at 11:32

Actually we were getting this error from caching CFC instances, not structs containing UDFs, although perhaps Lucee sees them as similar things?

But I can confirm that you’ve fixed the issue now. Thanks! grinning face

Michael Offner 13 May 2022 at 08:10

stacktrace for 3.0.0.43-BETA

java.io.IOException: type [lucee.runtime.type.UDFImpl] cannot be converted to BSON yet! at lucee.extension.io.cache.util.BSON.toBsonValue(BSON.java:346) at lucee.extension.io.cache.util.BSON._toBsonDocumentStruct(BSON.java:376) at lucee.extension.io.cache.util.BSON.toBsonDocument(BSON.java:258) at lucee.extension.io.cache.util.Coder.serialize(Coder.java:123) at lucee.extension.io.cache.redis.RedisCache.put(RedisCache.java:406) at lucee.extension.io.cache.redis.RedisCache.access$100(RedisCache.java:37) at lucee.extension.io.cache.redis.RedisCache$Storage.run(RedisCache.java:958)

Michael Offner 13 May 2022 at 08:10

ok when converting to this (udf within a struct), i can reproduce the issue

 

function udfToStore() { } cacheput(id:"testsafeudf", value:{str:"string",udf:udfToStore}, cacheName:cacheName); dump(cacheget(id:"testsafeudf", cacheName:cacheName)); RedisCommand( arguments:["SET","testsafeudf2",{str:"string",udf:udfToStore}], cacheName:"distlock" ); dump(RedisCommand( arguments:["GET","testsafeudf2"], cacheName:"distlock" ));

Michael Offner 13 May 2022 at 08:04

Simply write and read a UDF works fine

 

function udfToStore() { } cacheput(id:"testsafeudf", value:udfToStore, cacheName:cacheName); dump(cacheget(id:"testsafeudf", cacheName:cacheName)); RedisCommand( arguments:["SET","testsafeudf2",udfToStore], cacheName:"distlock" ); dump(RedisCommand( arguments:["GET","testsafeudf2"], cacheName:"distlock" ));

and i see no exception in the log or in the console, testing with 3.0.0.43-BETA

Fixed

Details

Assignee

Reporter

Priority

Fix versions

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Created 13 May 2022 at 07:54
Updated 13 May 2022 at 11:41
Resolved 13 May 2022 at 11:41

Flag notifications