Browse Source

REPORT-73833【设计器环境检测】本地目录,只有finedb异常,自动弹窗没弹

需要对使用后埋点。之前是使用的 Stream. 埋点后 Stream 流就不能用了。
这边换成 Collection 适配一下。
release/11.0
Harrison 2 years ago
parent
commit
d5840a8888
  1. 6
      designer-base/src/main/java/com/fr/env/detect/EnvDetectorCenter.java
  2. 13
      designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java
  3. 5
      designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java

6
designer-base/src/main/java/com/fr/env/detect/EnvDetectorCenter.java vendored

@ -151,7 +151,7 @@ public class EnvDetectorCenter {
if (!validAction.get()) { if (!validAction.get()) {
return; return;
} }
Stream<DetectorResult> resultStream = DetectorBridge.getInstance().detect(); Stream<DetectorResult> resultStream = DetectorBridge.getInstance().detect().stream();
// 展示效果 // 展示效果
NotificationDialogProperties properties = new NotificationDialogProperties(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Detect_Notification_Title")); NotificationDialogProperties properties = new NotificationDialogProperties(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Detect_Notification_Title"));
@ -196,7 +196,7 @@ public class EnvDetectorCenter {
*/ */
public List<DetectorResult> terminate(Throwable throwable) { public List<DetectorResult> terminate(Throwable throwable) {
Stream<DetectorResult> resultStream = DetectorBridge.getInstance().detect(throwable); Stream<DetectorResult> resultStream = DetectorBridge.getInstance().detect(throwable).stream();
return resultStream return resultStream
.filter((e) -> e.getStatus() == DetectorStatus.EXCEPTION) .filter((e) -> e.getStatus() == DetectorStatus.EXCEPTION)
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -209,7 +209,7 @@ public class EnvDetectorCenter {
*/ */
public List<DetectorResult> terminateUnexpectedly() { public List<DetectorResult> terminateUnexpectedly() {
Stream<DetectorResult> resultStream = DetectorBridge.getInstance().detect(); Stream<DetectorResult> resultStream = DetectorBridge.getInstance().detect().stream();
return resultStream return resultStream
.filter((e) -> e.getStatus() == DetectorStatus.EXCEPTION) .filter((e) -> e.getStatus() == DetectorStatus.EXCEPTION)
.collect(Collectors.toList()); .collect(Collectors.toList());

13
designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java vendored

@ -16,7 +16,9 @@ import com.fr.log.FineLoggerFactory;
import com.fr.value.NotNullLazyValue; import com.fr.value.NotNullLazyValue;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
/** /**
@ -128,9 +130,11 @@ public class DetectorBridge {
* *
* @return 能够检测出的异常情况 * @return 能够检测出的异常情况
*/ */
public Stream<DetectorResult> detect() { @NotNull
public Collection<DetectorResult> detect() {
return detectorManager.getValue().detect(); Stream<DetectorResult> results = detectorManager.getValue().detect();
return results.collect(Collectors.toList());
} }
/** /**
@ -141,10 +145,11 @@ public class DetectorBridge {
* @param throwable 异常 * @param throwable 异常
* @return 检测结果 * @return 检测结果
*/ */
public Stream<DetectorResult> detect(Throwable throwable) { @NotNull
public Collection<DetectorResult> detect(Throwable throwable) {
ThrowableStore.getInstance().add(throwable); ThrowableStore.getInstance().add(throwable);
Stream<DetectorResult> result = detect(); Collection<DetectorResult> result = detect();
ThrowableStore.getInstance().reset(); ThrowableStore.getInstance().reset();
return result; return result;

5
designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java

@ -28,12 +28,12 @@ import com.fr.stable.lifecycle.FineLifecycleFatalError;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import java.util.Collection;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* @author hades * @author hades
@ -88,8 +88,9 @@ public class LifecycleFatalErrorHandler {
@Override @Override
public void handle(FineLifecycleFatalError fatal) { public void handle(FineLifecycleFatalError fatal) {
Stream<DetectorResult> resultStream = DetectorBridge.getInstance().detect(fatal); Collection<DetectorResult> resultStream = DetectorBridge.getInstance().detect(fatal);
List<DetectorResult> results = resultStream List<DetectorResult> results = resultStream
.stream()
.filter((e) -> e.getStatus() == DetectorStatus.EXCEPTION) .filter((e) -> e.getStatus() == DetectorStatus.EXCEPTION)
.collect(Collectors.toList()); .collect(Collectors.toList());

Loading…
Cancel
Save