1

https://github.com/openzipkin/zipkin/pull/3239相关,我们遇到了一些(可能)奇怪的行为,我想知道下面的测试是否按预期工作:

import com.linecorp.armeria.client.WebClient;
import com.linecorp.armeria.common.HttpMethod;
import com.linecorp.armeria.common.HttpRequest;
import com.linecorp.armeria.common.HttpResponse;
import com.linecorp.armeria.common.HttpStatus;
import com.linecorp.armeria.server.Server;
import com.linecorp.armeria.server.ServerBuilder;
import java.util.concurrent.CompletableFuture;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class ArmeriaTraceBug {

  @Test
  public void test_trace_bug() throws Exception {
    ServerBuilder sb = Server.builder();
    sb.http(7003);
    sb.service("/", (ctx, req) -> HttpResponse.of("Hello, world!"));
    sb.routeDecorator()
      .methods(HttpMethod.TRACE)
      .pathPrefix("/")
      .build((delegate, ctx, req) -> HttpResponse.of(HttpStatus.METHOD_NOT_ALLOWED));
    Server server = sb.build();
    CompletableFuture<Void> future = server.start();
    future.join();
    WebClient webClient = WebClient.of("http://localhost:7003/");
    final HttpResponse response = webClient.execute(HttpRequest.of(HttpMethod.OPTIONS, "/something"));
    assertThat(response.aggregate().get().status()).isEqualTo(HttpStatus.NOT_FOUND);
  }
}

基本上我们想禁用所有TRACE请求,并设置pathPrefix("/")来实现这一点。但是由于某种原因,OPTIONS调用/something被困在同一条路径中。如果我删除路线装饰器,事情会按预期工作。

4

1 回答 1

1

感谢 Jorg Heymans 的提问。是的,这是一个错误,应该由https://github.com/line/armeria/pull/3120修复 谢谢!

于 2020-10-20T05:42:11.103 回答