Merge pull request #225 from xuing/master

修复某些情况下ContextHolder的NPE异常
This commit is contained in:
芋道源码 2023-03-11 10:12:38 +08:00 committed by GitHub
commit d430f6cb26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -539,11 +539,11 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
/**
* {@link MappedStatement} 对应的规则
*/
private static final ThreadLocal<List<DataPermissionRule>> RULES = new TransmittableThreadLocal<>();
private static final ThreadLocal<List<DataPermissionRule>> RULES = ThreadLocal.withInitial(Collections::emptyList);
/**
* SQL 是否进行重写
*/
private static final ThreadLocal<Boolean> REWRITE = new TransmittableThreadLocal<>();
private static final ThreadLocal<Boolean> REWRITE = ThreadLocal.withInitial(() -> Boolean.FALSE);
public static void init(List<DataPermissionRule> rules) {
RULES.set(rules);