小编vvs*_*man的帖子

无法在ConcurrentLinkedQueue源代码中获取此条件

在ConcurrentLinkedQueue的源代码中,在offer方法中:

public boolean offer(E e) {
checkNotNull(e);
final Node<E> newNode = new Node<E>(e);

for (Node<E> t = tail, p = t;;) {
    Node<E> q = p.next;
    if (q == null) {
        // p is last node
        if (p.casNext(null, newNode)) {
                // Successful CAS is the linearization point
                // for e to become an element of this queue,
                // and for newNode to become "live".
                if (p != t) // hop two nodes at a time
                    casTail(t, newNode);  // …
Run Code Online (Sandbox Code Playgroud)

java concurrency

5
推荐指数
1
解决办法
116
查看次数

spring boot验证器成功但没有异常抛出

我在 spring boot 中使用了验证器,但无法捕获任何异常,我的代码就是这样

首先我创建一个带注释的bean

@Data
@EqualsAndHashCode(callSuper = false)
public class OrderDetailPO extends BaseEntity<String>{

    private static final long serialVersionUID = 1L;
    @NotNull
    @Size(max=32,message="ordercode is null")
    private String orderCode;

    @NotBlank
    @Size(max=32,message="productMode is null")
    private String productMode;

    @NotBlank
    @Size(max=128,message="hotelType is null")
    private String hotelType;

    @NotBlank
    @Size(max=32,message="goodsId is null")
    private String goodsId;
}
Run Code Online (Sandbox Code Playgroud)

然后我在控制器中使用@validated

public Result<?> createOrderDetail( @RequestBody @Validated  OrderDetailPO orderDetail,BindingResult bindingResult) throws ParseException, UnsupportedEncodingException {

//       if (bindingResult.hasErrors()) {  
//              String errMsg="";
//              for(FieldError err: bindingResult.getFieldErrors()) {  
//                  errMsg += err.getField()+" is …
Run Code Online (Sandbox Code Playgroud)

validation exception spring-boot

3
推荐指数
1
解决办法
8608
查看次数

spring boot @PathVariable 无法验证

是的,与Spring 4 中的 @PathVariable ValidationAdd class level validation to @Pathvariable in Spring相同的问题

spring 验证不适用于参数,抛出也不例外,这是我的代码,后面是@Patrick 的回答,感谢他

@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
     return new MethodValidationPostProcessor();
}

/**
 * 
 * @param accountId
 */
@RequestMapping(value="/orderDetailSelByAccountId/{accountId}.json",method= {RequestMethod.POST})
@ResponseBody
@Validated
public Result<?> orderDetailSelByAccountId(  @NotNull @NotBlank 
@Size(min=10,max=32)@PathVariable(value="accountId") String accountId) { ....    }
Run Code Online (Sandbox Code Playgroud)

但是当我发送空 accountId 时,没有异常抛出......我是对的,还有其他解决方案吗?

validation spring spring-boot

0
推荐指数
1
解决办法
3676
查看次数

标签 统计

spring-boot ×2

validation ×2

concurrency ×1

exception ×1

java ×1

spring ×1