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) { } catch (final Exception ee) {
log.warn("Unable to auto-logout: ", ee.getMessage()); log.warn("Unable to auto-logout: ", ee.getMessage());
} }
return true; return false;
} }
} }
@Override @Override
public Boolean apply(final Exception error) { public Boolean apply(final Exception error) {
this.errors++; 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) { if (this.errors > 5) {
checkUserSession(); checkUserSession();
} }

View file

@ -241,7 +241,9 @@ public class ExamSessionServiceImpl implements ExamSessionService {
flushCache(exam); 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( return Result.ofError(new NoSuchElementException(
"No currently running exam found for id: " + examId)); "No currently running exam found for id: " + examId));

View file

@ -329,7 +329,7 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic
if (StringUtils.isNoneBlank(clientAddress) && if (StringUtils.isNoneBlank(clientAddress) &&
StringUtils.isNotBlank(clientConnection.clientAddress) && StringUtils.isNotBlank(clientConnection.clientAddress) &&
!clientAddress.equals(clientConnection.clientAddress)) { !clientAddress.equals(clientConnection.clientAddress)) {
log.error( log.warn(
"ClientConnection integrity violation: client address mismatch: {}, {}", "ClientConnection integrity violation: client address mismatch: {}, {}",
clientAddress, clientAddress,
clientConnection.clientAddress); clientConnection.clientAddress);
@ -337,7 +337,7 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic
"ClientConnection integrity violation: client address mismatch"); "ClientConnection integrity violation: client address mismatch");
} }
} else if (!clientConnection.status.clientActiveStatus) { } 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); clientConnection);
throw new IllegalArgumentException( throw new IllegalArgumentException(
"ClientConnection integrity violation: client connection is not in expected state"); "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) this.clientEventDAO.getPendingNotificationByValue(clientConnection.id, notificationId)
.flatMap(notification -> this.clientEventDAO.confirmPendingNotification(notification.id)) .flatMap(notification -> this.clientEventDAO.confirmPendingNotification(notification.id))
.map(this::removeFromCache) .map(this::removeFromCache)
.onError(error -> log.error("Failed to confirm pending notification: {}", event, error)); .getOrThrow();
} catch (final Exception e) { } catch (final Exception e) {
log.error( log.error(
@ -110,8 +110,7 @@ public class SEBClientNotificationServiceImpl implements SEBClientNotificationSe
return this.clientEventDAO.getPendingNotification(notificationId) return this.clientEventDAO.getPendingNotification(notificationId)
.map(notification -> this.confirmClientSide(notification, examId, connectionToken)) .map(notification -> this.confirmClientSide(notification, examId, connectionToken))
.flatMap(notification -> this.clientEventDAO.confirmPendingNotification(notificationId)) .flatMap(notification -> this.clientEventDAO.confirmPendingNotification(notificationId))
.map(this::removeFromCache) .map(this::removeFromCache);
.onError(error -> log.error("Failed to confirm pending notification: {}", notificationId, error));
} }
@Override @Override

View file

@ -149,6 +149,15 @@ public class APIExceptionHandler extends ResponseEntityExceptionHandler {
HttpStatus.BAD_REQUEST); 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) @ExceptionHandler(ResourceNotFoundException.class)
public ResponseEntity<Object> handleResourceNotFoundException( public ResponseEntity<Object> handleResourceNotFoundException(
final ResourceNotFoundException ex, final ResourceNotFoundException ex,
@ -182,7 +191,7 @@ public class APIExceptionHandler extends ResponseEntityExceptionHandler {
final ExamNotRunningException ex, final ExamNotRunningException ex,
final WebRequest request) { final WebRequest request) {
log.info("{}", ex.getMessage()); log.debug("{}", ex.getMessage());
return APIMessage.ErrorMessage.INTEGRITY_VALIDATION return APIMessage.ErrorMessage.INTEGRITY_VALIDATION
.createErrorResponse(ex.getMessage()); .createErrorResponse(ex.getMessage());
} }

View file

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

View file

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