CompilationFailureException: Compilation failure error: cannot access NotThreadSafe

Error content:

Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
error: cannot access NotThreadSafe

Error reporting reason:

            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>4.5.2</version>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpcore</artifactId>
                <version>4.4.5</version>
            </dependency>

The versions of httpclient and HttpCore packages do not match.

be careful! Many online Posts say that reducing HttpCore to 4.4.4 can solve the problem, because 4.5.2 and 4.4.4 match.

However, the httpclient package itself has security vulnerabilities and is vulnerable to XSS attacks.

For httpclient problems, see: https://github.com/advisories/GHSA-7r82-7xv7-xcpj
Apache HttpClient versions prior to version 4.5.13 and 5.0.3 can misinterpret malformed authority component in request URIs passed to the library as java.net.URI object and pick the wrong target host for request execution.

Therefore, you can upgrade httpclient to 4.5.13 here, which matches 4.4.5 of HttpCore. satisfy both sides.

Correct reference posture:

            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>4.5.13</version>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpcore</artifactId>
                <version>4.4.5</version>
            </dependency>

Read More: