Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
public final class KeyEncryptionKeyAsyncClient extends CryptographyAsyncClient implements AsyncKeyEncryptionKey {

private final ClientLogger logger = new ClientLogger(KeyEncryptionKeyAsyncClient.class);
private final String keyId;

/**
* Creates a KeyEncryptionKeyAsyncClient that uses {@code pipeline} to service requests
Expand All @@ -27,18 +28,17 @@ public final class KeyEncryptionKeyAsyncClient extends CryptographyAsyncClient i
*/
KeyEncryptionKeyAsyncClient(String keyId, HttpPipeline pipeline, CryptographyServiceVersion version) {
super(keyId, pipeline, version);
this.keyId = keyId;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are passing this to the superclass constructor, why not have a superclass manage the lifecycle of this variable? CryptographyAsyncClient can have a protected method getKeyId() to get this key id.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be Public API only in KEK client.
So moved the variable management to super class as package private method.
Kept it public in KEK client.

}

/**
* {@inheritDoc}
* Get the identifier of the key to use for cryptography operations.
*
* @return A {@link Mono} containing the key identifier.
*/
@Override
public Mono<String> getKeyId() {
try {
return Mono.just(key.getId());
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
return Mono.defer(() -> Mono.just(keyId));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public final class KeyEncryptionKeyClient implements KeyEncryptionKey {
}

/**
* {@inheritDoc}
* Get the identifier of the key to use for cryptography operations.
*
* @return The key identifier.
*/
@Override
public String getKeyId() {
Expand Down