ARTEMIS-4535 handle invalid filter gracefully

This commit does the following:

 - prevents a large stack trace when the user-supplied message filter
   has errors
 - improves feedback to user for filter-validity
 - indents the search-field in the "Browse Queue" screen same as on
   other screens
 - fixes a spelling error in a nearby comment
This commit is contained in:
Erwin Dondorp 2023-12-15 12:05:34 +01:00 committed by Justin Bertram
parent 6cddc7f5fa
commit 3413aa6991
No known key found for this signature in database
GPG Key ID: F41830B875BB8633
2 changed files with 10 additions and 6 deletions

View File

@ -32,7 +32,7 @@ var Artemis;
<div class="col-sm-20">
<form class="toolbar-pf-actions">
<div class="form-group toolbar-pf-filter">
<div class="input-group">
<div class="input-group" style="padding-left: 10px">
<input type="text" class="form-control" ng-model="$ctrl.filter" placeholder="Filter..." autocomplete="off" id="filterInput">
<div class="input-group-btn">
<button class="btn btn-link btn-find" ng-click="$ctrl.refresh()" type="button">
@ -688,7 +688,7 @@ var Artemis;
ctrl.dlq = ctrl.dlq || (message['StringProperties'] ? (message['StringProperties']['_AMQ_ORIG_QUEUE'] ? true : (message['StringProperties']['extraProperties._AMQ_ORIG_QUEUE'] ? true : false)) : false);
message.bodyText = createBodyText(message);
if (idx == 0 && !ctrl.loadPrevousPage) {
//always load n the first message for paination when viewing message details
//always load n the first message for pagination when viewing message details
ctrl.currentMessage = message;
ctrl.currentMessage.headers = createHeaders(ctrl.currentMessage)
ctrl.currentMessage.properties = createProperties(ctrl.currentMessage);
@ -893,12 +893,12 @@ var Artemis;
if (ctrl.objName) {
//make sure to count only filtered messages
if (ctrl.filter) {
jolokia.request({ type: 'exec', mbean: ctrl.objName, operation: 'countMessages(java.lang.String)', arguments: [ctrl.filter] }, Core.onSuccess(function(response) { ctrl.pagination.page(response.value); }));
jolokia.request({ type: 'exec', mbean: ctrl.objName, operation: 'countMessages(java.lang.String)', arguments: [ctrl.filter] }, Core.onSuccess(function(response) { ctrl.pagination.page(response.value); }, { error: onError }));
} else {
jolokia.request({ type: 'exec', mbean: ctrl.objName, operation: 'countMessages()'}, Core.onSuccess(function(response) { ctrl.pagination.page(response.value); }));
jolokia.request({ type: 'exec', mbean: ctrl.objName, operation: 'countMessages()'}, Core.onSuccess(function(response) { ctrl.pagination.page(response.value); }, { error: onError }));
}
jolokia.request({ type: 'exec', mbean: ctrl.objName, operation: 'browse(int, int, java.lang.String)', arguments: [ctrl.pagination.pageNumber, ctrl.pagination.pageSize, ctrl.filter] }, Core.onSuccess(populateTable));
jolokia.request({ type: 'exec', mbean: ctrl.objName, operation: 'browse(int, int, java.lang.String)', arguments: [ctrl.pagination.pageNumber, ctrl.pagination.pageSize, ctrl.filter] }, Core.onSuccess(populateTable, { error: onError }));
}
}

View File

@ -29,6 +29,7 @@ import java.util.Map;
import java.util.NoSuchElementException;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.ActiveMQInvalidFilterExpressionException;
import org.apache.activemq.artemis.api.core.JsonUtil;
import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.SimpleString;
@ -1639,7 +1640,10 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
return rc;
}
} catch (Exception e) {
logger.warn(e.getMessage(), e);
if (!(e instanceof ActiveMQInvalidFilterExpressionException)) {
// only log when not caused by user input
logger.warn(e.getMessage(), e);
}
if (AuditLogger.isResourceLoggingEnabled()) {
AuditLogger.browseMessagesFailure(queue.getName().toString());
}