!99 优化隐式流程里的异常会导致主流程里的异常发生时,记录隐式流程异常信息
Merge pull request !99 from zendwang/dev
This commit is contained in:
commit
4b9825de21
|
@ -248,7 +248,7 @@ public class FlowExecutor {
|
|||
Object param,
|
||||
Integer slotIndex, InnerChainTypeEnum innerChainType) {
|
||||
Slot slot = doExecute(chainId, param, null, null, slotIndex, innerChainType);
|
||||
return LiteflowResponse.newInnerResponse(slot);
|
||||
return LiteflowResponse.newInnerResponse(chainId, slot);
|
||||
}
|
||||
|
||||
private Slot doExecute(String chainId,
|
||||
|
@ -288,7 +288,7 @@ public class FlowExecutor {
|
|||
//我知道这在多线程调用隐式流程中会有问题。但是考虑到这种场景的不会多,也有其他的转换方式。
|
||||
//所以暂且这么做,以后再优化
|
||||
if (!innerChainType.equals(InnerChainTypeEnum.NONE)){
|
||||
slot.removeSubException();
|
||||
slot.removeSubException(chainId);
|
||||
slot.addSubChain(chainId);
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ public class FlowExecutor {
|
|||
if (innerChainType.equals(InnerChainTypeEnum.NONE)) {
|
||||
slot.setException(e);
|
||||
}else{
|
||||
slot.setSubException(e);
|
||||
slot.setSubException(chainId, e);
|
||||
}
|
||||
} finally {
|
||||
if (innerChainType.equals(InnerChainTypeEnum.NONE)) {
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package com.yomahub.liteflow.flow;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import com.yomahub.liteflow.enums.InnerChainTypeEnum;
|
||||
import com.yomahub.liteflow.exception.LiteFlowException;
|
||||
import com.yomahub.liteflow.flow.entity.CmpStep;
|
||||
import com.yomahub.liteflow.slot.Slot;
|
||||
|
@ -37,8 +34,8 @@ public class LiteflowResponse implements Serializable {
|
|||
return newResponse(slot, slot.getException());
|
||||
}
|
||||
|
||||
public static LiteflowResponse newInnerResponse(Slot slot){
|
||||
return newResponse(slot, slot.getSubException());
|
||||
public static LiteflowResponse newInnerResponse(String chainId, Slot slot){
|
||||
return newResponse(slot, slot.getSubException(chainId));
|
||||
}
|
||||
|
||||
private static LiteflowResponse newResponse(Slot slot, Exception e){
|
||||
|
|
|
@ -90,7 +90,7 @@ public class Chain implements Executable {
|
|||
}catch (Exception e){
|
||||
//这里事先取到exception set到slot里,为了方便finally取到exception
|
||||
if (slot.isSubChain(chainName)){
|
||||
slot.setSubException(e);
|
||||
slot.setSubException(chainName, e);
|
||||
}else{
|
||||
slot.setException(e);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
package com.yomahub.liteflow.slot;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.collection.ConcurrentHashSet;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
@ -18,7 +17,11 @@ import com.yomahub.liteflow.flow.id.IdGeneratorHolder;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Deque;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
@ -53,7 +56,7 @@ public class Slot{
|
|||
|
||||
private static final String EXCEPTION = "_exception";
|
||||
|
||||
private static final String SUB_EXCEPTION = "_sub_exception";
|
||||
private static final String SUB_EXCEPTION_PREFIX = "_sub_exception_";
|
||||
|
||||
private static final String PRIVATE_DELIVERY_PREFIX = "_private_d_";
|
||||
|
||||
|
@ -264,16 +267,16 @@ public class Slot{
|
|||
putMetaDataMap(EXCEPTION, e);
|
||||
}
|
||||
|
||||
public Exception getSubException() {
|
||||
return (Exception) this.metaDataMap.get(SUB_EXCEPTION);
|
||||
public Exception getSubException(String chainId) {
|
||||
return (Exception) this.metaDataMap.get(SUB_EXCEPTION_PREFIX + chainId);
|
||||
}
|
||||
|
||||
public void setSubException(Exception e) {
|
||||
putMetaDataMap(SUB_EXCEPTION, e);
|
||||
public void setSubException(String chainId, Exception e) {
|
||||
putMetaDataMap(SUB_EXCEPTION_PREFIX + chainId, e);
|
||||
}
|
||||
|
||||
public void removeSubException(){
|
||||
metaDataMap.remove(SUB_EXCEPTION);
|
||||
public void removeSubException(String chainId){
|
||||
metaDataMap.remove(SUB_EXCEPTION_PREFIX + chainId);
|
||||
}
|
||||
|
||||
public List<Object> getContextBeanList(){
|
||||
|
@ -294,14 +297,9 @@ public class Slot{
|
|||
}
|
||||
|
||||
public void addSubChain(String chainId){
|
||||
if (metaDataMap.containsKey(SUB_CHAIN)){
|
||||
Set<String> subChainSet = (Set<String>) metaDataMap.get(SUB_CHAIN);
|
||||
subChainSet.add(chainId);
|
||||
}else{
|
||||
Set<String> subChainSet = new ConcurrentHashSet<>();
|
||||
subChainSet.add(chainId);
|
||||
metaDataMap.put(SUB_CHAIN, subChainSet);
|
||||
}
|
||||
Set<String> subChainSet = (Set<String>) metaDataMap.getOrDefault(SUB_CHAIN, new ConcurrentHashSet<>());
|
||||
subChainSet.add(chainId);
|
||||
metaDataMap.putIfAbsent(SUB_CHAIN, subChainSet);
|
||||
}
|
||||
|
||||
public boolean isSubChain(String chainId){
|
||||
|
|
Loading…
Reference in New Issue