In a feign call, there is a requirement to query the order according to the order number. The interface is as follows:
@FeignClient(name = "order", path = "/")
public interface OrderFeignService {
@GetMapping(value = "/order/{orderNumber}")
BizOrderModel checkBizOrderExist(@PathVariable("orderNumber") String orderNumber);
}
The implementation is as follows:
@RestController
@RequestMapping("/")
public class OrderController implements OrderFeignService {
@Override
@GetMapping(value = "/order/{orderNumber}")
public BizOrderModel checkBizOrderExist(@PathVariable("orderNumber") String orderNumber) {
return orderService.findByOrderNumber(orderNumber);
}
}
The call is as follows:
@Service
@Slf4j
public class OrderService {
@Autowired
OrderFeignService orderFeignService;
public void test(){
if (null == orderFeignService.checkBizOrderExist(dto.getOrderNumber())) {
LOG.ERROR("Order information does not exist");
}
}
The exception message is as follows.
feign.FeignException: status 404 reading XXXXClient#XXXXMethod(Long)
at feign.FeignException.errorStatus(FeignException.java:62)
at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:91)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:138)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)
at com.sun.proxy.$Proxy97.querySpuDetailBySpuId(Unknown Source)
at XXXX(IndexService.java:41)
at XXXX(ElasticsearchTest.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at
…
Anomaly Exclusion.
That is, when the input of the get request is null, such as the orderNumber in this example is not passed, feign call will report 404!