2
0

More than 3 years have passed since last update.

httpcore-4.4.5 で削除されたannotation ThreadSafe NotThreadSafeの置換

Last updated at Posted at 2020-08-14

httpcore-4.4.4 では使用可能だが httpcore-4.4.5 から削除されたannotation

@ThreadSafe, @NotThreadSafe に関する置換メモ。

Release Note:
https://archive.apache.org/dist/httpcomponents/httpcore/RELEASE_NOTES-4.4.x.txt

httpcore ThreadSafe class not found solution:
https://dev-aux.com/java/org-apache-http-annotation-threadsafe-class-not-found

置換

@ThreadSafe class not found compilation error occurs after updating your org.apache.httpcomponents:httpcore dependency version to 4.4.11 or above.
@NotThreadSafe

org.apache.http.annotation.Immutable
org.apache.http.annotation.NotThreadSafe
org.apache.http.annotation.ThreadSafe

削除されたこれらの代わりに、org.apache.http.annotation.Contractorg.apache.http.annotation.ThreadingBehavior enum が導入された。

よって @ThreadSafeorg.apache.http.annotation.Contract に置換し、ThreadingBehavior enumの値SAFEを渡せば、スレッドセーフな動作規約を指定できる。

@Contract(threading = org.apache.http.annotation.ThreadingBehavior.SAFE)

等々。

同じく @NotThreadSafe@Contract(threading = org.apache.http.annotation.ThreadingBehavior.UNSAFE)

@ImmutableThreadingBehavior.IMMUTABLE あるいは IMMUTABLE_CONDITIONAL

以下も参考:
https://hc.apache.org/httpcomponents-core-ga/httpcore/clirr-report.html

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0