Skip to content

Commit 6ee3281

Browse files
committed
jooby-apt: turn off Route.setMvcMethod and Route.setReturnType by default
- fix #3529
1 parent 6881b6a commit 6ee3281

File tree

8 files changed

+21
-9
lines changed

8 files changed

+21
-9
lines changed

docs/asciidoc/mvc-api.adoc

+5
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,11 @@ on them (mostly annotations processors).
912912
|string
913913
|[]
914914
|Add custom handler mapping.
915+
916+
|jooby.mvcMethod
917+
|boolean
918+
|false
919+
|Set the Route.mvcMethod when true.
915920
|===
916921

917922
==== Setting options

jooby/src/main/java/io/jooby/Route.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,8 @@ public boolean isTransactional(boolean defaultValue) {
10411041
}
10421042

10431043
/**
1044-
* Method for MVC/Controller. Not available for lambda routes.
1044+
* Method for MVC/Controller available when <code>jooby.mvcMethod</code> processor option is set
1045+
* to <code>true</code>. Not available for lambda routes.
10451046
*
10461047
* @return Method for MVC/Controller. Not available for lambda routes.
10471048
*/

modules/jooby-apt/src/main/java/io/jooby/internal/apt/MvcContext.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public MvcContext(
4444
this.output = output;
4545
this.debug = Options.boolOpt(processingEnvironment, Options.DEBUG, false);
4646
this.incremental = Options.boolOpt(processingEnvironment, Options.INCREMENTAL, true);
47-
this.returnType = Options.boolOpt(processingEnvironment, Options.RETURN_TYPE, true);
48-
this.mvcMethod = Options.boolOpt(processingEnvironment, Options.MVC_METHOD, true);
47+
this.returnType = Options.boolOpt(processingEnvironment, Options.RETURN_TYPE, false);
48+
this.mvcMethod = Options.boolOpt(processingEnvironment, Options.MVC_METHOD, false);
4949
this.services = Options.boolOpt(processingEnvironment, Options.SERVICES, true);
5050
this.routerPrefix = Options.string(processingEnvironment, Options.ROUTER_PREFIX, "");
5151
this.routerSuffix = Options.string(processingEnvironment, Options.ROUTER_SUFFIX, "_");

modules/jooby-apt/src/test/java/tests/ModuleCompilerTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void arrayRoute() throws Exception {
8181

8282
@Test
8383
public void routes() throws Exception {
84-
new ProcessorRunner(new Routes())
84+
new ProcessorRunner(new Routes(), Map.of("jooby.returnType", true))
8585
.withRouter(
8686
app -> {
8787
MockRouter router = new MockRouter(app);
@@ -263,7 +263,7 @@ public void noTopLevel() throws Exception {
263263

264264
@Test
265265
public void setPrimitiveReturnType() throws Exception {
266-
new ProcessorRunner(new PrimitiveReturnType())
266+
new ProcessorRunner(new PrimitiveReturnType(), Map.of("jooby.returnType", true))
267267
.withRouter(
268268
app -> {
269269
Route route = app.getRoutes().get(0);

modules/jooby-apt/src/test/java/tests/i1814/Issue1814.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import static org.junit.jupiter.api.Assertions.assertEquals;
99

10+
import java.util.Map;
11+
1012
import org.junit.jupiter.api.Test;
1113

1214
import io.jooby.apt.ProcessorRunner;
@@ -17,7 +19,7 @@ public class Issue1814 {
1719

1820
@Test
1921
public void shouldIgnoreWildcardResponseType() throws Exception {
20-
new ProcessorRunner(new C1814())
22+
new ProcessorRunner(new C1814(), Map.of("jooby.returnType", true))
2123
.withRouter(
2224
app -> {
2325
MockRouter router = new MockRouter(app);

modules/jooby-apt/src/test/java/tests/i2629/Issue2629.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import static org.junit.jupiter.api.Assertions.assertNotNull;
1010

1111
import java.util.List;
12+
import java.util.Map;
1213

1314
import org.junit.jupiter.api.Test;
1415

@@ -20,7 +21,7 @@ public class Issue2629 {
2021

2122
@Test
2223
public void shouldSetMvcMethod() throws Exception {
23-
new ProcessorRunner(new C2629())
24+
new ProcessorRunner(new C2629(), Map.of("jooby.mvcMethod", true))
2425
.withRouter(
2526
app -> {
2627
MockRouter router = new MockRouter(app);

modules/jooby-apt/src/test/java/tests/i2629/Issue2629b.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import static org.junit.jupiter.api.Assertions.assertEquals;
99
import static org.junit.jupiter.api.Assertions.assertNotNull;
1010

11+
import java.util.Map;
12+
1113
import org.junit.jupiter.api.Test;
1214

1315
import io.jooby.apt.ProcessorRunner;
@@ -18,7 +20,7 @@ public class Issue2629b {
1820

1921
@Test
2022
public void shouldSetMvcMethod() throws Exception {
21-
new ProcessorRunner(new C2629b())
23+
new ProcessorRunner(new C2629b(), Map.of("jooby.mvcMethod", true))
2224
.withRouter(
2325
app -> {
2426
MockRouter router = new MockRouter(app);

modules/jooby-apt/src/test/java/tests/i3490/Issue3490.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import static org.junit.jupiter.api.Assertions.assertTrue;
99

1010
import java.io.IOException;
11+
import java.util.Map;
1112

1213
import org.junit.jupiter.api.Test;
1314

@@ -17,7 +18,7 @@ public class Issue3490 {
1718

1819
@Test
1920
public void shouldNotGeneratePrimitiveOnKotlinGenerics() throws IOException {
20-
new ProcessorRunner(new C3490())
21+
new ProcessorRunner(new C3490(), Map.of("jooby.returnType", true))
2122
.withSourceCode(
2223
true,
2324
source -> {

0 commit comments

Comments
 (0)