Skip to content

Commit

Permalink
Merge pull request #1023 from ZakarFin/handle-missing-data
Browse files Browse the repository at this point in the history
Remove unnecessary stack trace from logs
  • Loading branch information
ZakarFin authored Nov 7, 2023
2 parents 5a55a5c + d98509d commit 447472c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public void handleAction(ActionParameters ap) throws ActionException {
*/
public JSONObject getIndicatorMetadataJSON(User user, long pluginId, String indicatorId) throws ActionException {
StatisticalDatasourcePlugin plugin = pluginManager.getPlugin(pluginId);
if(plugin == null) {
if (plugin == null) {
throw new ActionParamsException("No such datasource: " + pluginId);
}
StatisticalIndicator indicator = plugin.getIndicator(user, indicatorId);
if(indicator == null) {
if (indicator == null) {
// indicator can be null if user doesn't have permission to it
throw new ActionParamsException("No such indicator: " + indicatorId + " on datasource: " + pluginId);
}
Expand All @@ -65,7 +65,7 @@ public JSONObject getIndicatorMetadataJSON(User user, long pluginId, String indi
}
try {
JSONObject indicatorMetadata = StatisticsHelper.toJSON(indicator);
// Note that there is an another layer of caches in the plugins doing the web queries.
// Note that there is another layer of caches in the plugins doing the web queries.
// Two layers are necessary, because deserialization and conversion to the internal data model
// is pretty heavy operation.
if (plugin.canCache() && indicatorMetadata != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,15 @@ public IndicatorSet getIndicatorSet(User user) {
public StatisticalIndicator getIndicator(User user, String indicatorId) {
try {
String json = JedisManager.get(getIndicatorMetadataKey(indicatorId));
if (json == null) {
// someone requested an indicator we don't know about
// client might have a saved ref to id that is no longer available OR
// someone is fishing for data with crafted urls
// either way, we don't need the stack trace from Jackson parsing a null value
return null;
}
StatisticalIndicator indicator = MAPPER.readValue(json, StatisticalIndicator.class);
if(hasPermission(indicator, user)) {
if (hasPermission(indicator, user)) {
// sort dimensions etc
try {
handleHints(indicator);
Expand Down

0 comments on commit 447472c

Please sign in to comment.