欢迎访问我的个人网站==》 jiashubing.cn

httpcore Immutable 升级替代方法

httpcore 包

<dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>${httpcore.version}</version>
</dependency>

 

4.4.4 版本里有个Immutable 注解

@Documented
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.CLASS)
public @interface Immutable {
}

 

4.4.13 版本里已经没有这个注解了
用@Contract(threading = ThreadingBehavior.SAFE) 替代

@Documented
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.CLASS)
public @interface Contract {
    ThreadingBehavior threading() default ThreadingBehavior.UNSAFE;
}


public enum ThreadingBehavior {
    IMMUTABLE,
    IMMUTABLE_CONDITIONAL,
    SAFE,
    SAFE_CONDITIONAL,
    UNSAFE;

    private ThreadingBehavior() {
    }
}

 

原创文章,欢迎转载,转载请注明出处!

posted @ 2021-04-30 14:25  贾树丙  阅读(391)  评论(0编辑  收藏  举报