Skip to content

Commit 5e4f0c0

Browse files
committed
#1391 Improve log messaging for non-restful controller
1 parent 7ad5107 commit 5e4f0c0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

activeweb-testing/src/test/java/app/controllers/MyRestfulControllerSpec.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public void should_prevent_wrong_HTTP_method(){
2525
SystemStreamUtil.replaceOut();
2626
controller("/my_restful").post("index");
2727
the(statusCode()).shouldEqual(405);
28-
the(SystemStreamUtil.getSystemOut()).shouldContain("Cannot execute a non-restful action on a restful controller.");
28+
the(SystemStreamUtil.getSystemOut()).shouldContain("Cannot execute a non-restful action on a restful controller: app.controllers.MyRestfulController#index");
29+
the(SystemStreamUtil.getSystemOut()).shouldContain("app.controllers.MyRestfulController#index action does not support HTTP method: POST, returning status code 405.");
2930
SystemStreamUtil.restoreSystemOut();
3031
}
3132
}

activeweb/src/main/java/org/javalite/activeweb/Route.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ boolean actionSupportsHTTPMethod() {
169169
DirectResponse res = new DirectResponse("405 - Method not allowed");
170170
//see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
171171
res.setStatus(405);
172-
LOGGER.warn("Requested action does not support HTTP method: " + method.name() + ", returning status code 405.");
172+
LOGGER.warn("{} action does not support HTTP method: " + method.name() + ", returning status code 405.", getControllerClassName() + "#" + getActionName());
173173
RequestContext.setControllerResponse(res);
174174
//see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
175175
RequestContext.getHttpResponse().setHeader("Allow", join(allowedActions(), ", "));
@@ -227,7 +227,7 @@ private boolean restfulActionSupportsHttpMethod() {
227227
|| actionName.equals("options") && httpMethod.equals(HttpMethod.OPTIONS)) {
228228
return true;
229229
} else {
230-
LOGGER.warn("Cannot execute a non-restful action on a restful controller.");
230+
LOGGER.warn("Cannot execute a non-restful action on a restful controller: {}", controller.getClass().getName() + "#" + actionMethod.getName() );
231231
return false;
232232
}
233233
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy