0.85.0 release notes
17th May 2019
New features
You can now bind your Service to a certain HTTP method or enable HTTP content-type negotiation very easily with the new
ServerBuilder.route()method. #1737ServerBuilder sb = new ServerBuilder(); sb.route() .get("/users/{id}") .delete("/users/{id}") .post("/users") .consumes(MediaType.JSON) .produces(MediaType.JSON_UTF_8) .build(new MyUserService()); // You can also configure using a lambda expression. sb.withRoute(b -> { b.path("/foo") .build(new MyFooService()); });It is now also possible to specify different settings for different services using the new
route()method. It means you can specify a large timeout for a certain service only conveniently. #1737ServerBuilder sb = new ServerBuilder(); sb.route() .path("/long_poll") .requestTimeoutMillis(0) // Disable timeout for /service. .build(new MyLongPollingService()); sb.route() .path("/get_now") .build(new MyOtherService()); // Use the default timeout. ```javaWe revamped our
HttpHeadersAPI to make it cleaner and safer. #1731HttpHeadershas been split into three types:RequestHeadersfor request headers with:methodand:pathheaderResponseHeadersfor response headers with:statusheaderHttpHeadersfor trailers and other headersRequestHeadersandResponseHeadersextendHttpHeaders.
HttpHeadersand its subtypes are immutable and thus must be built using a factory method or a builder.Quick examples:
RequestHeaders reqHdrs = RequestHeaders.of(HttpMethod.GET, "/get", HttpHeaderNames.ACCEPT, MediaType.JSON_UTF_8); RequestHeaders newReqHdrs = reqHdrs.toBuilder() .add("foo", "bar") .build(); ResponseHeaders resHdrs = ResponseHeaders.of(200 /* OK */); HttpHeaders hdrs = HttpHeaders.builder() .add("alice", "bob"); .build(); HttpHeaders newHdrs = hdrs.withMutations(builder -> { builder.add("charlie", "debora"); });See
HttpHeadersJavadoc for more examples.
You can now test your Armeria app with JUnit 5. A new module
armeria-testing-junit5has been added with the following extensions: #1736com.linecorp.armeria.testing.junit.server.ServerExtensioncom.linecorp.armeria.testing.junit.server.SelfSignedCertificateExtensioncom.linecorp.armeria.testing.junit.common.EventLoopGroupExtensioncom.linecorp.armeria.testing.junit.common.EventLoopExtension
You can now customize the behavior of gRPC JSON marshaller. #1696 #1753
ServerBuilder sb = new ServerBuilder(); sb.service(new GrpcServiceBuilder() .addService(new MyServiceImpl()) .supportedSerializationFormats(GrpcSerializationFormats.values()) .jsonMarshallerCustomizer(marshaller -> { marshaller.preservingProtoFieldNames(true); }) .build());You can now write a unary gRPC client without depending on grpc-java at all. #1703 #1748 #1751
HelloRequest req = HelloRequest.newBuilder() .setName("Alice") .build(); UnaryGrpcClient client = new UnaryGrpcClient(HttpClient.of("http://127.0.0.1:8080")); byte[] resBytes = client.execute("/com.example.HelloService/Greet", req.toByteArray()).join(); HelloResponse res = HelloResponse.parseFrom(resBytes);You can now use
GrpcServiceRegistrationBeanto register a gRPC service when using Spring Boot integration. #1749@Bean public GrpcServiceRegistrationBean helloService() { return new GrpcServiceRegistrationBean() .setServiceName("helloService") .setService(new GrpcServiceBuilder() .addService(new HelloService()) .supportedSerializationFormats(GrpcSerializationFormats.values()) .enableUnframedRequests(true) .build()) .setDecorators(LoggingService.newDecorator()) .setExampleRequests(List.of(ExampleRequest.of(HelloServiceGrpc.SERVICE_NAME, "Hello", HelloRequest.newBuilder() .setName("Armeria") .build()))); }You can now use
wildcardpattern when specifying built-in properties in LogbackRequestContextExportingAppender. #489 #1742
Bug fixes
- Trailing slashes in a path pattern is now handled correctly. #1741
- It is now disallowed to apply
CorsDecoratormore than once. #1740 HttpTracingClientandHttpTracingServicenow adds a valid addressablehttp.urltag. #1733 #1762SessionProtocolandSerializationFormatare now added tohttp.protocolandhttp.serfmttag instead.
Breaking changes
- Artifact armeria-testing has been renamed to
armeria-testing-junit4. Please update your project dependencies. #1736 - Many places in the public API that use
HttpHeadersas a parameter or a return value have been changed due to the revampedHttpHeadersAPI. #1731 - The following
ServerBuildermethods were removed:virtualHost(VirtualHost)defaultVirtualHost(VirtualHost)
Deprecations
The default prefix found in various configuration properties has been deprecated. Use the property setters without the default prefix. #1737
ServerBuilder sb = new ServerBuilder(); // Do NOT use this: sb.defaultRequestTimeout(...); // Use this: sb.requestTimeout(...);HttpHeaders.EMPTYhas been deprecated. UseHttpHeaders.of().
Dependencies
- Dropwizard Metrics 4.0.5 -> 4.1.0
- Jetty 9.4.17 -> 9.4.18
- Project Reactor 3.2.8 -> 3.2.9