aws / aws/aws-sdk-java-v2

Announcement: Apache 5 is now the default HTTP Client

Aperta
#7,007 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
announcement
Lingua principale
Java
Stelle
2.6k
Fork
1k
Merge medio
2g 9h
PR unite (30g)
51

Descrizione

Starting in Java SDK `v2.46.0`, SDK sync clients will use Apache 5 as the default HTTP client, without the need to manually add `apache5-client` as a dependency. This change comes after support for Apache 5 was added in `v2.41.0`.

Simply add the service module to your project, and the sync client will use Apache 5 HTTP client by default:

```

software.amazon.awssdk
s3

```
```
// Apache5HttpClient is used here
S3Client client = S3Client.create();
```
If you want to customize the client settings, use the Apache5HttpClient.builder() as before:

```
S3Client client = S3Client.builder()
.httpClientBuilder(Apache5HttpClient.builder()
.maxConnections(100)
.connectionTimeout(Duration.ofSeconds(5)))
.build();
```

### Notable changes

* **Logger name differences** - Apache 5 uses different logger names than Apache 4. If you have logging configurations targeting Apache 4 logger names, you must update them. Please refer to the Apache 5 documentation, and see an example of SDK wire logging with Apache5HttpClient in the [Developer Guide - Logging](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/logging-slf4j.html#sdk-java-logging-verbose).
* **Increase in jar size** - If you explicitly depend on `apache-client`, after this change the `apache5-client` will be also added to the classpath, resulting in a ~2.3 MB increase in bundled artifact size. To avoid the jar size increase you can exclude the `apache5-client` as a workaround:
```

software.amazon.awssdk
s3


software.amazon.awssdk
apache5-client

software.amazon.awssdk
apache-client

```
Note that we recommend to fully migrate to use `apache5-client` instead of `apache-client`.

* **Expect: 100-Continue is disabled by default** - It was enabled by default in Apache 4. See [PR #6828](https://github.com/aws/aws-sdk-java-v2/pull/6828) for details. To re-enable in the Apache5 client, set the expectContinueEnabled configuration to True:
```
S3Client client = S3Client.builder()
.httpClientBuilder(Apache5HttpClient.builder()
.expectContinueEnabled(Boolean.TRUE))
.build();
```
* **Network permissions needed for Java SecurityManager** - Apache HttpClient 5.6 enables TCP keep-alive socket options by default (`TCP_KEEPIDLE`, `TCP_KEEPINTERVAL`, `TCP_KEEPCOUNT`), which require `jdk.net.NetworkPermission` when a SecurityManager is active. Without these permissions, requests fail with `java.security.AccessControlException: access denied`. These permissions were not required for Apache 4.x. If you use SecurityManager and start to see `AccessControlExceptions` after the upgrade, you need to grant permission to those TCP keep-alive options, see [PR #6974](https://github.com/aws/aws-sdk-java-v2/pull/6974) for details.

## Feedback

If you have questions, find a bug or have a feature request for the client to better suit your needs, please reach out to us by creating a new [GitHub issue](https://github.com/aws/aws-sdk-java-v2/issues/new/choose).

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Non viene indicato alcun file del repository né alcun test; inizia esaminando l’annuncio e la documentazione di logging di Apache 5 e le pull requests collegate. L’issue non specifica né una modifica alla documentazione né criteri di accettazione, quindi il completamento non può essere determinato dal payload.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
documentation
Tipo di issue
Documentazione
Difficoltà
1/5
Tempo stimato
Meno di un'ora
Stato di attività
Tranquilla
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.