Skip to content

Commit 0bcbf1a

Browse files
committed
prevent duplicate constants
1 parent 3d53d55 commit 0bcbf1a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

http-generator-client/src/main/java/io/avaje/http/generator/client/ClientMethodWriter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import static java.util.stream.Collectors.toMap;
1111

12+
import java.util.HashSet;
1213
import java.util.List;
1314
import java.util.Map;
1415
import java.util.Optional;
@@ -35,6 +36,7 @@ class ClientMethodWriter {
3536
private final Optional<RequestTimeoutPrism> timeout;
3637
private final boolean useConfig;
3738
private final Map<String, String> segmentPropertyMap;
39+
private final Set<String> propertyConstants = new HashSet<>();
3840

3941
ClientMethodWriter(MethodReader method, Append writer, boolean useJsonb) {
4042
this.method = method;
@@ -76,6 +78,11 @@ private void methodStart(Append writer) {
7678

7779
segmentPropertyMap.forEach(
7880
(k, v) -> {
81+
82+
if (!propertyConstants.add(v)) {
83+
return;
84+
}
85+
7986
writer.append(" private static final String %s = ", v);
8087
final String getProperty = useConfig ? "Config.get(" : "System.getProperty(";
8188
writer.append(getProperty).append("\"%s\");", k).eol();

http-generator-client/src/test/java/io/avaje/http/generator/client/clients/TitanFall.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@
77
public interface TitanFall {
88

99
@Get("/${titan}/${drop.point}")
10-
Titan titanfall();
10+
Titan titanFall();
11+
12+
13+
@Get("/${titan}/copium")
14+
Titan titanFall3();
1115
}

0 commit comments

Comments
 (0)