Skip to content

Commit a847396

Browse files
committed
We used to handle 501 before we moved to java-http because we had to parse the http verb into a servlet enum.
We can now handle any value w/out explosion, but we still only map out standard methods in the DefaultActionConfigurationBuilder. So this is just to fix the error to be more accurate, which is what we used to do.
1 parent 86e44bc commit a847396

4 files changed

Lines changed: 18 additions & 5 deletions

File tree

build.savant

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ logbackVersion = "1.5.13"
2929
slf4jVersion = "2.0.13"
3030
testngVersion = "7.8.0"
3131

32-
project(group: "org.primeframework", name: "prime-mvc", version: "5.2.0", licenses: ["ApacheV2_0"]) {
32+
project(group: "org.primeframework", name: "prime-mvc", version: "5.3.0", licenses: ["ApacheV2_0"]) {
3333
workflow {
3434
fetch {
3535
// Dependency resolution order:

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>org.primeframework</groupId>
77
<artifactId>prime-mvc</artifactId>
8-
<version>5.1.1</version>
8+
<version>5.3.0</version>
99
<packaging>jar</packaging>
1010

1111
<name>FusionAuth App</name>

src/main/java/org/primeframework/mvc/action/DefaultActionMappingWorkflow.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001-2024, Inversoft Inc., All Rights Reserved
2+
* Copyright (c) 2001-2025, Inversoft Inc., All Rights Reserved
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
import io.fusionauth.http.server.HTTPRequest;
2828
import io.fusionauth.http.server.HTTPResponse;
2929
import org.primeframework.mvc.NotAllowedException;
30+
import org.primeframework.mvc.NotImplementedException;
3031
import org.primeframework.mvc.http.HTTPTools;
3132
import org.primeframework.mvc.http.Status;
3233
import org.primeframework.mvc.parameter.fileupload.annotation.FileUpload;
@@ -93,7 +94,15 @@ public void perform(WorkflowChain chain) throws IOException {
9394
if (actionInvocation.action != null && actionInvocation.method == null) {
9495
Class<?> actionClass = actionInvocation.configuration.actionClass;
9596
logger.debug("The action class [{}] does not have a valid execute method for the HTTP method [{}]", actionClass.getCanonicalName(), method);
96-
throw new NotAllowedException();
97+
98+
// Differentiate between not allowed for this action, vs no-implemented (supported by prime-mvc).
99+
if (HTTPMethod.StandardMethods.containsKey(method.name())) {
100+
throw new NotAllowedException();
101+
}
102+
103+
// Note that the DefaultActionConfigurationBuilder will only resolve executeMethods for methods named in StandardMethods.
104+
// See HTTPMethod.StandardMethods and DefaultActionConfigurationBuilder.findExecuteMethods
105+
throw new NotImplementedException();
97106
}
98107

99108
// Handle multipart file configuration

src/test/java/org/primeframework/mvc/GlobalTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,11 @@ public void notAllowed() {
14651465
public void notImplemented() {
14661466
simulator.test("/not-allowed")
14671467
.method("POTATO")
1468-
.assertStatusCode(405) // Not allowed since we can handle any name but the action doesn't have that method
1468+
// We currently only map out execute methods in the action that are named by a method
1469+
// defined in the HTTPMethod.StandardMethods. If an action does not define a standard HTTP
1470+
// method, a 405 will be returned. If you ask for a non-standard method that is not implemented
1471+
// by prime-mvc, you will receive a 501.
1472+
.assertStatusCode(501)
14691473
.assertHeaderContains("Cache-Control", "no-cache");
14701474
}
14711475

0 commit comments

Comments
 (0)