aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-02-02 14:27:48 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-02-03 11:20:40 +0100
commitca87a168cf6b6dd8d58454afbb6ee298db6003c1 (patch)
tree3d33c9f8033ff4e0f10d8961742e0314fb689e0d
parentf0979eba6b50db708d54ab331a741980dd27a373 (diff)
downloadsonarqube-ca87a168cf6b6dd8d58454afbb6ee298db6003c1.tar.gz
sonarqube-ca87a168cf6b6dd8d58454afbb6ee298db6003c1.zip
SONAR-6584 WS api/resources/index limit number of measures and components
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/component/ws/ResourcesWs.java11
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb9
2 files changed, 14 insertions, 6 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ResourcesWs.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ResourcesWs.java
index 618cc39a526..ed2151a4070 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ResourcesWs.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ResourcesWs.java
@@ -44,11 +44,14 @@ public class ResourcesWs implements WebService {
.setDescription("Gets a list of components. Requires Browse permission on resource.<br>" +
"The web service is deprecated and you're invited to use the alternatives: " +
"<ul>" +
- "<li>if you need components only: api/components/tree</li>" +
- "<li>if you need components with measures: api/measures/component_tree</li>" +
+ "<li>if you need one component without measures: api/components/show</li>" +
+ "<li>if you need one component with measures: api/measures/component</li>" +
+ "<li>if you need several components without measures: api/components/tree</li>" +
+ "<li>if you need several components with measures: api/measures/component_tree</li>" +
"</ul>" +
- "When you provide one metric, the number of results is limited to 500. When several metrics are provided, the number of results is not limited. " +
- "This is a known limitation and it won't be fixed.")
+ "When you provide one metric, the number of results is limited to 500. When several metrics are provided, the number of measures is limited to 10000. " +
+ "The number of components is limited to 500." +
+ "This is a known limitation and it won't be fixed. You're invited to use the alternatives suggested above.")
.setSince("2.10")
.setDeprecatedSince("5.4")
.setHandler(RailsHandler.INSTANCE)
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb
index 64da4002f0c..45b650b7eae 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb
@@ -123,7 +123,8 @@ class Api::ResourcesController < Api::ApiController
measures_conditions=[]
measures_values={}
measures_order = nil
- measures_limit = nil
+ # SONAR-6584 avoid OOM errors
+ measures_limit = 10000
measures_by_sid={}
measures=nil
rules_by_id=nil
@@ -225,7 +226,11 @@ class Api::ResourcesController < Api::ApiController
snapshots_conditions << 'projects.qualifier in (:qualifiers)'
end
- snapshots_including_resource=Snapshot.all(:conditions => [snapshots_conditions.join(' AND '), snapshots_values], :include => 'project')
+ snapshots_including_resource=Snapshot.all(
+ :conditions => [snapshots_conditions.join(' AND '), snapshots_values],
+ :include => 'project',
+ # SONAR-6584 avoid OOM errors
+ :limit => 500)
# ---------- APPLY SECURITY - remove unauthorized resources - only if no selected resource
if @resource.nil?