Merge branch 'dev-1.5' into development

This commit is contained in:
anhefti 2023-05-15 09:07:45 +02:00
commit bf6aa19a82
7 changed files with 25 additions and 12 deletions

View file

@ -56,14 +56,14 @@ public final class UpdateErrorHandler implements Function<Exception, Boolean> {
} catch (final Exception ee) {
log.warn("Unable to auto-logout: ", ee.getMessage());
}
return true;
return false;
}
}
@Override
public Boolean apply(final Exception error) {
this.errors++;
log.error("Failed to update server push: {}", error.getMessage(), error);
log.warn("Failed to update server push: {}", error.getMessage());
if (this.errors > 5) {
checkUserSession();
}

View file

@ -241,7 +241,9 @@ public class ExamSessionServiceImpl implements ExamSessionService {
flushCache(exam);
}
log.info("Exam {} is not currently running", examId);
if (log.isDebugEnabled()) {
log.info("Exam {} is not currently running", examId);
}
return Result.ofError(new NoSuchElementException(
"No currently running exam found for id: " + examId));

View file

@ -329,7 +329,7 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic
if (StringUtils.isNoneBlank(clientAddress) &&
StringUtils.isNotBlank(clientConnection.clientAddress) &&
!clientAddress.equals(clientConnection.clientAddress)) {
log.error(
log.warn(
"ClientConnection integrity violation: client address mismatch: {}, {}",
clientAddress,
clientConnection.clientAddress);
@ -337,7 +337,7 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic
"ClientConnection integrity violation: client address mismatch");
}
} else if (!clientConnection.status.clientActiveStatus) {
log.error("ClientConnection integrity violation: client connection is not in expected state: {}",
log.warn("ClientConnection integrity violation: client connection is not in expected state: {}",
clientConnection);
throw new IllegalArgumentException(
"ClientConnection integrity violation: client connection is not in expected state");

View file

@ -93,7 +93,7 @@ public class SEBClientNotificationServiceImpl implements SEBClientNotificationSe
this.clientEventDAO.getPendingNotificationByValue(clientConnection.id, notificationId)
.flatMap(notification -> this.clientEventDAO.confirmPendingNotification(notification.id))
.map(this::removeFromCache)
.onError(error -> log.error("Failed to confirm pending notification: {}", event, error));
.getOrThrow();
} catch (final Exception e) {
log.error(
@ -110,8 +110,7 @@ public class SEBClientNotificationServiceImpl implements SEBClientNotificationSe
return this.clientEventDAO.getPendingNotification(notificationId)
.map(notification -> this.confirmClientSide(notification, examId, connectionToken))
.flatMap(notification -> this.clientEventDAO.confirmPendingNotification(notificationId))
.map(this::removeFromCache)
.onError(error -> log.error("Failed to confirm pending notification: {}", notificationId, error));
.map(this::removeFromCache);
}
@Override

View file

@ -149,6 +149,15 @@ public class APIExceptionHandler extends ResponseEntityExceptionHandler {
HttpStatus.BAD_REQUEST);
}
@ExceptionHandler(IllegalArgumentException.class)
public ResponseEntity<Object> handleIllegalArgumentException(
final IllegalArgumentException ex,
final WebRequest request) {
log.warn("Illegal argument or state detected: {}\n send 400 Bad Request response", ex.getMessage());
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
@ExceptionHandler(ResourceNotFoundException.class)
public ResponseEntity<Object> handleResourceNotFoundException(
final ResourceNotFoundException ex,
@ -182,7 +191,7 @@ public class APIExceptionHandler extends ResponseEntityExceptionHandler {
final ExamNotRunningException ex,
final WebRequest request) {
log.info("{}", ex.getMessage());
log.debug("{}", ex.getMessage());
return APIMessage.ErrorMessage.INTEGRITY_VALIDATION
.createErrorResponse(ex.getMessage());
}

View file

@ -425,7 +425,10 @@ public class ExamMonitoringController {
notificationId,
examId,
connectionToken)
.getOrThrow();
.onError(error -> {
log.error("Failed to confirm pending notification: {} for exam {}, cause: {}",
notificationId, examId, error.getMessage());
});
}
@RequestMapping(

View file

@ -1578,7 +1578,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest {
fail("Exception expected here");
} catch (final Exception e) {
assertEquals("Unexpected error while rest call", e.getMessage());
assertEquals("argument \"content\" is null", e.getMessage());
}
// test follow-up integrity violation
@ -1596,7 +1596,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest {
fail("Exception expected here");
} catch (final Exception e) {
assertEquals("Unexpected error while rest call", e.getMessage());
assertEquals("argument \"content\" is null", e.getMessage());
}
final ConfigurationTableValues newTableValue = new ConfigurationTableValues(