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

A bad credential file can lead to NoClassDefFound DefaultCredentialsProvider #1030

Closed
abrooksv opened this issue Jan 22, 2019 · 0 comments
Closed

Comments

@abrooksv
Copy link
Contributor

Expected Behavior

SDK should skip bad profiles or lazy load the default chain

Current Behavior

java.lang.NoClassDefFoundError: Could not initialize class software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider
	at software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder.lambda$mergeChildDefaults$0(AwsDefaultClientBuilder.java:111)
	at software.amazon.awssdk.utils.builder.SdkBuilder.applyMutation(SdkBuilder.java:61)
	at software.amazon.awssdk.core.client.config.SdkClientConfiguration.merge(SdkClientConfiguration.java:67)
	at software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder.mergeChildDefaults(AwsDefaultClientBuilder.java:109)
	at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.syncClientConfiguration(SdkDefaultClientBuilder.java:143)
	at software.amazon.awssdk.services.cognitoidentity.DefaultCognitoIdentityClientBuilder.buildClient(DefaultCognitoIdentityClientBuilder.java:29)
	at software.amazon.awssdk.services.cognitoidentity.DefaultCognitoIdentityClientBuilder.buildClient(DefaultCognitoIdentityClientBuilder.java:22)
	at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.build(SdkDefaultClientBuilder.java:119)
	at software.aws.toolkits.core.ToolkitClientManager.createNewClient(ToolkitClientManager.kt:120)
	at software.aws.toolkits.core.ToolkitClientManager$getClient$2.apply(ToolkitClientManager.kt:63)
	at software.aws.toolkits.core.ToolkitClientManager$getClient$2.apply(ToolkitClientManager.kt:28)

True exception is:

com.intellij.diagnostic.PluginException:  [Plugin: aws.toolkit]
	at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.convertStub(ActionManagerImpl.java:149)
	at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.getActionImpl(ActionManagerImpl.java:471)
	at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.getAction(ActionManagerImpl.java:459)
	at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.preloadActions(ActionManagerImpl.java:1275)
	at com.intellij.openapi.actionSystem.impl.ActionPreloader.preload(ActionPreloader.java:32)
	at com.intellij.openapi.application.Preloader.lambda$null$0(Preloader.java:66)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:164)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:582)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:532)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:87)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:151)
	at com.intellij.openapi.application.Preloader.lambda$initComponent$1(Preloader.java:63)
	at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:227)
	at com.intellij.util.concurrency.BoundedTaskExecutor.access$100(BoundedTaskExecutor.java:26)
	at com.intellij.util.concurrency.BoundedTaskExecutor$2$1.run(BoundedTaskExecutor.java:200)
	at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:229)
	at com.intellij.util.concurrency.BoundedTaskExecutor$2.run(BoundedTaskExecutor.java:194)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ExceptionInInitializerError
	at software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder.lambda$mergeChildDefaults$0(AwsDefaultClientBuilder.java:111)
	at software.amazon.awssdk.utils.builder.SdkBuilder.applyMutation(SdkBuilder.java:61)
	at software.amazon.awssdk.core.client.config.SdkClientConfiguration.merge(SdkClientConfiguration.java:67)
	at software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder.mergeChildDefaults(AwsDefaultClientBuilder.java:109)
	at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.syncClientConfiguration(SdkDefaultClientBuilder.java:143)
	at software.amazon.awssdk.services.cognitoidentity.DefaultCognitoIdentityClientBuilder.buildClient(DefaultCognitoIdentityClientBuilder.java:29)
	at software.amazon.awssdk.services.cognitoidentity.DefaultCognitoIdentityClientBuilder.buildClient(DefaultCognitoIdentityClientBuilder.java:22)
	at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.build(SdkDefaultClientBuilder.java:119)
	at software.aws.toolkits.core.ToolkitClientManager.createNewClient(ToolkitClientManager.kt:120)
	at software.aws.toolkits.core.ToolkitClientManager$getClient$2.apply(ToolkitClientManager.kt:63)
	at software.aws.toolkits.core.ToolkitClientManager$getClient$2.apply(ToolkitClientManager.kt:28)
	at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
	at software.aws.toolkits.core.ToolkitClientManager.getClient(ToolkitClientManager.kt:63)
	at software.aws.toolkits.jetbrains.services.telemetry.AWSCognitoCredentialsProvider.<init>(CognitoIdentityProvider.kt:98)
	at software.aws.toolkits.jetbrains.services.telemetry.AWSCognitoCredentialsProvider.<init>(CognitoIdentityProvider.kt:41)
	at software.aws.toolkits.jetbrains.services.telemetry.DefaultTelemetryService.<init>(TelemetryService.kt:77)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.picocontainer.defaults.InstantiatingComponentAdapter.newInstance(InstantiatingComponentAdapter.java:193)
	at com.intellij.util.pico.CachingConstructorInjectionComponentAdapter.doGetComponentInstance(CachingConstructorInjectionComponentAdapter.java:85)
	at com.intellij.util.pico.CachingConstructorInjectionComponentAdapter.instantiateGuarded(CachingConstructorInjectionComponentAdapter.java:62)
	at com.intellij.util.pico.CachingConstructorInjectionComponentAdapter.getComponentInstance(CachingConstructorInjectionComponentAdapter.java:45)
	at com.intellij.openapi.components.impl.ServiceManagerImpl$MyComponentAdapter.getComponentInstance(ServiceManagerImpl.java:209)
	at com.intellij.util.pico.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:246)
	at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:213)
	at com.intellij.openapi.components.ServiceManager.doGetService(ServiceManager.java:52)
	at com.intellij.openapi.components.ServiceManager.getService(ServiceManager.java:26)
	at software.aws.toolkits.jetbrains.services.telemetry.TelemetryService$Companion.getInstance(TelemetryService.kt:39)
	at software.aws.toolkits.jetbrains.components.telemetry.AnActionWrapper.<clinit>(ActionWrappers.kt:50)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.convertStub(ActionManagerImpl.java:145)
	... 19 more
