在验证提供给Is there a way to get a variable in to a custom ConstraintValidator when using JAX-RS?的解决方案时,我注意到isValid
被调用了两次,我怀疑这是正确的。
我可以在尝试使用的两个WLP中重新创建问题:
server.xml
<featureManager>
<feature>jaxrs-2.1</feature>
<feature>localConnector-1.0</feature>
<feature>transportSecurity-1.0</feature>
<feature>beanValidation-2.0</feature>
<feature>jaxrsClient-2.1</feature>
<feature>cdi-2.0</feature>
</featureManager>
在解释双重验证的代码中找不到任何内容。
堆栈转储显示这是在同一线程中发生的。 第一个验证堆栈摘要:
.....
ValidatorImpl.validateParameters(T, Method, Object[], Class<?>...) line: 224
BeanValidationProvider.validateParameters(T, Method, Object[]) line: 113
GeneratedMethodAccessor593.invoke(Object, Object[]) line: not available
Method.invoke(Object, Object...) line: not available
LibertyJaxRsInvoker.callValidationMethod(String, Object[], Object) line: 371
LibertyJaxRsInvoker.invoke(Exchange, Object, Method, List<Object>) line: 254
LibertyJaxRsInvoker(JAXRSInvoker).invoke(Exchange, Object, Object) line: 205
.....
第二个验证堆栈片段在几毫秒后出现:
....
ValidatorImpl.validateParameters(T, Method, Object[], Class<?>...) line: 224
ValidationInterceptor.validateMethodInvocation(InvocationContext) line: 66
GeneratedMethodAccessor662.invoke(Object, Object[]) line: not available
Method.invoke(Object, Object...) line: not available
SimpleInterceptorInvocation$SimpleMethodInvocation.invoke(InvocationContext) line: 73
InterceptorMethodHandler.executeAroundInvoke(Object, Method, Method, Object[], InterceptorMethodHandler$CachedInterceptionChain, InterceptionDecorationContext$Stack) line: 84
InterceptorMethodHandler.executeInterception(Object, Method, Method, Object[], InterceptionType, InterceptionDecorationContext$Stack) line: 72
InterceptorMethodHandler.invoke(InterceptionDecorationContext$Stack, Object, Method, Method, Object[]) line: 56
CombinedInterceptorAndDecoratorStackMethodHandler.invoke(InterceptionDecorationContext$Stack, Object, Method, Method, Object[], boolean, boolean) line: 79
CombinedInterceptorAndDecoratorStackMethodHandler.invoke(InterceptionDecorationContext$Stack, Object, Method, Method, Object[]) line: 68
CustomerResource$Proxy$_$$_WeldSubclass.postCustomer(Customer) line: not available
CustomerResource$Proxy$_$$_WeldClientProxy.postCustomer(Customer) line: not available
GeneratedMethodAccessor661.invoke(Object, Object[]) line: not available
Method.invoke(Object, Object...) line: not available
LibertyJaxRsServerFactoryBean.performInvocation(Exchange, Object, Method, Object[]) line: 652
LibertyJaxRsInvoker.performInvocation(Exchange, Object, Method, Object[]) line: 160
LibertyJaxRsInvoker(AbstractInvoker).invoke(Exchange, Object, Method, List<Object>) line: 96
LibertyJaxRsInvoker.invoke(Exchange, Object, Method, List<Object>) line: 273
LibertyJaxRsInvoker(JAXRSInvoker).invoke(Exchange, Object, Object) line: 205
....
难道验证只能调用一次吗?