STS not on class path when using parallel stream
See original GitHub issueRunning EcrClient.listImagesPaginator() in a Collection.parallelStream() using Spring Boot sometimes results in WebIdentityCredentialsUtils.factory() not finding STS on its class path.
Describe the issue
Sometimes when I execute the above I get the error message: “To use web identity tokens, the ‘sts’ service module must be on the class path.”. I know that parallel streams delegates work to the ForkJoin common pool, and it seems that sometimes some threads from this pool might have a class loader that does not have STS on its path. (Maybe because of Spring? I noticed that the loader called “app” does not have STS)
Is there a reason you guys are using Thread.currentThread().getContextClassLoader(), instead of Object.getClass().getClassLoader() in the WebIdentityCredentialsUtils class?
I admit I know little about class loaders and how you use them, but I cannot use parallelStream() reliably at the moment. Or do you advise against using parallelStream at all?
Not filing as bug, since it might be intended behaviour.
Steps to Reproduce
I am listing docker images from multiple repositories in parallel.
@Override
public Stream<String> listImages(List<String> repositories) {
return repositories.parallelStream()
.flatMap(repoName -> ecr.listImagesPaginator(builder -> builder.registryId(this.registryId).repositoryName(repoName).filter(f -> f.tagStatus(TagStatus.TAGGED)))
.imageIds()
.stream()
.map(ImageIdentifier::imageTag));
}
Current Behavior
I get the message “To use web identity tokens, the ‘sts’ service module must be on the class path.” instead of it finding STS and using the token credentials.
Your Environment
- AWS Java SDK version used: 2.14.18
- JDK version used: 13
- Operating System and version: Using the openjdk:13 image, which uses Oracle Linux 7 I believe.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Hi @BartXZX Could you please help me to confirm ones, if you have added “sts” module in dependency like
or it would be of great help if you could provide all dependencies related to <groupId>software.amazon.awssdk</groupId>
Nevermind, I see it’s already in 25 😃 And I’m happy to say I no longer see the issue!
Of course, it was an issue we saw ‘sometimes’ but usually we had a 50/50 chance to see it on startup. I’ve tested many times now and have not seen it since, so I’m happy. Will let you guys know if I see it pop up again.
Thank you for the quick response!