Caused by: java.lang.NullPointerException: Access key ID cannot be blank.
	at software.amazon.awssdk.utils.Validate.notNull(Validate.java:98)
	at software.amazon.awssdk.auth.credentials.AwsBasicCredentials.<init>(AwsBasicCredentials.java:66)
	at software.amazon.awssdk.auth.credentials.AwsBasicCredentials.<init>(AwsBasicCredentials.java:58)
	at software.amazon.awssdk.auth.credentials.AwsBasicCredentials.create(AwsBasicCredentials.java:78)
	at software.amazon.awssdk.auth.credentials.internal.ProfileCredentialsUtils.basicProfileCredentialsProvider(ProfileCredentialsUtils.java:110)
	at software.amazon.awssdk.auth.credentials.internal.ProfileCredentialsUtils.credentialsProvider(ProfileCredentialsUtils.java:98)
	at software.amazon.awssdk.auth.credentials.internal.ProfileCredentialsUtils.credentialsProvider(ProfileCredentialsUtils.java:80)
	at software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider.lambda$new$0(ProfileCredentialsProvider.java:65)
	at java.util.Optional.flatMap(Optional.java:241)
	at software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider.<init>(ProfileCredentialsProvider.java:64)
	at software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider.<init>(ProfileCredentialsProvider.java:44)
	at software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider$BuilderImpl.build(ProfileCredentialsProvider.java:193)
	at software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider.create(ProfileCredentialsProvider.java:85)
	at software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider.createChain(DefaultCredentialsProvider.java:68)
	at software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider.<init>(DefaultCredentialsProvider.java:50)
	at software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider.<clinit>(DefaultCredentialsProvider.java:42)
	... 53 more

Possible Solution(s)

  1. Do not parse credentials file in init method
  2. Make .option(AwsClientOption.CREDENTIALS_PROVIDER, DefaultCredentialsProvider.create()) actually a supplier instead of init-ing the chain.

Steps to Reproduce (for bugs)

Use this profile:

[default]
region = us-west-2
aws_access_key_id =
aws_secret_access_key = 

Context

aws/aws-toolkit-jetbrains#762

Your Environment

  • AWS Java SDK version used: 2.2.0
  • JDK version used: 1.8
  • Operating System and version: Mac
millems added a commit that referenced this issue Feb 7, 2019
The default credentials provider chain and region provider chains will no longer be loaded until they are first used. Further, the profile credentials provider will never raise an exception when it is created. The exception won't be raised until it is first used.

Fixes #1030, #1014, #749
millems added a commit that referenced this issue Feb 8, 2019
The default credentials provider chain and region provider chains will no longer be loaded until they are first used. Further, the profile credentials provider will never raise an exception when it is created. The exception won't be raised until it is first used.

Fixes #1030, #1014, #749
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

1 participant