fix: 发送通知时线程安全问题
This commit is contained in:
parent
e2808365ce
commit
63037ffb1c
|
@ -2,11 +2,12 @@ package io.metersphere.notice.domain;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class MessageDetail {
|
||||
public class MessageDetail implements Serializable {
|
||||
private List<String> userIds = new ArrayList<>();
|
||||
private String id;
|
||||
private String event;
|
||||
|
|
|
@ -4,12 +4,13 @@ import io.metersphere.notice.domain.Receiver;
|
|||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class NoticeModel {
|
||||
public class NoticeModel implements Serializable {
|
||||
/**
|
||||
* 保存 测试id
|
||||
*/
|
||||
|
|
|
@ -8,6 +8,7 @@ import io.metersphere.notice.domain.MessageDetail;
|
|||
import io.metersphere.notice.sender.AbstractNoticeSender;
|
||||
import io.metersphere.notice.sender.NoticeModel;
|
||||
import io.metersphere.notice.sender.impl.*;
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
@ -66,7 +67,9 @@ public class NoticeSendService {
|
|||
messageDetails.stream()
|
||||
.filter(messageDetail -> StringUtils.equals(messageDetail.getEvent(), noticeModel.getEvent()))
|
||||
.forEach(messageDetail -> {
|
||||
this.getNoticeSender(messageDetail).send(messageDetail, noticeModel);
|
||||
MessageDetail m = SerializationUtils.clone(messageDetail);
|
||||
NoticeModel n = SerializationUtils.clone(noticeModel);
|
||||
this.getNoticeSender(m).send(m, n);
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -102,7 +105,9 @@ public class NoticeSendService {
|
|||
messageDetails.stream()
|
||||
.filter(messageDetail -> StringUtils.equals(messageDetail.getEvent(), noticeModel.getEvent()))
|
||||
.forEach(messageDetail -> {
|
||||
this.getNoticeSender(messageDetail).send(messageDetail, noticeModel);
|
||||
MessageDetail m = SerializationUtils.clone(messageDetail);
|
||||
NoticeModel n = SerializationUtils.clone(noticeModel);
|
||||
this.getNoticeSender(m).send(m, n);
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -133,7 +138,9 @@ public class NoticeSendService {
|
|||
messageDetails.stream()
|
||||
.filter(messageDetail -> StringUtils.equals(messageDetail.getEvent(), noticeModel.getEvent()))
|
||||
.forEach(messageDetail -> {
|
||||
this.getNoticeSender(messageDetail).send(messageDetail, noticeModel);
|
||||
MessageDetail m = SerializationUtils.clone(messageDetail);
|
||||
NoticeModel n = SerializationUtils.clone(noticeModel);
|
||||
this.getNoticeSender(m).send(m, n);
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in New Issue