winfriedgerlach commented on PR #692:
URL:
https://github.com/apache/httpcomponents-client/pull/692#issuecomment-3135887395
Hi @arturobernalg, I am already using a custom connection factory to create
my "instrumented connections". But that was not the question that I wanted to
answer with this PR: I wanted to make the creation of such "custom connections"
easier.
Take this example: if I principally appreciate the behavior of
`DefaultManagedHttpClientConnection` and it was not final, I could easily add
stuff to the log when closing a connection.
```java
// in ManagedHttpClientConnectionFactory#createConnection:
final var connection = new
DefaultManagedHttpClientConnection(id) {
@Override
public void close() throws IOException {
var certificate = (X509Certificate)
getSSLSession().getPeerCertificates()[0];
var dn =
certificate.getSubjectX500Principal().getName();
LOG.info("Closing connection {} with DN: {}", id,
dn);
super.close();
}
};
```
(just as an example, don't worry about missing checks etc.)
What would be your alternative solution to this approach?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]