Skip to content

Commit 3114f1a

Browse files
authored
Merge branch 'master' into loomClient
2 parents 50dd8db + ea7d886 commit 3114f1a

File tree

93 files changed

+2583
-332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+2583
-332
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ build/
1313
*.Module
1414
dependency-reduced-pom.xml
1515
.DS_Store
16+
tests/test-sigma/avaje-processors.txt
17+
tests/test-sigma/io.avaje.jsonb.spi.JsonbExtension

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# [Avaje-HTTP](https://avaje.io/http/)
22
[![Discord](https://img.shields.io/discord/1074074312421683250?color=%237289da&label=discord)](https://discord.gg/Qcqf9R27BR)
33
[![Build](https://github.com/avaje/avaje-http/actions/workflows/build.yml/badge.svg)](https://github.com/avaje/avaje-http/actions/workflows/build.yml)
4-
[![Maven Central : avaje-inject](https://img.shields.io/maven-central/v/io.avaje/avaje-http-api.svg?label=Maven%20Central)](https://maven-badges.herokuapp.com/maven-central/io.avaje/avaje-http-api)
4+
[![Maven Central](https://img.shields.io/maven-central/v/io.avaje/avaje-http-api.svg?label=Maven%20Central)](https://mvnrepository.com/artifact/io.avaje/avaje-http-api)
55
[![javadoc](https://javadoc.io/badge2/io.avaje/avaje-http-api/http_api_javadoc.svg?&color=purple)](https://javadoc.io/doc/io.avaje/avaje-http-api)
66
[![javadoc](https://javadoc.io/badge2/io.avaje/avaje-http-client/http_client_javadoc.svg?&color=purple)](https://javadoc.io/doc/io.avaje/avaje-http-client)
77
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/avaje/avaje-inject/blob/master/LICENSE)

htmx-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.avaje</groupId>
88
<artifactId>avaje-http-parent</artifactId>
9-
<version>2.8-RC3</version>
9+
<version>2.9-RC3</version>
1010
</parent>
1111

1212
<artifactId>avaje-htmx-api</artifactId>

htmx-nima-jstache/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.avaje</groupId>
88
<artifactId>avaje-http-parent</artifactId>
9-
<version>2.8-RC3</version>
9+
<version>2.9-RC3</version>
1010
</parent>
1111

1212
<artifactId>avaje-htmx-nima-jstache</artifactId>
@@ -39,14 +39,14 @@
3939
<dependency>
4040
<groupId>io.avaje</groupId>
4141
<artifactId>avaje-inject</artifactId>
42-
<version>10.4</version>
42+
<version>11.0</version>
4343
<scope>provided</scope>
4444
<optional>true</optional>
4545
</dependency>
4646
<dependency>
4747
<groupId>io.avaje</groupId>
4848
<artifactId>avaje-spi-service</artifactId>
49-
<version>2.6</version>
49+
<version>2.8</version>
5050
<scope>provided</scope>
5151
<optional>true</optional>
5252
</dependency>

htmx-nima/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.avaje</groupId>
88
<artifactId>avaje-http-parent</artifactId>
9-
<version>2.8-RC3</version>
9+
<version>2.9-RC3</version>
1010
</parent>
1111

1212
<artifactId>avaje-htmx-nima</artifactId>
@@ -21,12 +21,12 @@
2121
<dependency>
2222
<groupId>io.avaje</groupId>
2323
<artifactId>avaje-htmx-api</artifactId>
24-
<version>2.8-RC3</version>
24+
<version>2.9-RC3</version>
2525
</dependency>
2626
<dependency>
2727
<groupId>io.helidon.webserver</groupId>
2828
<artifactId>helidon-webserver</artifactId>
29-
<version>4.1.2</version>
29+
<version>4.1.4</version>
3030
</dependency>
3131
</dependencies>
3232
</project>

http-api-javalin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.avaje</groupId>
66
<artifactId>avaje-http-parent</artifactId>
7-
<version>2.8-RC3</version>
7+
<version>2.9-RC3</version>
88
<relativePath>..</relativePath>
99
</parent>
1010

http-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.avaje</groupId>
66
<artifactId>avaje-http-parent</artifactId>
7-
<version>2.8-RC3</version>
7+
<version>2.9-RC3</version>
88
<relativePath>..</relativePath>
99
</parent>
1010

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package io.avaje.http.api;
2+
3+
import static java.lang.annotation.ElementType.METHOD;
4+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
5+
6+
import java.lang.annotation.Retention;
7+
import java.lang.annotation.Target;
8+
9+
/**
10+
* Marks a method that handles HTTP OPTIONS requests.
11+
*/
12+
@Target(METHOD)
13+
@Retention(RUNTIME)
14+
@HttpMethod("OPTIONS")
15+
public @interface Options {
16+
17+
/** Specify the path. */
18+
String value() default "";
19+
20+
}

http-client-gson-adapter/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.avaje</groupId>
66
<artifactId>avaje-http-parent</artifactId>
7-
<version>2.8-RC3</version>
7+
<version>2.9-RC3</version>
88
</parent>
99

1010
<artifactId>avaje-http-client-gson</artifactId>
@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>io.avaje</groupId>
2222
<artifactId>avaje-http-client</artifactId>
23-
<version>2.8-RC3</version>
23+
<version>2.9-RC3</version>
2424
<scope>provided</scope>
2525
</dependency>
2626

http-client-moshi-adapter/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.avaje</groupId>
55
<artifactId>avaje-http-parent</artifactId>
6-
<version>2.8-RC3</version>
6+
<version>2.9-RC3</version>
77
</parent>
88
<artifactId>avaje-http-client-moshi</artifactId>
99

@@ -19,7 +19,7 @@
1919
<dependency>
2020
<groupId>io.avaje</groupId>
2121
<artifactId>avaje-http-client</artifactId>
22-
<version>2.8-RC3</version>
22+
<version>2.9-RC3</version>
2323
<scope>provided</scope>
2424
</dependency>
2525

http-client/pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.avaje</groupId>
66
<artifactId>avaje-http-parent</artifactId>
7-
<version>2.8-RC3</version>
7+
<version>2.9-RC3</version>
88
</parent>
99

1010
<artifactId>avaje-http-client</artifactId>
@@ -29,21 +29,21 @@
2929
<dependency>
3030
<groupId>com.fasterxml.jackson.core</groupId>
3131
<artifactId>jackson-databind</artifactId>
32-
<version>2.18.0</version>
32+
<version>2.18.2</version>
3333
<optional>true</optional>
3434
</dependency>
3535

3636
<dependency>
3737
<groupId>io.avaje</groupId>
3838
<artifactId>avaje-jsonb</artifactId>
39-
<version>2.2</version>
39+
<version>2.3</version>
4040
<optional>true</optional>
4141
</dependency>
4242

4343
<dependency>
4444
<groupId>io.avaje</groupId>
4545
<artifactId>avaje-inject</artifactId>
46-
<version>10.4</version>
46+
<version>11.0</version>
4747
<optional>true</optional>
4848
</dependency>
4949

@@ -66,7 +66,7 @@
6666
<dependency>
6767
<groupId>io.avaje</groupId>
6868
<artifactId>avaje-http-api</artifactId>
69-
<version>2.8-RC3</version>
69+
<version>${project.version}</version>
7070
<scope>test</scope>
7171
</dependency>
7272

@@ -99,7 +99,7 @@
9999
<path>
100100
<groupId>io.avaje</groupId>
101101
<artifactId>avaje-inject-generator</artifactId>
102-
<version>10.4</version>
102+
<version>11.0</version>
103103
</path>
104104
</annotationProcessorPaths>
105105
</configuration>

http-client/src/main/java/io/avaje/http/client/DHttpClientContext.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.avaje.http.client;
22

3+
import java.lang.invoke.MethodHandles;
4+
import java.lang.invoke.MethodType;
35
import java.lang.reflect.Type;
46
import java.net.http.HttpHeaders;
57
import java.net.http.HttpRequest;
@@ -9,6 +11,7 @@
911
import java.util.List;
1012
import java.util.Map;
1113
import java.util.concurrent.CompletableFuture;
14+
import java.util.concurrent.ExecutorService;
1215
import java.util.concurrent.atomic.AtomicReference;
1316
import java.util.concurrent.atomic.LongAccumulator;
1417
import java.util.concurrent.atomic.LongAdder;
@@ -340,4 +343,17 @@ private String authToken() {
340343
String maxResponseBody(String body) {
341344
return body.length() > 1_000 ? body.substring(0, 1_000) + " <truncated> ..." : body;
342345
}
346+
347+
@Override
348+
public void close() {
349+
if (Integer.getInteger("java.specification.version") >= 21) {
350+
try {
351+
MethodHandles.lookup()
352+
.findVirtual(java.net.http.HttpClient.class, "close", MethodType.methodType(void.class))
353+
.invokeExact(httpClient);
354+
} catch (Throwable t) {
355+
throw new IllegalStateException("Failed to close java.net.http.HttpClient instance");
356+
}
357+
}
358+
}
343359
}

http-client/src/main/java/io/avaje/http/client/HttpClient.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.net.Authenticator;
44
import java.net.CookieHandler;
55
import java.net.ProxySelector;
6-
import java.net.http.HttpRequest;
76
import java.time.Duration;
87
import java.util.Map;
98
import java.util.concurrent.Executor;
@@ -33,7 +32,7 @@
3332
*
3433
* }</pre>
3534
*/
36-
public interface HttpClient {
35+
public interface HttpClient extends AutoCloseable {
3736

3837
/**
3938
* Return the builder to config and build the client context.
@@ -93,6 +92,19 @@ static Builder builder() {
9392
*/
9493
HttpClient.Metrics metrics(boolean reset);
9594

95+
/**
96+
* Note: invoking this method has no effect on JDK versions less than 21.
97+
*
98+
* <p>Initiates an orderly shutdown in which http requests previously submitted are run to
99+
* completion, but no new requests will be accepted. Running a request to completion may involve
100+
* running several operations in the background, including waiting for responses to be delivered.
101+
* This method waits until all operations have completed execution and the client has terminated.
102+
*
103+
* @see {@linkplain java.net.http.HttpClient#close}
104+
*/
105+
@Override
106+
void close();
107+
96108
/**
97109
* Builds the HttpClient.
98110
*

http-generator-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.avaje</groupId>
66
<artifactId>avaje-http-parent</artifactId>
7-
<version>2.8-RC3</version>
7+
<version>2.9-RC3</version>
88
</parent>
99

1010
<artifactId>avaje-http-client-generator</artifactId>

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.avaje.http.generator.client;
22

3+
import io.avaje.http.generator.core.APContext;
34
import io.avaje.http.generator.core.BaseControllerWriter;
45
import io.avaje.http.generator.core.ControllerReader;
56
import io.avaje.http.generator.core.MethodReader;
@@ -62,12 +63,17 @@ private void writeMethods() {
6263
for (final ClientMethodWriter methodWriter : methodList) {
6364
methodWriter.write();
6465
}
66+
writer.append(" @Override").eol();
67+
writer.append(" public void close() {").eol();
68+
writer.append(" this.client.close();").eol();
69+
writer.append(" }").eol();
6570
}
6671

6772
private void writeClassStart() {
6873
writer.append(AT_GENERATED).eol();
6974
AnnotationUtil.writeAnnotations(writer, reader.beanType());
70-
writer.append("public class %s%s implements %s {", shortName, suffix, shortName).eol().eol();
75+
76+
writer.append("public class %s%s implements %s, AutoCloseable {", shortName, suffix, shortName).eol().eol();
7177

7278
writer.append(" private final HttpClient client;").eol().eol();
7379

http-generator-core/pom.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.avaje</groupId>
66
<artifactId>avaje-http-parent</artifactId>
7-
<version>2.8-RC3</version>
7+
<version>2.9-RC3</version>
88
</parent>
99

1010
<artifactId>avaje-http-generator-core</artifactId>
@@ -34,12 +34,6 @@
3434
<scope>provided</scope>
3535
</dependency>
3636

37-
<dependency>
38-
<groupId>io.swagger.core.v3</groupId>
39-
<artifactId>swagger-annotations</artifactId>
40-
<version>${swagger.version}</version>
41-
<scope>provided</scope>
42-
</dependency>
4337
<dependency>
4438
<groupId>io.swagger.core.v3</groupId>
4539
<artifactId>swagger-models</artifactId>

http-generator-core/src/main/java/io/avaje/http/generator/core/CoreWebMethod.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ public enum CoreWebMethod implements WebMethod {
66
PUT(200, 204),
77
PATCH(200, 204),
88
DELETE(200, 204),
9+
OPTIONS(200, 204),
910
ERROR(500),
1011
FILTER(0),
1112
OTHER(0, 0);
1213

13-
private int statusCode;
14-
private int voidStatusCode;
14+
private final int statusCode;
15+
private final int voidStatusCode;
1516

1617
CoreWebMethod(int statusCode, int voidStatusCode) {
1718
this.statusCode = statusCode;

http-generator-core/src/main/java/io/avaje/http/generator/core/openapi/OpenAPISerializer.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,20 @@
33
import java.lang.reflect.Field;
44
import java.util.Collection;
55
import java.util.Map;
6+
import java.util.Set;
67

78
final class OpenAPISerializer {
89

10+
private static final Set<String> IGNORED_FIELDS = Set.of(
11+
"SCHEMA_RESOLUTION_PROPERTY",
12+
"BIND_TYPE_AND_TYPES",
13+
"BINARY_STRING_CONVERSION_PROPERTY",
14+
"COMPONENTS_SCHEMAS_REF",
15+
"APPLY_SCHEMA_RESOLUTION_PROPERTY",
16+
"exampleSetFlag",
17+
"types",
18+
"specVersion");
19+
920
private OpenAPISerializer() {}
1021

1122
/**
@@ -65,13 +76,8 @@ static String serialize(Object obj) throws IllegalAccessException {
6576
for (final Field field : fields) {
6677

6778
// skip JsonIgnored fields
68-
if ("SCHEMA_RESOLUTION_PROPERTY".equals(field.getName())
69-
|| "BIND_TYPE_AND_TYPES".equals(field.getName())
70-
|| "BINARY_STRING_CONVERSION_PROPERTY".equals(field.getName())
71-
|| "COMPONENTS_SCHEMAS_REF".equals(field.getName())
72-
|| "exampleSetFlag".equals(field.getName())
73-
|| "types".equals(field.getName())
74-
|| "specVersion".equals(field.getName())) {
79+
if (IGNORED_FIELDS
80+
.contains(field.getName())) {
7581
continue;
7682
}
7783

http-generator-helidon/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<artifactId>avaje-http-parent</artifactId>
66
<groupId>io.avaje</groupId>
7-
<version>2.8-RC3</version>
7+
<version>2.9-RC3</version>
88
</parent>
99

1010
<artifactId>avaje-http-helidon-generator</artifactId>

http-generator-helidon/src/main/java/io/avaje/http/generator/helidon/nima/ControllerWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private void writeRoutes(List<ControllerMethodWriter> methods) {
123123
private void writeClassStart() {
124124
writer.append(AT_GENERATED).eol();
125125
writer.append(diAnnotation()).eol();
126-
writer.append("public class %s$Route implements HttpFeature {", shortName).eol().eol();
126+
writer.append("public final class %s$Route implements HttpFeature {", shortName).eol().eol();
127127

128128
var controllerName = "controller";
129129
var controllerType = shortName;

0 commit comments

Comments
 (0)