fix: Avoid source clear
This commit is contained in:
@@ -12,6 +12,8 @@ public class SourceDetailResolveContext {
|
||||
|
||||
private static final ThreadLocal<Map<String, Map<String, Object>>> CONTEXT =
|
||||
ThreadLocal.withInitial(HashMap::new);
|
||||
private static final ThreadLocal<Integer> DEPTH =
|
||||
ThreadLocal.withInitial(() -> 0);
|
||||
|
||||
public static Map<String, Map<String, Object>> getSourceMap() {
|
||||
return CONTEXT.get();
|
||||
@@ -29,6 +31,20 @@ public class SourceDetailResolveContext {
|
||||
CONTEXT.get().put(sourceId, detail);
|
||||
}
|
||||
|
||||
public static void start() {
|
||||
DEPTH.set(DEPTH.get() + 1);
|
||||
}
|
||||
|
||||
public static void end() {
|
||||
int depth = DEPTH.get() - 1;
|
||||
if (depth <= 0) {
|
||||
clear();
|
||||
DEPTH.remove();
|
||||
} else {
|
||||
DEPTH.set(depth);
|
||||
}
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
CONTEXT.remove();
|
||||
}
|
||||
|
||||
@@ -655,6 +655,7 @@ public abstract class BaseResourceFieldService<T extends BaseResourceField, V ex
|
||||
if (CollectionUtils.isEmpty(resourceIds)) {
|
||||
return Map.of();
|
||||
}
|
||||
SourceDetailResolveContext.start();
|
||||
try {
|
||||
List<BaseField> flattenFormFields = Objects.requireNonNull(CommonBeanFactory.getBean(ModuleFormService.class)).
|
||||
getFlattenFormFields(getFormKey(), OrganizationContext.getOrganizationId());
|
||||
@@ -735,7 +736,7 @@ public abstract class BaseResourceFieldService<T extends BaseResourceField, V ex
|
||||
LogUtils.error(e);
|
||||
return null;
|
||||
} finally {
|
||||
SourceDetailResolveContext.clear();
|
||||
SourceDetailResolveContext.end();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user