Skip to content

Commit b4b124c

Browse files
author
Haydon Perrin
committed
ControllerMethodWriter: Renamed return variable names to result for consistency with the generated code.
1 parent e061ca2 commit b4b124c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

http-generator-javalin/src/main/java/io/avaje/http/generator/javalin/ControllerMethodWriter.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ private void writeContextReturn() {
8888
// Support for CompletableFuture's.
8989
final UType type = UType.parse(method.returnType());
9090
if (type.isGeneric() && type.mainType().equals("java.util.concurrent.CompletableFuture")) {
91-
final String returnVariableName = "futureResult";
91+
final String futureResultVariableName = "futureResult";
9292

9393
writer.append(" ctx.future(() -> {").eol();
94-
writer.append(" return result.thenAccept(%s -> {", returnVariableName).eol();
94+
writer.append(" return result.thenAccept(%s -> {", futureResultVariableName).eol();
9595
writer.append(" ");
96-
this.writeContextReturn(returnVariableName);
96+
this.writeContextReturn(futureResultVariableName);
9797
writer.eol().append(" });").eol();
9898
writer.append(" });").eol();
9999
return;
@@ -103,7 +103,7 @@ private void writeContextReturn() {
103103
this.writeContextReturn("result");
104104
}
105105

106-
private void writeContextReturn(final String returnVariableName) {
106+
private void writeContextReturn(final String resultVariableName) {
107107
final var produces = method.produces();
108108
if (produces == null || MediaType.APPLICATION_JSON.equalsIgnoreCase(produces)) {
109109
if (useJsonB) {
@@ -112,16 +112,16 @@ private void writeContextReturn(final String returnVariableName) {
112112
uType = uType.paramRaw();
113113
}
114114

115-
writer.append(" %sJsonType.toJson(%s, ctx.contentType(\"application/json\").outputStream());", uType.shortName(), returnVariableName);
115+
writer.append(" %sJsonType.toJson(%s, ctx.contentType(\"application/json\").outputStream());", uType.shortName(), resultVariableName);
116116
} else {
117-
writer.append(" ctx.json(%s);", returnVariableName);
117+
writer.append(" ctx.json(%s);", resultVariableName);
118118
}
119119
} else if (MediaType.TEXT_HTML.equalsIgnoreCase(produces)) {
120-
writer.append(" ctx.html(%s);", returnVariableName);
120+
writer.append(" ctx.html(%s);", resultVariableName);
121121
} else if (MediaType.TEXT_PLAIN.equalsIgnoreCase(produces)) {
122-
writer.append(" ctx.contentType(\"text/plain\").result(%s);", returnVariableName);
122+
writer.append(" ctx.contentType(\"text/plain\").result(%s);", resultVariableName);
123123
} else {
124-
writer.append(" ctx.contentType(\"%s\").result(%s);", produces, returnVariableName);
124+
writer.append(" ctx.contentType(\"%s\").result(%s);", produces, resultVariableName);
125125
}
126126
}
127127
}

0 commit comments

Comments
 (0)