{"record":{"id":"531ea39be7629dc9","repo":"redisson/redisson","slug":"expiration-max-idle-time-setting-can-t-be-non-zer-531ea3","errorCode":null,"errorMessage":".expiration.max_idle_time setting can't be non-zero","messagePattern":"\\.expiration\\.max_idle_time setting can't be non-zero","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"redisson-hibernate/redisson-hibernate-5/src/main/java/org/redisson/hibernate/RedissonRegionNativeFactory.java","lineNumber":51,"sourceCode":" */\npublic class RedissonRegionNativeFactory extends RedissonRegionFactory {\n\n    private static final long serialVersionUID = 4889779229712681692L;\n\n    @Override\n    public void start(SessionFactoryOptions settings, Properties properties) throws CacheException {\n        Set<Map.Entry<Object, Object>> entrySet = properties.entrySet();\n        for (Map.Entry<Object, Object> entry : entrySet) {\n            if (entry.getKey().toString().endsWith(RedissonRegionFactory.MAX_ENTRIES_SUFFIX)) {\n                Integer value = Integer.valueOf(entry.getValue().toString());\n                if (value > 0) {\n                    throw new IllegalArgumentException(\".eviction.max_entries setting can't be non-zero\");\n                }\n            }\n            if (entry.getKey().toString().endsWith(RedissonRegionFactory.MAX_IDLE_SUFFIX)) {\n                Integer value = Integer.valueOf(entry.getValue().toString());\n                if (value > 0) {\n                    throw new IllegalArgumentException(\".expiration.max_idle_time setting can't be non-zero\");\n                }\n            }\n        }\n        super.start(settings, properties);\n    }\n\n    @Override\n    protected RMapCache<Object, Object> getCache(String regionName, Properties properties, String defaultKey) {\n        RMapCacheNative<Object, Object> cache = redisson.getMapCacheNative(regionName);\n        return new MapCacheNativeWrapper<>(cache);\n    }\n    \n}\n","sourceCodeStart":33,"sourceCodeEnd":65,"githubUrl":"https://github.com/redisson/redisson/blob/91188987c2a9023e7fedabff758681ad9b107f25/redisson-hibernate/redisson-hibernate-5/src/main/java/org/redisson/hibernate/RedissonRegionNativeFactory.java#L33-L65","documentation":"Thrown by RedissonRegionNativeFactory.start (hibernate-5 native module) at startup when any cache property ending with the max-idle-time suffix (e.g. hibernate.cache.redisson.<region>.expiration.max_idle_time) is greater than 0. Native regions use Redis-native TTL/eviction, so per-region idle eviction configured client-side is rejected with IllegalArgumentException. (As with max_entries, the 'can't be non-zero' wording really means 'must not be positive'.)","triggerScenarios":"Starting a SessionFactory with RedissonRegionNativeFactory while any property key ending in .expiration.max_idle_time has a parsed Integer value > 0. The start() property-scan loop throws before the client is created.","commonSituations":"Copy-pasting cache properties from a RedissonRegionFactory setup (where max_idle_time is valid) into a config now using the native factory; keeping old region tuning when upgrading to the Redis 7 native cache module.","solutions":["Delete the hibernate.cache.redisson.<region>.expiration.max_idle_time entries (or set to 0) when using the native factory.","Rely on Redis server-side expiration policy (maxmemory-policy, key TTL) for idle-based eviction.","Switch to RedissonRegionFactory if per-region max_idle_time semantics are required.","Audit all *.expiration.max_idle_time keys across your configuration files — one positive value aborts startup."],"exampleFix":"# before\nhibernate.cache.region.factory_class=org.redisson.hibernate.RedissonRegionNativeFactory\nhibernate.cache.redisson.entity.Commodity.expiration.max_idle_time=900000\n\n# after\nhibernate.cache.region.factory_class=org.redisson.hibernate.RedissonRegionNativeFactory\n# (max_idle_time removed; TTL handled natively by Redis)","handlingStrategy":"validation","validationCode":"for (String key : hibernateProps.stringPropertyNames()) {\n    if (key.endsWith(\".expiration.max_idle_time\")\n            && Integer.parseInt(hibernateProps.getProperty(key)) > 0) {\n        throw new IllegalStateException(key + \" must be 0/unset for RedissonRegionNativeFactory\");\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Strip all *.expiration.max_idle_time entries when adopting the native factory.","Use Redis key TTL / maxmemory-policy for idle-eviction with native regions.","Add a config lint rule that rejects these keys whenever factory_class contains 'Native'."],"tags":["configuration","eviction","expiration","redis-7","hibernate","redisson"],"backgroundTag":null,"analyzedSha":"91188987c2a9023e7fedabff758681ad9b107f25","analyzedAt":"2026-08-14T11:39:42.619Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}