question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] KeyEncryptionKeyClientBuilder.buildKeyEncryptionKey().getKeyId(String keyId) leads to NullPointerException

See original GitHub issue

Describe the bug In com.azure:azure-security-keyvault-keys:4.0.0, use com.azure.security.keyvault.keys.cryptography.KeyEncryptionKeyClientBuilder.buildKeyEncryptionKey().getKeyId(String keyId) leads to NullPointerException

Exception or Stack Trace

java.lang.NullPointerException: null
	at com.azure.security.keyvault.keys.cryptography.KeyEncryptionKeyAsyncClient.getKeyId(KeyEncryptionKeyAsyncClient.java:38) ~[azure-security-keyvault-keys-4.0.0.jar:na]
	at com.azure.security.keyvault.keys.cryptography.KeyEncryptionKeyClient.getKeyId(KeyEncryptionKeyClient.java:28) ~[azure-security-keyvault-keys-4.0.0.jar:na]
	at com.example.demo.DemoApplication.test(DemoApplication.java:49) ~[classes/:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1795) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.1.RELEASE.jar:5.2.1.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.1.RELEASE.jar:2.2.1.RELEASE]
	at com.example.demo.DemoApplication.main(DemoApplication.java:28) ~[classes/:na]

To Reproduce Steps to reproduce the behavior: I have put the reproducible codes in https://github.com/chpoon92/azure-key-vault-bugs Preparation:

  1. Azure key vault url
  2. Service principal that can access key vault
    • tenant-id
    • client id
    • client secret
  3. Key name of an existing key in key vault
  4. Put above values in the config file /src/main/resources/application.yml

Run: In cmd, execute

mvn spring-boot:run

Code Snippet I have put in /src/main/java/com/example/demo/DemoApplication.java In function test()

Expected behavior Key id returned by com.azure.security.keyvault.keys.models.KeyVaultKey should be same as key id returned by com.azure.core.cryptography.KeyEncryptionKey

Setup (please complete the following information):

  • OS: Windows
  • IDE : IntelliJ
  • JDK : OpenJDK 11
  • Build tools : Maven 3.6.2
  • Library:
    • com.azure:azure-security-keyvault-keys:4.0.0
    • com.azure:azure-identity:1.0.0
    • org.springframework.boot:spring-boot-starter:2.2.1.RELEASE

Additional context The purpose of using com.azure.security.keyvault.keys.cryptography.KeyEncryptionKeyClientBuilder is because I need to apply Azure Key Vault to client side encryption of Azure Storage. The setup in com.azure:azure-storage-blob-cryptography:12.0.0 requires an instance of com.azure.core.cryptography.AsyncKeyEncryptionKeyResolver, which is the interface implemented by KeyEncryptionKeyClientBuilder.

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [*] Bug Description Added
  • [*] Repro Steps Added
  • [*] Setup information Added

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
g2vinaycommented, Jan 7, 2020

The fix for this issue has been merged into the master. It will be released as part of the KV release going out tomorrow on 7th Jan 2020.

0reactions
g2vinaycommented, Apr 9, 2020

@chpoon92 Thank you for posting this issue again. Since the root issue is resolved, we’ll be closing this issue. Do reach out to us, If you spot any other issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix and Avoid NullPointerException in Java - Rollbar
The NullPointerException occurs due to a situation in application code where an uninitialized object is attempted to be accessed or modified.
Read more >
java - What is a NullPointerException, and how do I fix it?
The NullPointerException (NPE) typically occurs when you declare a variable but did not create an object and assign it to the variable before...
Read more >
Test Class Failing due to NullPointerException
I will assume the latter, but basically the problem is that CustomSetting__c.getInstance().SecretAccessKey__c is null. You have to create your ...
Read more >
Java NullPointerException - Detect, Fix, and Best Practices
When we run the above program, it throws the following NullPointerException error message. Exception in thread "main" java.lang.
Read more >
NullPointerException (Java Platform SE 7 ) - Oracle Help Center
public class NullPointerException extends RuntimeException. Thrown when an application attempts to use null in a case where an object is required.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found