Skip to content

Commit

Permalink
ARTEMIS-4535 handle invalid filter gracefully
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Erwin Dondorp authored and jbertram committed Dec 21, 2023
1 parent 6cddc7f commit 3413aa6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 }));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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;
Expand Down Expand Up @@ -1639,7 +1640,10 @@ public CompositeData[] browse(int page, int pageSize, String filter) throws Exce
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());
}
Expand Down

0 comments on commit 3413aa6

Please sign in to comment.