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

null Token causes NPE #10

Closed
roryodonnell opened this issue May 11, 2018 · 10 comments
Closed

null Token causes NPE #10

roryodonnell opened this issue May 11, 2018 · 10 comments

Comments

@roryodonnell
Copy link

		tokenExpiresInSecs = Integer.parseInt(token.getExpires_in());
ERROR [2018-05-11 08:21:17,497] io.dropwizard.jersey.errors.LoggingExceptionMapper: Error handling a request: 29b2039092d5264c
! java.lang.NullPointerException: null
! at com.ibm.cloud.objectstorage.oauth.DefaultTokenManager.cacheToken(DefaultTokenManager.java:246)
! at com.ibm.cloud.objectstorage.oauth.DefaultTokenManager.retrieveToken(DefaultTokenManager.java:375)
! at com.ibm.cloud.objectstorage.oauth.DefaultTokenManager.getToken(DefaultTokenManager.java:190)
! at com.ibm.cloud.objectstorage.oauth.IBMOAuthSigner.sign(IBMOAuthSigner.java:40)
! at com.ibm.cloud.objectstorage.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1164)
! at com.ibm.cloud.objectstorage.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1030)
! at com.ibm.cloud.objectstorage.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:742)
! at com.ibm.cloud.objectstorage.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:716)
! at com.ibm.cloud.objectstorage.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699)
! at com.ibm.cloud.objectstorage.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667)
! at com.ibm.cloud.objectstorage.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
@seamus-mcgrath
Copy link
Contributor

seamus-mcgrath commented May 11, 2018

Hi @roryodonnell we'll look into this. It should be handled better. Were you running normal IAM authentication flow or have you written any custom token provider implementation? Also, what version of the SDK are you using?

@roryodonnell
Copy link
Author

Using this code from the Wiki

    public static AmazonS3 getS3Client(ObjectStorageConfig config, boolean keepConnectionAlive) {
        AWSCredentials credentials = null;
        if (config.getEndpoint().contains("objectstorage.softlayer.net")) {
            credentials = new BasicIBMOAuthCredentials(config.getAccessKey(), config.getSecretKey());
        }
        else {
            credentials = new BasicAWSCredentials(config.getAccessKey(), config.getSecretKey());
        }

        ClientConfiguration clientConfig = new ClientConfiguration().withRequestTimeout(config.getRequestTimeout());
        clientConfig.setUseTcpKeepAlive(keepConnectionAlive);

        AmazonS3 cos = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials))
                .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.getEndpoint(), config.getRegion()))
                .withPathStyleAccessEnabled(true).withClientConfiguration(clientConfig).build();
        return cos;
    }

Using this endpoint -> s3.us-south.objectstorage.softlayer.net along with the apiKey and resource_instance_id. Funny thing is, it works locally from Eclipse, but fails under a local minikube deployment

@roryodonnell
Copy link
Author

    <dependency>
        <groupId>com.ibm.cos</groupId>
        <artifactId>ibm-cos-java-sdk</artifactId>
        <version>2.1.0</version>
    </dependency>

@seamus-mcgrath
Copy link
Contributor

Looks like it is failing to retrieve a token, although it should handle the null object better. Can you reach https://iam.ng.bluemix.net/oidc/token from within minikube?

@roryodonnell
Copy link
Author

roryodonnell commented May 11, 2018

haven't tried that - just a fyi

@seamus-mcgrath
Copy link
Contributor

@roryodonnell did you get connectivity within minikube to the token endpoint? If so, did it resolve your issue?

@roryodonnell
Copy link
Author

I'm not sure - didn't dig into it too much. It could have been a temporary connection issue with cos - but as you say - the main point is to direct you to the unhandled NPE exception

@seamus-mcgrath
Copy link
Contributor

ok, we have an internal Jira raised - CSAFE-38356. I'll keep this github issue open too. thanks

@roryodonnell
Copy link
Author

....happy Friday!!

@barry-hueston
Copy link

Hi @roryodonnell this issue has been resolved in the latest public release of the Java SDK. Version 2.1.3.

Please let us know if you have any further issues with this.

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

3 participants