Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread Pinning With Virtual Threads #1985

Closed
bcluap opened this issue Feb 13, 2024 · 1 comment
Closed

Thread Pinning With Virtual Threads #1985

bcluap opened this issue Feb 13, 2024 · 1 comment

Comments

@bcluap
Copy link

bcluap commented Feb 13, 2024

Problem:

There is thread pinning when using the AWS Encryption SDK as it uses an old Apache HTTP client which causes pinning here:

org.apache.http.pool.AbstractConnPool$2.get(AbstractConnPool.java:256) <== monitors:1

The source:
@Override public E get(final long timeout, final TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException { for (;;) { **synchronized (this) {** try { final E entry = entryRef.get(); if (entry != null) { return entry; } if (done.get()) { throw new ExecutionException(operationAborted()); } final E leasedEntry = getPoolEntryBlocking(route, state, timeout, timeUnit, this); if (validateAfterInactivity > 0) { if (leasedEntry.getUpdated() + validateAfterInactivity <= System.currentTimeMillis()) { if (!validate(leasedEntry)) { leasedEntry.close(); release(leasedEntry, false); continue; } } }

Solution:

The Encryption SDK should allow overirding the HTTP client via an SPI or similar much like many of the other AWS SDK's. Alternatively upgrade to use httpclient5

@texastony
Copy link
Contributor

@bcluap

Thanks for cutting the issue!
The AWS Encryption SDK for Java (ESDK-Java) does, indirectly, allow for overriding the HTTP Client.

The ESDKs are not SDK clients, but they consume SDK Clients.
The consumed SDK client can be customized, otherwise a default one is created.

I authored a PR with an Example to demonstrate customizing the SDK Client.

I used the default ApachHTTP client,
as I did not want to bring in an additional dependency to use the CRT Client,
so the demonstration does not really address your concern.

If the KMS Client object, from the AWS SDK for Java V2,
does not allow you to use an HTTP Client that avoids thread pinning,
we would need to bring this up with @aws/aws-sdk-java-team .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants