3. patch UZH

fix log spam (description), concurrent GUI calls using same hashmmap
This commit is contained in:
anhefti 2023-04-27 11:38:24 +02:00
parent d6c0e8810d
commit 56ad74dc25
4 changed files with 28 additions and 15 deletions

View file

@ -426,7 +426,7 @@ public final class Exam implements GrantEntity {
builder.append(", name="); builder.append(", name=");
builder.append(this.name); builder.append(this.name);
builder.append(", description="); builder.append(", description=");
builder.append(this.getDescription()); builder.append(Utils.truncateText(this.getDescription(), 255));
builder.append(", startTime="); builder.append(", startTime=");
builder.append(this.startTime); builder.append(this.startTime);
builder.append(", endTime="); builder.append(", endTime=");

View file

@ -821,6 +821,18 @@ public final class Utils {
return false; return false;
} }
public static boolean isEqualsWithEmptyCheckTruncated(final String s1, final String s2) {
if (s2 == null || s1 == null) {
return false;
}
if (s1.endsWith("...")) {
return Objects.equals(truncateText(s1, 1000), truncateText(s2, 1000));
} else {
return Objects.equals(s1, s2);
}
}
public static Long toLong(final String longValue) { public static Long toLong(final String longValue) {
try { try {
return Long.valueOf(longValue); return Long.valueOf(longValue);

View file

@ -467,15 +467,15 @@ public class ExamSessionServiceImpl implements ExamSessionService {
final Set<Long> connectionIds) { final Set<Long> connectionIds) {
this.duplicateCheck.clear(); this.duplicateCheck.clear();
this.duplicates.clear(); final Set<Long> duplicates = new HashSet<>();
return this.clientConnectionDAO return this.clientConnectionDAO
.getConnectionTokens(examId) .getConnectionTokens(examId)
.map(tokens -> tokens.stream() .map(tokens -> tokens.stream()
.map(this::getForTokenAndCheckDuplication) .map(token -> this.getForTokenAndCheckDuplication(token, duplicates))
.filter(ccd -> connectionIds.contains(ccd.clientConnection.id)) .filter(ccd -> connectionIds.contains(ccd.clientConnection.id))
.map(ccd -> ccd.clientStaticData) .map(ccd -> ccd.clientStaticData)
.collect(Collectors.toList())) .collect(Collectors.toList()))
.map(staticData -> new MonitoringStaticClientData(staticData, this.duplicates)); .map(staticData -> new MonitoringStaticClientData(staticData, duplicates));
} }
@Override @Override
@ -633,17 +633,19 @@ public class ExamSessionServiceImpl implements ExamSessionService {
} }
private final Map<String, Long> duplicateCheck = new HashMap<>(); private final Map<String, Long> duplicateCheck = new HashMap<>();
private final Set<Long> duplicates = new HashSet<>();
private ClientConnectionDataInternal getForTokenAndCheckDuplication(final String token) { private ClientConnectionDataInternal getForTokenAndCheckDuplication(
final String token,
final Set<Long> duplicates) {
final ClientConnectionDataInternal cc = this.examSessionCacheService.getClientConnection(token); final ClientConnectionDataInternal cc = this.examSessionCacheService.getClientConnection(token);
if (cc.clientConnection.status.duplicateCheckStatus) { if (cc.clientConnection.status.duplicateCheckStatus) {
final Long id = this.duplicateCheck.put( final Long id = this.duplicateCheck.put(
cc.clientConnection.userSessionId, cc.clientConnection.userSessionId,
cc.getConnectionId()); cc.getConnectionId());
if (id != null) { if (id != null) {
this.duplicates.add(id); duplicates.add(id);
this.duplicates.add(cc.getConnectionId()); duplicates.add(cc.getConnectionId());
} }
} }
return cc; return cc;

View file

@ -355,22 +355,21 @@ class ExamUpdateHandler {
if (!Utils.isEqualsWithEmptyCheck(exam.name, quizData.name) || if (!Utils.isEqualsWithEmptyCheck(exam.name, quizData.name) ||
!Objects.equals(exam.startTime, quizData.startTime) || !Objects.equals(exam.startTime, quizData.startTime) ||
!Objects.equals(exam.endTime, quizData.endTime) || !Objects.equals(exam.endTime, quizData.endTime) ||
!Utils.isEqualsWithEmptyCheck(exam.getDescription(), quizData.description) || !Utils.isEqualsWithEmptyCheckTruncated(exam.getDescription(), quizData.description) ||
!Utils.isEqualsWithEmptyCheck(exam.getStartURL(), quizData.startURL)) { !Utils.isEqualsWithEmptyCheck(exam.getStartURL(), quizData.startURL)) {
if (!Utils.isEqualsWithEmptyCheck(exam.name, quizData.name)) { if (!Utils.isEqualsWithEmptyCheck(exam.name, quizData.name)) {
log.info("Update name difference from LMS. Exam:{}, QuizData: {}", exam.name, quizData.name); log.info("Update name difference from LMS. Exam: {}, QuizData: {}", exam.name, quizData.name);
} }
if (!Objects.equals(exam.startTime, quizData.startTime)) { if (!Objects.equals(exam.startTime, quizData.startTime)) {
log.info("Update startTime difference from LMS. Exam:{}, QuizData: {}", exam.startTime, log.info("Update startTime difference from LMS. Exam: {}, QuizData: {}", exam.startTime,
quizData.startTime); quizData.startTime);
} }
if (!Objects.equals(exam.endTime, quizData.endTime)) { if (!Objects.equals(exam.endTime, quizData.endTime)) {
log.info("Update endTime difference from LMS. Exam:{}, QuizData: {}", exam.endTime, quizData.endTime); log.info("Update endTime difference from LMS. Exam: {}, QuizData: {}", exam.endTime, quizData.endTime);
} }
if (!Utils.isEqualsWithEmptyCheck(exam.getDescription(), quizData.description)) { if (!Utils.isEqualsWithEmptyCheckTruncated(exam.getDescription(), quizData.description)) {
log.info("Update description difference from LMS. Exam:{}, QuizData: {}", exam.getDescription(), log.info("Update description difference from LMS. Exam: {}", exam);
quizData.description);
} }
if (!Utils.isEqualsWithEmptyCheck(exam.getStartURL(), quizData.startURL)) { if (!Utils.isEqualsWithEmptyCheck(exam.getStartURL(), quizData.startURL)) {
log.info("Update startURL difference from LMS. Exam:{}, QuizData: {}", log.info("Update startURL difference from LMS. Exam:{}, QuizData: {}",