Browse Source
把脏数据的逻辑修改后,导致即便只是锁住、没权限也会出现这个问题。 所以,这里添加一个检测链,前一个检测后,后一个才能继续检测。 并在对具体的类型检测时,保持原来的逻辑release/11.0
Harrison
2 years ago
5 changed files with 132 additions and 15 deletions
@ -0,0 +1,46 @@
|
||||
package com.fr.env.detect.impl; |
||||
|
||||
import com.fr.env.detect.base.ExceptionDetector; |
||||
import com.fr.env.detect.bean.DetectorResult; |
||||
import com.fr.env.detect.bean.DetectorStatus; |
||||
import org.jetbrains.annotations.Nullable; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* 检测链 |
||||
* 责任链模式, 有先后顺序,哪一个先获得,哪一个先终止。 |
||||
* |
||||
* created by Harrison on 2022/06/16 |
||||
**/ |
||||
public class DetectorChain { |
||||
|
||||
private List<ExceptionDetector> detectors = new ArrayList<>(); |
||||
|
||||
public static DetectorChain construct(ExceptionDetector... detectors) { |
||||
|
||||
DetectorChain detectorChain = new DetectorChain(); |
||||
detectorChain.detectors = Arrays.stream(detectors).collect(Collectors.toList()); |
||||
return detectorChain; |
||||
} |
||||
|
||||
@Nullable |
||||
public DetectorResult detect() { |
||||
|
||||
for (ExceptionDetector detector : detectors) { |
||||
DetectorResult result = detector.detect(); |
||||
if (result != null && result.getStatus() == DetectorStatus.EXCEPTION) { |
||||
return result; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public List<ExceptionDetector> getDetectors() { |
||||
|
||||
return this.detectors; |
||||
} |
||||
} |
Loading…
Reference in new issue