Replacement of annotation ThreadSafe / NotThreadSafe removed in httpcore-4.4.5

Annotation that is available in httpcore-4.4.4 but removed from httpcore-4.4.5

Replacement notes for @ 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

Replacement

@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

Instead of these removed, ʻorg.apache.http.annotation.Contract and ʻorg.apache.http.annotation.ThreadingBehavior enum were introduced.

Therefore, you can specify a thread-safe operating convention by replacing @ ThreadSafe with ʻorg.apache.http.annotation.Contract and passing the value SAFEofThreadingBehavior` enum.

Example

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

And so on.

Similarly, @NotThreadSafe is@Contract (threading = org.apache.http.annotation.ThreadingBehavior.UNSAFE)

@Immutable is ThreadingBehavior.IMMUTABLE or ʻIMMUTABLE_CONDITIONAL`

See also: https://hc.apache.org/httpcomponents-core-ga/httpcore/clirr-report.html

Recommended Posts

Replacement of annotation ThreadSafe / NotThreadSafe removed in httpcore-4.4.5