]> source.dussan.org Git - sonarqube.git/commitdiff
fix quality flaws (sort field can be null)
authorStephane Gamard <stephane.gamard@searchbox.com>
Tue, 1 Jul 2014 15:03:29 +0000 (17:03 +0200)
committerStephane Gamard <stephane.gamard@searchbox.com>
Tue, 1 Jul 2014 15:03:29 +0000 (17:03 +0200)
sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java

index 944576127be411ad93639a2f01864367bab4e6b4..06e3334574e2d13e24755f7fdffa559be87729cf 100644 (file)
@@ -234,13 +234,17 @@ public class SearchAction implements RequestHandler {
     query.setHasDebtCharacteristic(request.paramAsBoolean(PARAM_HAS_DEBT_CHARACTERISTIC));
     query.setActivation(request.paramAsBoolean(PARAM_ACTIVATION));
     query.setQProfileKey(request.param(PARAM_QPROFILE));
-    query.setSortField(RuleNormalizer.RuleField.of(request.param(SearchOptions.PARAM_SORT)));
-    query.setAscendingSort(request.mandatoryParamAsBoolean(SearchOptions.PARAM_ASCENDING));
     query.setTags(request.paramAsStrings(PARAM_TAGS));
     query.setInheritance(request.paramAsStrings(PARAM_INHERITANCE));
     query.setIsTemplate(request.paramAsBoolean(PARAM_IS_TEMPLATE));
     query.setTemplateKey(request.param(PARAM_TEMPLATE_KEY));
     query.setKey(request.param(PARAM_KEY));
+
+    String sortParam = request.param(SearchOptions.PARAM_SORT);
+    if (sortParam != null) {
+      query.setSortField(RuleNormalizer.RuleField.of(sortParam));
+      query.setAscendingSort(request.mandatoryParamAsBoolean(SearchOptions.PARAM_ASCENDING));
+    }
     return query;
   }