Skip to content

Commit

Permalink
Fix change in RestChannel
Browse files Browse the repository at this point in the history
`RestChannel` now has a parameter `detailedErrorsEnabled` which wasn't being passed in, causing a `NoSuchMethodError` if you try to run it with elasticsearch 1.5 (and a compile error if you tried to compile it).

See also elastic/elasticsearch#10117

Closes #30.
(cherry picked from commit 91445ef)
(cherry picked from commit 849a457)
  • Loading branch information
tstibbs authored and dadoonet committed Mar 29, 2015
1 parent c01a296 commit 596e434
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Expand Up @@ -33,8 +33,8 @@
*/
abstract class AbstractServletRestChannel extends RestChannel {

protected AbstractServletRestChannel(RestRequest request) {
super(request);
protected AbstractServletRestChannel(RestRequest request, boolean detailedErrorsEnabled) {
super(request, detailedErrorsEnabled);
}

@Override
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/elasticsearch/wares/AsyncNodeServlet.java
Expand Up @@ -48,16 +48,17 @@ public void destroy() {
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
final AsyncContext asyncContext = req.startAsync();
ServletRestRequest request = new ServletRestRequest(req);
AsyncServletRestChannel channel = new AsyncServletRestChannel(request, asyncContext);
AsyncServletRestChannel channel = new AsyncServletRestChannel(request, asyncContext,
detailedErrorsEnabled);
restController.dispatchRequest(request, channel);
}

static class AsyncServletRestChannel extends AbstractServletRestChannel {

final AsyncContext asyncContext;

AsyncServletRestChannel(RestRequest restRequest, AsyncContext asyncContext) {
super(restRequest);
AsyncServletRestChannel(RestRequest restRequest, AsyncContext asyncContext, boolean detailedErrorsEnabled) {
super(restRequest, detailedErrorsEnabled);
this.asyncContext = asyncContext;
}

Expand Down
12 changes: 8 additions & 4 deletions src/main/java/org/elasticsearch/wares/NodeServlet.java
Expand Up @@ -20,6 +20,7 @@
package org.elasticsearch.wares;

import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.http.netty.NettyHttpServerTransport;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.node.internal.InternalNode;
Expand Down Expand Up @@ -53,6 +54,8 @@ public class NodeServlet extends HttpServlet {
protected Node node;

protected RestController restController;

protected boolean detailedErrorsEnabled;

@Override
public void init() throws ServletException {
Expand Down Expand Up @@ -111,7 +114,8 @@ public void init() throws ServletException {
getServletContext().log("Using pre-initialized elasticsearch Node '" + getServletName() + "'");
this.node = (InternalNode) nodeAttribute;
}
restController = ((InternalNode) node).injector().getInstance(RestController.class);
restController = ((InternalNode) node).injector().getInstance(RestController.class);
detailedErrorsEnabled = this.node.settings().getAsBoolean(NettyHttpServerTransport.SETTING_HTTP_DETAILED_ERRORS_ENABLED, true);
}

@Override
Expand All @@ -125,7 +129,7 @@ public void destroy() {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
ServletRestRequest request = new ServletRestRequest(req);
ServletRestChannel channel = new ServletRestChannel(request, resp);
ServletRestChannel channel = new ServletRestChannel(request, resp, this.detailedErrorsEnabled);
try {
restController.dispatchRequest(request, channel);
channel.latch.await();
Expand All @@ -145,8 +149,8 @@ static class ServletRestChannel extends AbstractServletRestChannel {

IOException sendFailure;

ServletRestChannel(RestRequest restRequest, HttpServletResponse resp) {
super(restRequest);
ServletRestChannel(RestRequest restRequest, HttpServletResponse resp, boolean detailedErrorsEnabled) {
super(restRequest, detailedErrorsEnabled);
this.resp = resp;
this.latch = new CountDownLatch(1);
}
Expand Down

0 comments on commit 596e434

Please sign in to comment.