aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2014-01-22 10:28:42 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2014-01-22 10:28:54 +0100
commit54e5359b2fcc258d2b7b4b1ec8f399ea4d9a3ff7 (patch)
tree5cfbe076351b521d796b739b93d106424c8310a7 /sonar-server
parent0285e6af2ea839968a3121afbbdf8c1e0e08fac1 (diff)
downloadsonarqube-54e5359b2fcc258d2b7b4b1ec8f399ea4d9a3ff7.tar.gz
sonarqube-54e5359b2fcc258d2b7b4b1ec8f399ea4d9a3ff7.zip
Fix conflict of Java web services with RoR development mode
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/ws/ServletResponse.java16
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/api/java_ws_controller.rb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/base.rb6
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/reloader.rb9
4 files changed, 20 insertions, 15 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/ws/ServletResponse.java b/sonar-server/src/main/java/org/sonar/server/ws/ServletResponse.java
index d5b001b2f57..0a2354f87b7 100644
--- a/sonar-server/src/main/java/org/sonar/server/ws/ServletResponse.java
+++ b/sonar-server/src/main/java/org/sonar/server/ws/ServletResponse.java
@@ -35,6 +35,7 @@ import java.io.StringWriter;
public class ServletResponse implements Response {
private final HttpServletResponse source;
+ private int httpStatus = 200;
public ServletResponse(HttpServletResponse hsr) {
this.source = hsr;
@@ -42,7 +43,7 @@ public class ServletResponse implements Response {
@Override
public JsonWriter newJsonWriter() {
- return JsonWriter.of(new Buffer(source));
+ return JsonWriter.of(new Buffer());
}
@Override
@@ -70,24 +71,19 @@ public class ServletResponse implements Response {
@Override
public Response setStatus(int httpStatus) {
- source.setStatus(httpStatus);
+ this.httpStatus = httpStatus;
return this;
}
- private static class Buffer extends StringWriter {
- private final HttpServletResponse httpResponse;
-
- public Buffer(HttpServletResponse httpResponse) {
- this.httpResponse = httpResponse;
- }
-
+ private class Buffer extends StringWriter {
@Override
public void close() throws IOException {
super.close();
+ source.setStatus(httpStatus);
ServletOutputStream stream = null;
try {
- stream = httpResponse.getOutputStream();
+ stream = source.getOutputStream();
IOUtils.copy(new ByteArrayInputStream(toString().getBytes(Charsets.UTF_8)), stream);
stream.flush();
} catch (IOException e) {
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/java_ws_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/java_ws_controller.rb
index 8ff82b92ebf..212c235297d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/java_ws_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/java_ws_controller.rb
@@ -41,7 +41,7 @@ class Api::JavaWsController < Api::ApiController
engine = Java::OrgSonarServerPlatform::Platform.component(Java::OrgSonarServerWs::WebServiceEngine.java_class)
engine.execute(ws_request, ws_response, params[:wspath], params[:wsaction])
- # response is already written to HttpServletResponse. No need to feed :text
- render :text => '', :status => ws_response.status(), :content_type => media_type
+ # response is already written to HttpServletResponse
+ render :nothing => true
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/base.rb b/sonar-server/src/main/webapp/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/base.rb
index 41a8a64ad26..144743f9914 100644
--- a/sonar-server/src/main/webapp/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/base.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/base.rb
@@ -972,7 +972,11 @@ module ActionController #:nodoc:
render_for_text(generator.to_s, options[:status])
elsif options[:nothing]
- render_for_text(nil, options[:status])
+ #sonar
+ # Java web services fully handle HTTP response (status and body). See java_ws_controller.rb.
+ @performed_render = true
+ #render_for_text(nil, options[:status])
+ #/sonar
else
render_for_file(default_template, options[:status], layout)
diff --git a/sonar-server/src/main/webapp/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/reloader.rb b/sonar-server/src/main/webapp/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/reloader.rb
index 709d88a37be..a6f77484ab1 100644
--- a/sonar-server/src/main/webapp/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/reloader.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/reloader.rb
@@ -28,7 +28,10 @@ module ActionController
end
def self.run(lock = @@default_lock)
- lock.lock
+ #sonar
+ # Development mode does not work with integration of Java web services (java_ws_controller.rb).
+ #lock.lock
+ #/sonar
begin
Dispatcher.reload_application
status, headers, body = yield
@@ -46,7 +49,9 @@ module ActionController
# run our cleanup code.
[status, headers, BodyWrapper.new(body, lock)]
rescue Exception
- lock.unlock
+ #sonar
+ #lock.unlock
+ #/sonar
raise
end
end