Skip to content

armeria-0.79.0

Choose a tag to compare

@minwoox minwoox released this 23 Jan 01:19
0ff9a35

New features

  • A user can serve an individual file very easily. #1505
    ServerBuilder sb = new ServerBuilder();
    // Auto-generates ETag, Last-Modified.
    // Handles 'If-None-Match' and 'If-Modified-Since'.
    sb.service("/favicon.ico", HttpFile.of(new File("/var/www/favicon.ico")).asService());
    sb.annotatedService(new Object() {
        @Get("/files/{fileName}")
        public HttpResponse getFile(ServiceRequestContext ctx, HttpRequest req,
                                    @Param String fileName) {
            return HttpFile.of(new File("/var/www/files", fileName)).asService(ctx, req);
        }
    });
  • A user can specify different CORS policies for different origins. #1139 #1526
    ServerBuilder sb = new ServerBuilder().service("/message", myService.decorate(
        CorsServiceBuilder.forOrigins("http://example.com")
                          .allowCredentials()
                          .allowNullOrigin() // 'Origin: null' will be accepted.
                          ...
                          .andForOrigins("http://example2.com")
                          ...
                          .and() // Should call to return to CorsServiceBuilder.
                          .newDecorator()));
  • A user can have different access logger names for different virtual hosts. #947 #1517
  • Publisher and Stream return type is handled by the default response converters in AnnotatedHttpService. #1530
    public class MyAnnotatedService {
    
        @Get("/stream")
        @ProducesJsonSequences
        public Stream<String> stream() {
            return Stream.of("foo", "bar", "baz", "qux");
        }
    
        @Get("/publisher")
        @ProducesJsonSequences
        public Publisher<String> publisher() {
            return Flux.just("foo", "bar", "baz", "qux");
        }
    }
    • Maybe, Single, Completable and Observable are supported once you add armeria-rxjava to the dependencies as well.
      public class MyAnnotatedService {
          @Get("/observable")
          @ProducesJsonSequences
          public Observable<String> observable() {
              return Observable.just("foo", "bar", "baz", "qux");
          }
      }
  • A user is able to specify an alternative HTTP status code using @StatusCode. #1509
    public class MyAnnotatedService {
    
        @StatusCode(201)
        @Post("/users/{name}")
        public User createUser(@Param String name) { ... }
    
        // @StatusCode(200) would be applied by default.
        @Get("/users/{name}")
        public User getUser(@Param String name) { ... }
    
        // @StatusCode(204) would be applied by default.
        @Delete("/users/{name}")
        public void deleteUser(@Param String name) { ... }
    }
  • Added option to run gRPC callback in a blocking executor. #1525 #1524
    ServerBuilder sb = new ServerBuilder();
    sb.service(new GrpcServiceBuilder().useBlockingTaskExecutor(true)
                                       .addService(...)
                                       .build());
  • Marshalled Status.cause between server and client for more structured error handling in gRPC. #1504
  • Added verboseResponses property to ServerBuilder and ServerConfig. #1507 #1508
    ServerBuilder sb = new ServerBuilder();
    sb.verboseExceptions(true);
  • The services in DocService UI are now collapsible. #1506

Improvements

  • HttpHeaderNames.of() now accepts CharSequence. #1516
    // Before:
    HttpClientBuilder b = new HttpClientBuilder(...);
    b.addHttpHeader(AsciiString.of("my-header"), value);
    
    // After:
    b.addHttpHeader(HttpHeaderNames.of("my-header"), value);
    // or
    b.addHttpHeader("my-header", value);
  • Armeria(Client|Server)Configurator extends org.springframework.core.Ordered. #1535
    • A user can easily define the order of configurators applied.
  • CountingSampler in logging is not syncronized anymore. #1527
  • HttpStatus and HttpStatusException lookup performance is improved. #1545

Bug fixes

  • Fixed a bug where a connection which is scheduled for disconnection is returned to the pool. #1513
  • Fixed a bug where verboseExceptions is not working correctly when Exceptions.isExpected(Throwable) is used. #1529
  • Fixed a bug where initCause and addSuppressed can be called on singleton exceptions. #1545
  • Fixed a bug where exception messages are logged which do not really need to be logged. #1529
  • Fixed a bug where an HTTP/1 response adds redundant content-length: 0
    header for status code 204, 205 and 304. #1505
  • Fixed a bug where redundant injection with the same parameter happens in AnnotatedHttpService. #1538
  • Fixed a bug where a preflight request is not handled when an annotated service method is decorated with CorsService. #1537

Breaking changes

  • Moved fields in CorsConfig and CorsServiceBuilder except for anyOriginSupported and shortCircuit to CorsPolicy and AbstractCorsPolicyBuilder. #1526
  • Replaced the usage of HttpVfs.Entry with HttpFile. #1505
    • HttpVfs.get() returns HttpFile instead HttpVfs.Entry.
  • ResponseConverterFunction.convert() method takes more parameters which are headers and trailingHeaders. #1509
  • The behavior when null object is returned is changed in AnnotatedHttpService. #1509
  • The signature of CircuitBreakerListener is changed. #1509
    • The first parameter of all methods is String circuitBreakerName instead of CircuitBreaker circuitBreaker.
  • Renamed ArmeriaClientConfigurator.customize() to configure(). #1535
  • IllegalStateException is raised instead of ClosedClientFactoryException when a request in progress is cancelled due to the termination of ClientFactory. #1532

Deprecations

  • ClosedClientFactoryException has been deprectated. #1532

Dependencies

  • Curator 4.0.1 -> 4.1.0
  • Dropwizard Metrics 4.0.3 -> 4.0.5
  • gRPC 1.17.1 -> 1.18.0
  • Jackson 2.9.7 -> 2.9.8
  • java-jwt 3.4.1 -> 3.5.0
  • Micrometer 1.1.1 -> 1.1.2
  • Reactor 3.2.3 -> 3.2.5
  • RxJava 2.2.4 -> 2.2.5
  • Spring Boot 2.1.1 -> 2.1.2, 1.5.18 -> 1.5.19
  • Tomcat 8.5.35 -> 8.5.37