comment stringlengths 1 45k | method_body stringlengths 23 281k | target_code stringlengths 0 5.16k | method_body_after stringlengths 12 281k | context_before stringlengths 8 543k | context_after stringlengths 8 543k |
|---|---|---|---|---|---|
Same question | public URL getShareUrl() {
String shareURLString = String.format("%s/%s", azureFileStorageClient.getUrl(), shareName);
if (snapshot != null) {
shareURLString = String.format("%s?snapshot=%s", shareURLString, snapshot);
}
try {
return new URL(shareURLString);
} catch (MalformedURLException e) {
throw logger.logException... | String shareURLString = String.format("%s/%s", azureFileStorageClient.getUrl(), shareName); | public URL getShareUrl() {
StringBuilder shareURLString = new StringBuilder(azureFileStorageClient.getUrl()).append("/").append(shareName);
if (snapshot != null) {
shareURLString.append("?snapshot=").append(snapshot);
}
try {
return new URL(shareURLString.toString());
} catch (MalformedURLException e) {
throw logger.lo... | class ShareAsyncClient {
private final ClientLogger logger = new ClientLogger(ShareAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String snapshot;
/**
* Creates a ShareAsyncClient that sends requests to the storage share at {@link AzureFileSt... | class ShareAsyncClient {
private final ClientLogger logger = new ClientLogger(ShareAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String snapshot;
/**
* Creates a ShareAsyncClient that sends requests to the storage share at {@link AzureFileSt... |
The format is like `https://sima.file.core.windows.net/sharename/directoryPath` | public URL getDirectoryUrl() {
String directoryURLString = String.format("%s/%s/%s", azureFileStorageClient.getUrl(),
shareName, directoryPath);
if (snapshot != null) {
directoryURLString = String.format("%s?snapshot=%s", directoryURLString, snapshot);
}
try {
return new URL(directoryURLString);
} catch (MalformedURLEx... | String directoryURLString = String.format("%s/%s/%s", azureFileStorageClient.getUrl(), | public URL getDirectoryUrl() {
StringBuilder directoryURLString = new StringBuilder(azureFileStorageClient.getUrl()).append("/")
.append(shareName).append("/").append(directoryPath);
if (snapshot != null) {
directoryURLString.append("?snapshot=").append(snapshot);
}
try {
return new URL(directoryURLString.toString());
... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... |
Instead of doing multiple String::format calls across if statements, why not use a string builder? | public URL getDirectoryUrl() {
String directoryURLString = String.format("%s/%s/%s", azureFileStorageClient.getUrl(),
shareName, directoryPath);
if (snapshot != null) {
directoryURLString = String.format("%s?snapshot=%s", directoryURLString, snapshot);
}
try {
return new URL(directoryURLString);
} catch (MalformedURLEx... | directoryURLString = String.format("%s?snapshot=%s", directoryURLString, snapshot); | public URL getDirectoryUrl() {
StringBuilder directoryURLString = new StringBuilder(azureFileStorageClient.getUrl()).append("/")
.append(shareName).append("/").append(directoryPath);
if (snapshot != null) {
directoryURLString.append("?snapshot=").append(snapshot);
}
try {
return new URL(directoryURLString.toString());
... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... |
StringBuilder comment. | public URL getFileUrl() {
String fileURLString = String.format("%s/%s/%s", azureFileStorageClient.getUrl(), shareName, filePath);
if (snapshot != null) {
fileURLString = String.format("%s?snapshot=%s", fileURLString, snapshot);
}
try {
return new URL(fileURLString);
} catch (MalformedURLException e) {
throw logger.logE... | fileURLString = String.format("%s?snapshot=%s", fileURLString, snapshot); | public URL getFileUrl() {
StringBuilder fileURLString = new StringBuilder(azureFileStorageClient.getUrl()).append("/")
.append(shareName).append("/").append(filePath);
if (snapshot != null) {
fileURLString.append("?snapshot=").append(snapshot);
}
try {
return new URL(fileURLString.toString());
} catch (MalformedURLExce... | class FileAsyncClient {
private final ClientLogger logger = new ClientLogger(FileAsyncClient.class);
private static final long FILE_DEFAULT_BLOCK_SIZE = 4 * 1024 * 1024L;
private static final long DOWNLOAD_UPLOAD_CHUNK_TIMEOUT = 300;
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareN... | class FileAsyncClient {
private final ClientLogger logger = new ClientLogger(FileAsyncClient.class);
private static final long FILE_DEFAULT_BLOCK_SIZE = 4 * 1024 * 1024L;
private static final long DOWNLOAD_UPLOAD_CHUNK_TIMEOUT = 300;
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareN... |
StringBuilder comment. | public URL getShareUrl() {
String shareURLString = String.format("%s/%s", azureFileStorageClient.getUrl(), shareName);
if (snapshot != null) {
shareURLString = String.format("%s?snapshot=%s", shareURLString, snapshot);
}
try {
return new URL(shareURLString);
} catch (MalformedURLException e) {
throw logger.logException... | shareURLString = String.format("%s?snapshot=%s", shareURLString, snapshot); | public URL getShareUrl() {
StringBuilder shareURLString = new StringBuilder(azureFileStorageClient.getUrl()).append("/").append(shareName);
if (snapshot != null) {
shareURLString.append("?snapshot=").append(snapshot);
}
try {
return new URL(shareURLString.toString());
} catch (MalformedURLException e) {
throw logger.lo... | class ShareAsyncClient {
private final ClientLogger logger = new ClientLogger(ShareAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String snapshot;
/**
* Creates a ShareAsyncClient that sends requests to the storage share at {@link AzureFileSt... | class ShareAsyncClient {
private final ClientLogger logger = new ClientLogger(ShareAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String snapshot;
/**
* Creates a ShareAsyncClient that sends requests to the storage share at {@link AzureFileSt... |
```java logger.error("Queue URL is malformed"); throw logger.logExceptionAsError(new RuntimeException("Queue URL is malformed")); ``` Does this log twice? | public URL getQueueUrl() {
try {
return new URL(String.format("%s/%s", client.getUrl(), queueName));
} catch (MalformedURLException ex) {
logger.error("Queue URL is malformed");
throw logger.logExceptionAsError(new RuntimeException("Queue URL is malformed"));
}
} | throw logger.logExceptionAsError(new RuntimeException("Queue URL is malformed")); | public URL getQueueUrl() {
try {
return new URL(String.format("%s/%s", client.getUrl(), queueName));
} catch (MalformedURLException ex) {
throw logger.logExceptionAsError(new RuntimeException("Queue URL is malformed"));
}
} | class QueueAsyncClient {
private final ClientLogger logger = new ClientLogger(QueueAsyncClient.class);
private final AzureQueueStorageImpl client;
private final String queueName;
/**
* Creates a QueueAsyncClient that sends requests to the storage queue service at {@link
* Each service call goes through the {@link HttpP... | class QueueAsyncClient {
private final ClientLogger logger = new ClientLogger(QueueAsyncClient.class);
private final AzureQueueStorageImpl client;
private final String queueName;
/**
* Creates a QueueAsyncClient that sends requests to the storage queue service at {@link
* Each service call goes through the {@link HttpP... |
Good catch. | public URL getQueueUrl() {
try {
return new URL(String.format("%s/%s", client.getUrl(), queueName));
} catch (MalformedURLException ex) {
logger.error("Queue URL is malformed");
throw logger.logExceptionAsError(new RuntimeException("Queue URL is malformed"));
}
} | throw logger.logExceptionAsError(new RuntimeException("Queue URL is malformed")); | public URL getQueueUrl() {
try {
return new URL(String.format("%s/%s", client.getUrl(), queueName));
} catch (MalformedURLException ex) {
throw logger.logExceptionAsError(new RuntimeException("Queue URL is malformed"));
}
} | class QueueAsyncClient {
private final ClientLogger logger = new ClientLogger(QueueAsyncClient.class);
private final AzureQueueStorageImpl client;
private final String queueName;
/**
* Creates a QueueAsyncClient that sends requests to the storage queue service at {@link
* Each service call goes through the {@link HttpP... | class QueueAsyncClient {
private final ClientLogger logger = new ClientLogger(QueueAsyncClient.class);
private final AzureQueueStorageImpl client;
private final String queueName;
/**
* Creates a QueueAsyncClient that sends requests to the storage queue service at {@link
* Each service call goes through the {@link HttpP... |
Any benefits of StringBuilder? | public URL getDirectoryUrl() {
String directoryURLString = String.format("%s/%s/%s", azureFileStorageClient.getUrl(),
shareName, directoryPath);
if (snapshot != null) {
directoryURLString = String.format("%s?snapshot=%s", directoryURLString, snapshot);
}
try {
return new URL(directoryURLString);
} catch (MalformedURLEx... | directoryURLString = String.format("%s?snapshot=%s", directoryURLString, snapshot); | public URL getDirectoryUrl() {
StringBuilder directoryURLString = new StringBuilder(azureFileStorageClient.getUrl()).append("/")
.append(shareName).append("/").append(directoryPath);
if (snapshot != null) {
directoryURLString.append("?snapshot=").append(snapshot);
}
try {
return new URL(directoryURLString.toString());
... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... |
Made the changes. | public URL getDirectoryUrl() {
String directoryURLString = String.format("%s/%s/%s", azureFileStorageClient.getUrl(),
shareName, directoryPath);
if (snapshot != null) {
directoryURLString = String.format("%s?snapshot=%s", directoryURLString, snapshot);
}
try {
return new URL(directoryURLString);
} catch (MalformedURLEx... | directoryURLString = String.format("%s?snapshot=%s", directoryURLString, snapshot); | public URL getDirectoryUrl() {
StringBuilder directoryURLString = new StringBuilder(azureFileStorageClient.getUrl()).append("/")
.append(shareName).append("/").append(directoryPath);
if (snapshot != null) {
directoryURLString.append("?snapshot=").append(snapshot);
}
try {
return new URL(directoryURLString.toString());
... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... |
`%n` | public void purgeDeletedCertificateWithResponseCodeSnippets() {
CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient();
certificateAsyncClient.purgeDeletedCertificateWithResponse("deletedCertificateName")
.subscriberContext(Context.of(key1, value1, key2, value2))
.subscribe(purgeResponse ->
System.... | System.out.printf("Purge Status response %d \n", purgeResponse.getStatusCode())); | public void purgeDeletedCertificateWithResponseCodeSnippets() {
CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient();
certificateAsyncClient.purgeDeletedCertificateWithResponse("deletedCertificateName")
.subscriberContext(Context.of(key1, value1, key2, value2))
.subscribe(purgeResponse ->
System.... | class CertificateAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link CertificateAsyncClient}
* @return An instance of {@link CertificateAsyncClient}
*/
public Certif... | class CertificateAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link CertificateAsyncClient}
* @return An instance of {@link CertificateAsyncClient}
*/
public Certif... |
You can uncomment this. Since it's verbose, it's most likely not logged and if verbose logging is enabled, then I guess logging this is okay. | public void onUnhandled(Event event) {
try {
super.onUnhandled(event);
} catch (NullPointerException e) {
logger.error("Exception occurred when handling event in super.", e);
}
} | public void onUnhandled(Event event) {
try {
super.onUnhandled(event);
} catch (NullPointerException e) {
logger.error("Exception occurred when handling event in super.", e);
}
} | class CustomIOHandler extends IOHandler {
private final ClientLogger logger = new ClientLogger(CustomIOHandler.class);
private final String connectionId;
public CustomIOHandler(final String connectionId) {
this.connectionId = connectionId;
}
@Override
public void onTransportClosed(Event event) {
final Transport transpo... | class CustomIOHandler extends IOHandler {
private final ClientLogger logger = new ClientLogger(CustomIOHandler.class);
private final String connectionId;
public CustomIOHandler(final String connectionId) {
this.connectionId = connectionId;
}
@Override
public void onTransportClosed(Event event) {
final Transport transpo... | |
Yeah. It's very, very verbose when it is enabled, because there are so many reactor events we don't bother to listen to. I guess that's why it's DEBUG. | public void onUnhandled(Event event) {
try {
super.onUnhandled(event);
} catch (NullPointerException e) {
logger.error("Exception occurred when handling event in super.", e);
}
} | public void onUnhandled(Event event) {
try {
super.onUnhandled(event);
} catch (NullPointerException e) {
logger.error("Exception occurred when handling event in super.", e);
}
} | class CustomIOHandler extends IOHandler {
private final ClientLogger logger = new ClientLogger(CustomIOHandler.class);
private final String connectionId;
public CustomIOHandler(final String connectionId) {
this.connectionId = connectionId;
}
@Override
public void onTransportClosed(Event event) {
final Transport transpo... | class CustomIOHandler extends IOHandler {
private final ClientLogger logger = new ClientLogger(CustomIOHandler.class);
private final String connectionId;
public CustomIOHandler(final String connectionId) {
this.connectionId = connectionId;
}
@Override
public void onTransportClosed(Event event) {
final Transport transpo... | |
Mind changing the `\n` to `%n` as expected in `printf` | public static void main(String[] args) throws IOException, InterruptedException, IllegalArgumentException {
CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
CertificatePolicy policy = new Certif... | System.out.printf("Purge Status response %d \n", purgeResponse.getStatusCode())); | public static void main(String[] args) throws IOException, InterruptedException, IllegalArgumentException {
CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
CertificatePolicy policy = new Certif... | class BackupAndRestoreOperationsAsync {
/**
* Authenticates with the key vault and shows how to asynchronously backup and restore certificates in the key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws InterruptedException ... | class BackupAndRestoreOperationsAsync {
/**
* Authenticates with the key vault and shows how to asynchronously backup and restore certificates in the key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws InterruptedException ... |
Change this to `println` | public void purgeDeletedCertificateCodeSnippets() {
CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient();
certificateAsyncClient.purgeDeletedCertificate("deletedCertificateName")
.subscriberContext(Context.of(key1, value1, key2, value2))
.doOnSuccess(response -> System.out.printf("Successfully Pu... | .doOnSuccess(response -> System.out.printf("Successfully Purged certificate \n")); | public void purgeDeletedCertificateCodeSnippets() {
CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient();
certificateAsyncClient.purgeDeletedCertificate("deletedCertificateName")
.subscriberContext(Context.of(key1, value1, key2, value2))
.doOnSuccess(response -> System.out.println("Successfully P... | class CertificateAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link CertificateAsyncClient}
* @return An instance of {@link CertificateAsyncClient}
*/
public Certif... | class CertificateAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link CertificateAsyncClient}
* @return An instance of {@link CertificateAsyncClient}
*/
public Certif... |
`%n` | public static void main(String[] args) throws InterruptedException {
CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaP... | System.out.printf("Purge Status response %d \n", purgeResponse.getStatusCode())); | public static void main(String[] args) throws InterruptedException {
CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaP... | class HelloWorldAsync {
/**
* Authenticates with the key vault and shows how to asynchronously set, get, update and delete a key in the key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws InterruptedException when the threa... | class HelloWorldAsync {
/**
* Authenticates with the key vault and shows how to asynchronously set, get, update and delete a key in the key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws InterruptedException when the threa... |
`%n` | public static void main(String[] args) throws InterruptedException {
CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaP... | System.out.printf("Purge Status response %d \n", purgeResponse.getStatusCode())); | public static void main(String[] args) throws InterruptedException {
CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaP... | class HelloWorldAsync {
/**
* Authenticates with the key vault and shows how to asynchronously set, get, update and delete a key in the key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws InterruptedException when the threa... | class HelloWorldAsync {
/**
* Authenticates with the key vault and shows how to asynchronously set, get, update and delete a key in the key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws InterruptedException when the threa... |
`%n` | public static void main(String[] args) throws InterruptedException {
CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaP... | System.out.printf("Purge Status response %d \n", purgeResponse.getStatusCode())); | public static void main(String[] args) throws InterruptedException {
CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaP... | class ManagingDeletedCertificatesAsync {
/**
* Authenticates with the key vault and shows how to asynchronously list, recover and purge deleted certificates in a soft-delete enabled key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.... | class ManagingDeletedCertificatesAsync {
/**
* Authenticates with the key vault and shows how to asynchronously list, recover and purge deleted certificates in a soft-delete enabled key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.... |
`%n` | public static void main(String[] args) throws IOException, InterruptedException, IllegalArgumentException {
KeyAsyncClient keyAsyncClient = new KeyClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
keyAsyncClient.createRsaKey(new RsaKeyCreateOptions("CloudRsa... | System.out.printf("Purge Status response %d \n", purgeResponse.getStatusCode())); | public static void main(String[] args) throws IOException, InterruptedException, IllegalArgumentException {
KeyAsyncClient keyAsyncClient = new KeyClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
keyAsyncClient.createRsaKey(new RsaKeyCreateOptions("CloudRsa... | class BackupAndRestoreOperationsAsync {
/**
* Authenticates with the key vault and shows how to asynchronously backup and restore keys in the key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws InterruptedException when the... | class BackupAndRestoreOperationsAsync {
/**
* Authenticates with the key vault and shows how to asynchronously backup and restore keys in the key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws InterruptedException when the... |
Don't need `\n` | public void purgeDeletedKeySnippets() {
KeyAsyncClient keyAsyncClient = createAsyncClient();
keyAsyncClient.purgeDeletedKey("deletedKeyName")
.subscribe(purgeResponse ->
System.out.println("Successfully Purged deleted Key \n"));
} | System.out.println("Successfully Purged deleted Key \n")); | public void purgeDeletedKeySnippets() {
KeyAsyncClient keyAsyncClient = createAsyncClient();
keyAsyncClient.purgeDeletedKey("deletedKeyName")
.subscribe(purgeResponse ->
System.out.println("Successfully Purged deleted Key"));
} | class KeyAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link KeyAsyncClient}
* @return An instance of {@link KeyAsyncClient}
*/
public KeyAsyncClient createAsyncClie... | class KeyAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link KeyAsyncClient}
* @return An instance of {@link KeyAsyncClient}
*/
public KeyAsyncClient createAsyncClie... |
`%n` | public static void main(String[] args) throws InterruptedException {
KeyAsyncClient keyAsyncClient = new KeyClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
Response<Key> createKeyResponse = keyAsyncClient.createRsaKeyWithResponse(new RsaKeyCreateOptions("C... | System.out.printf("Cloud Rsa key purge status response %d \n", purgeResponse.getStatusCode())); | public static void main(String[] args) throws InterruptedException {
KeyAsyncClient keyAsyncClient = new KeyClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
Response<Key> createKeyResponse = keyAsyncClient.createRsaKeyWithResponse(new RsaKeyCreateOptions("C... | class HelloWorldAsync {
/**
* Authenticates with the key vault and shows how to asynchronously set, get, update and delete a key in the key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws InterruptedException when the threa... | class HelloWorldAsync {
/**
* Authenticates with the key vault and shows how to asynchronously set, get, update and delete a key in the key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws InterruptedException when the threa... |
`%d%n`, remove the copy and paste error. | public void purgeDeletedKeyWithResponseSnippets() {
KeyAsyncClient keyAsyncClient = createAsyncClient();
keyAsyncClient.purgeDeletedKeyWithResponse("deletedKeyName")
.subscriberContext(Context.of(key1, value1, key2, value2))
.subscribe(purgeResponse ->
System.out.printf("Purge Status response %rsaPrivateExponent \n", p... | System.out.printf("Purge Status response %rsaPrivateExponent \n", purgeResponse.getStatusCode())); | public void purgeDeletedKeyWithResponseSnippets() {
KeyAsyncClient keyAsyncClient = createAsyncClient();
keyAsyncClient.purgeDeletedKeyWithResponse("deletedKeyName")
.subscriberContext(Context.of(key1, value1, key2, value2))
.subscribe(purgeResponse ->
System.out.printf("Purge Status response %d %n", purgeResponse.getS... | class KeyAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link KeyAsyncClient}
* @return An instance of {@link KeyAsyncClient}
*/
public KeyAsyncClient createAsyncClie... | class KeyAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link KeyAsyncClient}
* @return An instance of {@link KeyAsyncClient}
*/
public KeyAsyncClient createAsyncClie... |
`println` | public void purgeDeletedKeySnippets() {
KeyAsyncClient keyAsyncClient = createAsyncClient();
keyAsyncClient.purgeDeletedKey("deletedKeyName")
.subscribe(purgeResponse ->
System.out.printf("Successfully Purged deleted Key\n"));
} | System.out.printf("Successfully Purged deleted Key\n")); | public void purgeDeletedKeySnippets() {
KeyAsyncClient keyAsyncClient = createAsyncClient();
keyAsyncClient.purgeDeletedKey("deletedKeyName")
.subscribe(purgeResponse ->
System.out.println("Successfully Purged deleted Key"));
} | class KeyAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link KeyAsyncClient}
* @return An instance of {@link KeyAsyncClient}
*/
public KeyAsyncClient createAsyncClie... | class KeyAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link KeyAsyncClient}
* @return An instance of {@link KeyAsyncClient}
*/
public KeyAsyncClient createAsyncClie... |
Mind fixing the copy and paste error, `%d%n` | public void purgeDeletedKeyWithResponseSnippets() {
KeyClient keyClient = createClient();
Response<Void> purgedResponse = keyClient.purgeDeletedKeyWithResponse("deletedKeyName", new Context(key2, value2));
System.out.printf("Purge Status Code: %rsaPrivateExponent", purgedResponse.getStatusCode());
} | System.out.printf("Purge Status Code: %rsaPrivateExponent", purgedResponse.getStatusCode()); | public void purgeDeletedKeyWithResponseSnippets() {
KeyClient keyClient = createClient();
Response<Void> purgedResponse = keyClient.purgeDeletedKeyWithResponse("deletedKeyName", new Context(key2, value2));
System.out.printf("Purge Status Code: %d %n", purgedResponse.getStatusCode());
} | class KeyClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link KeyClient}
* @return An instance of {@link KeyClient}
*/
public KeyClient createClient() {
KeyClient keyClien... | class KeyClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link KeyClient}
* @return An instance of {@link KeyClient}
*/
public KeyClient createClient() {
KeyClient keyClien... |
`%n` | public static void main(String[] args) throws InterruptedException {
KeyAsyncClient keyAsyncClient = new KeyClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
keyAsyncClient.createEcKey(new EcKeyCreateOptions("CloudEcKey")
.setExpires(OffsetDateTime.now().plu... | System.out.printf("Storage account key purge status response %d \n", purgeResponse.getStatusCode())); | public static void main(String[] args) throws InterruptedException {
KeyAsyncClient keyAsyncClient = new KeyClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
keyAsyncClient.createEcKey(new EcKeyCreateOptions("CloudEcKey")
.setExpires(OffsetDateTime.now().plu... | class ManagingDeletedKeysAsync {
/**
* Authenticates with the key vault and shows how to asynchronously list, recover and purge deleted keys in a soft-delete enabled key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws Inter... | class ManagingDeletedKeysAsync {
/**
* Authenticates with the key vault and shows how to asynchronously list, recover and purge deleted keys in a soft-delete enabled key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws Inter... |
`%n` | public static void main(String[] args) throws InterruptedException {
KeyAsyncClient keyAsyncClient = new KeyClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
keyAsyncClient.createEcKey(new EcKeyCreateOptions("CloudEcKey")
.setExpires(OffsetDateTime.now().plu... | System.out.printf("Bank account key purge status response %d \n", purgeResponse.getStatusCode())); | public static void main(String[] args) throws InterruptedException {
KeyAsyncClient keyAsyncClient = new KeyClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
keyAsyncClient.createEcKey(new EcKeyCreateOptions("CloudEcKey")
.setExpires(OffsetDateTime.now().plu... | class ManagingDeletedKeysAsync {
/**
* Authenticates with the key vault and shows how to asynchronously list, recover and purge deleted keys in a soft-delete enabled key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws Inter... | class ManagingDeletedKeysAsync {
/**
* Authenticates with the key vault and shows how to asynchronously list, recover and purge deleted keys in a soft-delete enabled key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws Inter... |
Don't need `\n` | public void purgeDeletedSecretCodeSnippets() {
SecretAsyncClient secretAsyncClient = getAsyncSecretClient();
secretAsyncClient.purgeDeletedSecret("deletedSecretName")
.doOnSuccess(purgeResponse ->
System.out.println("Successfully Purged deleted Secret \n"));
} | System.out.println("Successfully Purged deleted Secret \n")); | public void purgeDeletedSecretCodeSnippets() {
SecretAsyncClient secretAsyncClient = getAsyncSecretClient();
secretAsyncClient.purgeDeletedSecret("deletedSecretName")
.doOnSuccess(purgeResponse ->
System.out.println("Successfully Purged deleted Secret"));
} | class SecretAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link SecretAsyncClient}
* @return An instance of {@link SecretAsyncClient}
*/
public SecretAsyncClient cre... | class SecretAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link SecretAsyncClient}
* @return An instance of {@link SecretAsyncClient}
*/
public SecretAsyncClient cre... |
`%n` | public static void main(String[] args) throws IOException, InterruptedException, IllegalArgumentException {
SecretAsyncClient secretAsyncClient = new SecretClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
secretAsyncClient.setSecret(new Secret("StorageAccou... | System.out.printf("Purge Status response %d \n", purgeResponse.getStatusCode())); | public static void main(String[] args) throws IOException, InterruptedException, IllegalArgumentException {
SecretAsyncClient secretAsyncClient = new SecretClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
secretAsyncClient.setSecret(new Secret("StorageAccou... | class BackupAndRestoreOperationsAsync {
/**
* Authenticates with the key vault and shows how to asynchronously backup and restore secrets in the key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws InterruptedException when ... | class BackupAndRestoreOperationsAsync {
/**
* Authenticates with the key vault and shows how to asynchronously backup and restore secrets in the key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws InterruptedException when ... |
`%n` | public static void main(String[] args) throws InterruptedException {
SecretAsyncClient secretAsyncClient = new SecretClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
secretAsyncClient.setSecret(new Secret("BankAccountPassword", "f4G34fMh8v")
.setExpires(Off... | System.out.printf("Bank account secret purge status response %d \n", purgeResponse.getStatusCode())); | public static void main(String[] args) throws InterruptedException {
SecretAsyncClient secretAsyncClient = new SecretClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
secretAsyncClient.setSecret(new Secret("BankAccountPassword", "f4G34fMh8v")
.setExpires(Off... | class HelloWorldAsync {
/**
* Authenticates with the key vault and shows how to asynchronously set, get, update and delete a secret in the key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws InterruptedException when the th... | class HelloWorldAsync {
/**
* Authenticates with the key vault and shows how to asynchronously set, get, update and delete a secret in the key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws InterruptedException when the th... |
`%n` | public static void main(String[] args) throws InterruptedException {
SecretAsyncClient secretAsyncClient = new SecretClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
secretAsyncClient.setSecret(new Secret("BankAccountPassword", "f4G34fMh8v")
.setExpires(Off... | System.out.printf("Storage account secret purge status response %d \n", purgeResponse.getStatusCode())); | public static void main(String[] args) throws InterruptedException {
SecretAsyncClient secretAsyncClient = new SecretClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
secretAsyncClient.setSecret(new Secret("BankAccountPassword", "f4G34fMh8v")
.setExpires(Off... | class ManagingDeletedSecretsAsync {
/**
* Authenticates with the key vault and shows how to asynchronously list, recover and purge deleted secrets in a soft-delete enabled key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws... | class ManagingDeletedSecretsAsync {
/**
* Authenticates with the key vault and shows how to asynchronously list, recover and purge deleted secrets in a soft-delete enabled key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws... |
`%n` | public static void main(String[] args) throws InterruptedException {
SecretAsyncClient secretAsyncClient = new SecretClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
secretAsyncClient.setSecret(new Secret("BankAccountPassword", "f4G34fMh8v")
.setExpires(Off... | System.out.printf("Bank account secret purge status response %d \n", purgeResponse.getStatusCode())); | public static void main(String[] args) throws InterruptedException {
SecretAsyncClient secretAsyncClient = new SecretClientBuilder()
.endpoint("https:
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
secretAsyncClient.setSecret(new Secret("BankAccountPassword", "f4G34fMh8v")
.setExpires(Off... | class ManagingDeletedSecretsAsync {
/**
* Authenticates with the key vault and shows how to asynchronously list, recover and purge deleted secrets in a soft-delete enabled key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws... | class ManagingDeletedSecretsAsync {
/**
* Authenticates with the key vault and shows how to asynchronously list, recover and purge deleted secrets in a soft-delete enabled key vault.
*
* @param args Unused. Arguments to the program.
* @throws IllegalArgumentException when invalid key vault endpoint is passed.
* @throws... |
`println` | public void purgeDeletedSecretCodeSnippets() {
SecretAsyncClient secretAsyncClient = getAsyncSecretClient();
secretAsyncClient.purgeDeletedSecret("deletedSecretName")
.doOnSuccess(purgeResponse ->
System.out.printf("Successfully Purged deleted Secret \n"));
} | System.out.printf("Successfully Purged deleted Secret \n")); | public void purgeDeletedSecretCodeSnippets() {
SecretAsyncClient secretAsyncClient = getAsyncSecretClient();
secretAsyncClient.purgeDeletedSecret("deletedSecretName")
.doOnSuccess(purgeResponse ->
System.out.println("Successfully Purged deleted Secret"));
} | class SecretAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link SecretAsyncClient}
* @return An instance of {@link SecretAsyncClient}
*/
public SecretAsyncClient cre... | class SecretAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link SecretAsyncClient}
* @return An instance of {@link SecretAsyncClient}
*/
public SecretAsyncClient cre... |
`%n` | public void purgeDeletedSecretWithResponseCodeSnippets() {
SecretAsyncClient secretAsyncClient = getAsyncSecretClient();
secretAsyncClient.purgeDeletedSecretWithResponse("deletedSecretName")
.subscriberContext(Context.of(key1, value1, key2, value2))
.subscribe(purgeResponse ->
System.out.printf("Purge Status response %... | System.out.printf("Purge Status response %d \n", purgeResponse.getStatusCode())); | public void purgeDeletedSecretWithResponseCodeSnippets() {
SecretAsyncClient secretAsyncClient = getAsyncSecretClient();
secretAsyncClient.purgeDeletedSecretWithResponse("deletedSecretName")
.subscriberContext(Context.of(key1, value1, key2, value2))
.subscribe(purgeResponse ->
System.out.printf("Purge Status response %... | class SecretAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link SecretAsyncClient}
* @return An instance of {@link SecretAsyncClient}
*/
public SecretAsyncClient cre... | class SecretAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link SecretAsyncClient}
* @return An instance of {@link SecretAsyncClient}
*/
public SecretAsyncClient cre... |
Don't need `\n` | public void purgeDeletedCertificateCodeSnippets() {
CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient();
certificateAsyncClient.purgeDeletedCertificate("deletedCertificateName")
.subscriberContext(Context.of(key1, value1, key2, value2))
.doOnSuccess(response -> System.out.println("Successfully P... | .doOnSuccess(response -> System.out.println("Successfully Purged certificate \n")); | public void purgeDeletedCertificateCodeSnippets() {
CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient();
certificateAsyncClient.purgeDeletedCertificate("deletedCertificateName")
.subscriberContext(Context.of(key1, value1, key2, value2))
.doOnSuccess(response -> System.out.println("Successfully P... | class CertificateAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link CertificateAsyncClient}
* @return An instance of {@link CertificateAsyncClient}
*/
public Certif... | class CertificateAsyncClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link CertificateAsyncClient}
* @return An instance of {@link CertificateAsyncClient}
*/
public Certif... |
You can create a static instance of this `ObjectMapper` to avoid creating lots of these objects for every `decryptBlob` call. | private EncryptionData getAndValidateEncryptionData(String encryptedDataString) {
if (encryptedDataString == null) {
throw logger.logExceptionAsError(new IllegalStateException(CryptographyConstants.DECRYPT_UNENCRYPTED_BLOB));
}
ObjectMapper objectMapper = new ObjectMapper();
try {
EncryptionData encryptionData = object... | ObjectMapper objectMapper = new ObjectMapper(); | private EncryptionData getAndValidateEncryptionData(String encryptedDataString) {
if (encryptedDataString == null) {
return null;
}
ObjectMapper objectMapper = new ObjectMapper();
try {
EncryptionData encryptionData = objectMapper.readValue(encryptedDataString, EncryptionData.class);
if (encryptionData == null) {
retur... | class with the specified key and resolver.
* <p>
* If the generated policy is intended to be used for encryption, users are expected to provide a key at the
* minimum. The absence of key will cause an exception to be thrown during encryption. If the generated policy is
* intended to be used for decryption, users can pr... | class with the specified key and resolver.
* <p>
* If the generated policy is intended to be used for encryption, users are expected to provide a key at the
* minimum. The absence of key will cause an exception to be thrown during encryption. If the generated policy is
* intended to be used for decryption, users can pr... |
Add an error message to indicate what was null everywhere you are using `Objects.requireNonNull` ```suggestion Objects.requireNonNull(encryptionData.contentEncryptionIV(), "contentEncryptionIV in encryptionData cannot be null"); ``` | private EncryptionData getAndValidateEncryptionData(String encryptedDataString) {
if (encryptedDataString == null) {
throw logger.logExceptionAsError(new IllegalStateException(CryptographyConstants.DECRYPT_UNENCRYPTED_BLOB));
}
ObjectMapper objectMapper = new ObjectMapper();
try {
EncryptionData encryptionData = object... | Objects.requireNonNull(encryptionData.contentEncryptionIV()); | private EncryptionData getAndValidateEncryptionData(String encryptedDataString) {
if (encryptedDataString == null) {
return null;
}
ObjectMapper objectMapper = new ObjectMapper();
try {
EncryptionData encryptionData = objectMapper.readValue(encryptedDataString, EncryptionData.class);
if (encryptionData == null) {
retur... | class with the specified key and resolver.
* <p>
* If the generated policy is intended to be used for encryption, users are expected to provide a key at the
* minimum. The absence of key will cause an exception to be thrown during encryption. If the generated policy is
* intended to be used for decryption, users can pr... | class with the specified key and resolver.
* <p>
* If the generated policy is intended to be used for encryption, users are expected to provide a key at the
* minimum. The absence of key will cause an exception to be thrown during encryption. If the generated policy is
* intended to be used for decryption, users can pr... |
This should throw NPE instead - https://azure.github.io/azure-sdk/java_implementation.html#java-errors-system-errors | private EncryptionData getAndValidateEncryptionData(String encryptedDataString) {
if (encryptedDataString == null) {
throw logger.logExceptionAsError(new IllegalStateException(CryptographyConstants.DECRYPT_UNENCRYPTED_BLOB));
}
ObjectMapper objectMapper = new ObjectMapper();
try {
EncryptionData encryptionData = object... | if (encryptedDataString == null) { | private EncryptionData getAndValidateEncryptionData(String encryptedDataString) {
if (encryptedDataString == null) {
return null;
}
ObjectMapper objectMapper = new ObjectMapper();
try {
EncryptionData encryptionData = objectMapper.readValue(encryptedDataString, EncryptionData.class);
if (encryptionData == null) {
retur... | class with the specified key and resolver.
* <p>
* If the generated policy is intended to be used for encryption, users are expected to provide a key at the
* minimum. The absence of key will cause an exception to be thrown during encryption. If the generated policy is
* intended to be used for decryption, users can pr... | class with the specified key and resolver.
* <p>
* If the generated policy is intended to be used for encryption, users are expected to provide a key at the
* minimum. The absence of key will cause an exception to be thrown during encryption. If the generated policy is
* intended to be used for decryption, users can pr... |
Don't need this check as the `blobName()` builder method already checks for null. | private AzureBlobStorageImpl constructImpl() {
Objects.requireNonNull(blobName, "'blobName' cannot be null.");
/*
Implicit and explicit root container access are functionally equivalent, but explicit references are easier
to read and debug.
*/
if (ImplUtils.isNullOrEmpty(containerName)) {
containerName = BlobContainerA... | Objects.requireNonNull(blobName, "'blobName' cannot be null."); | private AzureBlobStorageImpl constructImpl() {
Objects.requireNonNull(blobName, "'blobName' cannot be null.");
/*
Implicit and explicit root container access are functionally equivalent, but explicit references are easier
to read and debug.
*/
if (ImplUtils.isNullOrEmpty(containerName)) {
containerName = BlobContainerA... | class EncryptedBlobClientBuilder extends BaseBlobClientBuilder<EncryptedBlobClientBuilder> {
private final ClientLogger logger = new ClientLogger(EncryptedBlobClientBuilder.class);
private String containerName;
private String blobName;
private String snapshot;
private AsyncKeyEncryptionKey keyWrapper;
private AsyncKeyE... | class EncryptedBlobClientBuilder extends BaseBlobClientBuilder<EncryptedBlobClientBuilder> {
private final ClientLogger logger = new ClientLogger(EncryptedBlobClientBuilder.class);
private String containerName;
private String blobName;
private String snapshot;
private AsyncKeyEncryptionKey keyWrapper;
private AsyncKeyE... |
Was this a bug in the previously released preview? | public BlobContainerClientBuilder endpoint(String endpoint) {
try {
URL url = new URL(endpoint);
BlobUrlParts parts = BlobUrlParts.parse(url);
this.endpoint = parts.getScheme() + ":
this.containerName = parts.getBlobContainerName();
String sasToken = parts.getSasQueryParameters().encode();
if (!ImplUtils.isNullOrEmpty(... | if (!ImplUtils.isNullOrEmpty(sasToken)) { | public BlobContainerClientBuilder endpoint(String endpoint) {
try {
URL url = new URL(endpoint);
BlobUrlParts parts = BlobUrlParts.parse(url);
this.endpoint = parts.getScheme() + ":
this.containerName = parts.getBlobContainerName();
String sasToken = parts.getSasQueryParameters().encode();
if (!ImplUtils.isNullOrEmpty(... | class BlobContainerClientBuilder {
private final ClientLogger logger = new ClientLogger(BlobContainerClientBuilder.class);
private String endpoint;
private String accountName;
private String containerName;
private CpkInfo customerProvidedKey;
private SharedKeyCredential sharedKeyCredential;
private TokenCredential toke... | class BlobContainerClientBuilder {
private final ClientLogger logger = new ClientLogger(BlobContainerClientBuilder.class);
private String endpoint;
private String accountName;
private String containerName;
private CpkInfo customerProvidedKey;
private SharedKeyCredential sharedKeyCredential;
private TokenCredential toke... |
Yes, this appears to have been release with the incorrect boolean check. | public BlobContainerClientBuilder endpoint(String endpoint) {
try {
URL url = new URL(endpoint);
BlobUrlParts parts = BlobUrlParts.parse(url);
this.endpoint = parts.getScheme() + ":
this.containerName = parts.getBlobContainerName();
String sasToken = parts.getSasQueryParameters().encode();
if (!ImplUtils.isNullOrEmpty(... | if (!ImplUtils.isNullOrEmpty(sasToken)) { | public BlobContainerClientBuilder endpoint(String endpoint) {
try {
URL url = new URL(endpoint);
BlobUrlParts parts = BlobUrlParts.parse(url);
this.endpoint = parts.getScheme() + ":
this.containerName = parts.getBlobContainerName();
String sasToken = parts.getSasQueryParameters().encode();
if (!ImplUtils.isNullOrEmpty(... | class BlobContainerClientBuilder {
private final ClientLogger logger = new ClientLogger(BlobContainerClientBuilder.class);
private String endpoint;
private String accountName;
private String containerName;
private CpkInfo customerProvidedKey;
private SharedKeyCredential sharedKeyCredential;
private TokenCredential toke... | class BlobContainerClientBuilder {
private final ClientLogger logger = new ClientLogger(BlobContainerClientBuilder.class);
private String endpoint;
private String accountName;
private String containerName;
private CpkInfo customerProvidedKey;
private SharedKeyCredential sharedKeyCredential;
private TokenCredential toke... |
These are only used once. Do we need variables for these two? | private AzureBlobStorageImpl constructImpl() {
Objects.requireNonNull(blobName, "'blobName' cannot be null.");
checkValidEncryptionParameters();
/*
Implicit and explicit root container access are functionally equivalent, but explicit references are easier
to read and debug.
*/
if (ImplUtils.isNullOrEmpty(containerName)... | String userAgentName = BlobCryptographyConfiguration.NAME; | private AzureBlobStorageImpl constructImpl() {
Objects.requireNonNull(blobName, "'blobName' cannot be null.");
checkValidEncryptionParameters();
/*
Implicit and explicit root container access are functionally equivalent, but explicit references are easier
to read and debug.
*/
if (ImplUtils.isNullOrEmpty(containerName)... | class EncryptedBlobClientBuilder {
private final ClientLogger logger = new ClientLogger(EncryptedBlobClientBuilder.class);
private String endpoint;
private String accountName;
private String containerName;
private String blobName;
private String snapshot;
private SharedKeyCredential sharedKeyCredential;
private TokenCr... | class EncryptedBlobClientBuilder {
private final ClientLogger logger = new ClientLogger(EncryptedBlobClientBuilder.class);
private String endpoint;
private String accountName;
private String containerName;
private String blobName;
private String snapshot;
private SharedKeyCredential sharedKeyCredential;
private TokenCr... |
This usecase ,user stop polling after N second. I think user is not calling `cancelOperation` . Should we remove the call to `cancelOperation()` here ? | public void subscribeToAllPollEventStopPollingAfterNSecondsTest() {
Duration pollInterval = Duration.ofSeconds(1);
Duration waitTime = Duration.ofSeconds(3);
PollResponse<Response> success = new PollResponse<>(OperationStatus.SUCCESSFULLY_COMPLETED, new Response("Created: Cert A"));
PollResponse<Response> inProgress = ... | .verifyError(); | public void subscribeToAllPollEventStopPollingAfterNSecondsTest() {
Duration pollInterval = Duration.ofSeconds(1);
Duration waitTime = Duration.ofSeconds(3);
PollResponse<Response> success = new PollResponse<>(OperationStatus.SUCCESSFULLY_COMPLETED, new Response("Created: Cert A"));
PollResponse<Response> inProgress = ... | class PollerTests {
@Mock
private Function<PollResponse<Response>, Mono<PollResponse<Response>>> pollOperation;
@Mock
private Consumer<Poller<Response>> cancelOperation;
@Before
public void beforeTest() {
MockitoAnnotations.initMocks(this);
}
@After
public void afterTest() {
Mockito.framework().clearInlineMocks();
}
/*... | class PollerTests {
@Mock
private Function<PollResponse<Response>, Mono<PollResponse<Response>>> pollOperation;
@Mock
private Consumer<Poller<Response>> cancelOperation;
@Before
public void beforeTest() {
MockitoAnnotations.initMocks(this);
}
@After
public void afterTest() {
Mockito.framework().clearInlineMocks();
}
/*... |
Fixed. | public void subscribeToAllPollEventStopPollingAfterNSecondsTest() {
Duration pollInterval = Duration.ofSeconds(1);
Duration waitTime = Duration.ofSeconds(3);
PollResponse<Response> success = new PollResponse<>(OperationStatus.SUCCESSFULLY_COMPLETED, new Response("Created: Cert A"));
PollResponse<Response> inProgress = ... | .verifyError(); | public void subscribeToAllPollEventStopPollingAfterNSecondsTest() {
Duration pollInterval = Duration.ofSeconds(1);
Duration waitTime = Duration.ofSeconds(3);
PollResponse<Response> success = new PollResponse<>(OperationStatus.SUCCESSFULLY_COMPLETED, new Response("Created: Cert A"));
PollResponse<Response> inProgress = ... | class PollerTests {
@Mock
private Function<PollResponse<Response>, Mono<PollResponse<Response>>> pollOperation;
@Mock
private Consumer<Poller<Response>> cancelOperation;
@Before
public void beforeTest() {
MockitoAnnotations.initMocks(this);
}
@After
public void afterTest() {
Mockito.framework().clearInlineMocks();
}
/*... | class PollerTests {
@Mock
private Function<PollResponse<Response>, Mono<PollResponse<Response>>> pollOperation;
@Mock
private Consumer<Poller<Response>> cancelOperation;
@Before
public void beforeTest() {
MockitoAnnotations.initMocks(this);
}
@After
public void afterTest() {
Mockito.framework().clearInlineMocks();
}
/*... |
Null check? | public static OperationStatus fromString(String name, boolean isComplete) {
OperationStatus status = fromString(name, OperationStatus.class);
status.completed = isComplete;
return status;
} | OperationStatus status = fromString(name, OperationStatus.class); | public static OperationStatus fromString(String name, boolean isComplete) {
OperationStatus status = fromString(name, OperationStatus.class);
if (status != null) {
if (operationStatusMap != null && operationStatusMap.containsKey(name)) {
OperationStatus operationStatus = operationStatusMap.get(name);
if (operationStatu... | class OperationStatus extends ExpandableStringEnum<OperationStatus> {
private boolean completed;
/** Represents that polling has not yet started for this long-running operation. */
public static final OperationStatus NOT_STARTED = fromString("NOT_STARTED", false);
/** Represents that this long-running operation is in p... | class OperationStatus extends ExpandableStringEnum<OperationStatus> {
private boolean completed;
/** Represents that polling has not yet started for this long-running operation. */
public static final OperationStatus NOT_STARTED = fromString("NOT_STARTED", false);
/** Represents that this long-running operation is in p... |
nit: double space. | public static OperationStatus fromString(String name, boolean isComplete) {
OperationStatus status = fromString(name, OperationStatus.class);
status.completed = isComplete;
return status;
} | OperationStatus status = fromString(name, OperationStatus.class); | public static OperationStatus fromString(String name, boolean isComplete) {
OperationStatus status = fromString(name, OperationStatus.class);
if (status != null) {
if (operationStatusMap != null && operationStatusMap.containsKey(name)) {
OperationStatus operationStatus = operationStatusMap.get(name);
if (operationStatu... | class OperationStatus extends ExpandableStringEnum<OperationStatus> {
private boolean completed;
/** Represents that polling has not yet started for this long-running operation. */
public static final OperationStatus NOT_STARTED = fromString("NOT_STARTED", false);
/** Represents that this long-running operation is in p... | class OperationStatus extends ExpandableStringEnum<OperationStatus> {
private boolean completed;
/** Represents that polling has not yet started for this long-running operation. */
public static final OperationStatus NOT_STARTED = fromString("NOT_STARTED", false);
/** Represents that this long-running operation is in p... |
What if cancelOepration throws an exception? | public Mono<T> cancelOperation() throws UnsupportedOperationException {
if (this.cancelOperation == null) {
throw logger.logExceptionAsError(new UnsupportedOperationException(
"Cancel operation is not supported on this service/resource."));
}
final PollResponse<T> response = this.pollResponse;
if (response != null && r... | return this.cancelOperation.apply(this); | public Mono<T> cancelOperation() {
if (this.cancelOperation == null) {
return Mono.error(logger.logExceptionAsError(new UnsupportedOperationException(
"Cancel operation is not supported on this service/resource.")));
}
final PollResponse<T> response = this.pollResponse;
if (response != null && response.getStatus() != O... | class Poller<T, R> {
private final ClientLogger logger = new ClientLogger(Poller.class);
/*
* poll operation is a function that takes the previous PollResponse, and returns a new Mono of PollResponse to
* represent the current state
*/
private final Function<PollResponse<T>, Mono<PollResponse<T>>> pollOperation;
/*
* p... | class Poller<T, R> {
private final ClientLogger logger = new ClientLogger(Poller.class);
/*
* poll operation is a function that takes the previous PollResponse, and returns a new Mono of PollResponse to
* represent the current state
*/
private final Function<PollResponse<T>, Mono<PollResponse<T>>> pollOperation;
/*
* p... |
If its a REST call in cancelOperation then the behavoiur will be same as an API call. User can specify .onError on the Mono returned to them from cancelOperation. if needed in CancelOperation, Mono.error should be returned there. | public Mono<T> cancelOperation() throws UnsupportedOperationException {
if (this.cancelOperation == null) {
throw logger.logExceptionAsError(new UnsupportedOperationException(
"Cancel operation is not supported on this service/resource."));
}
final PollResponse<T> response = this.pollResponse;
if (response != null && r... | return this.cancelOperation.apply(this); | public Mono<T> cancelOperation() {
if (this.cancelOperation == null) {
return Mono.error(logger.logExceptionAsError(new UnsupportedOperationException(
"Cancel operation is not supported on this service/resource.")));
}
final PollResponse<T> response = this.pollResponse;
if (response != null && response.getStatus() != O... | class Poller<T, R> {
private final ClientLogger logger = new ClientLogger(Poller.class);
/*
* poll operation is a function that takes the previous PollResponse, and returns a new Mono of PollResponse to
* represent the current state
*/
private final Function<PollResponse<T>, Mono<PollResponse<T>>> pollOperation;
/*
* p... | class Poller<T, R> {
private final ClientLogger logger = new ClientLogger(Poller.class);
/*
* poll operation is a function that takes the previous PollResponse, and returns a new Mono of PollResponse to
* represent the current state
*/
private final Function<PollResponse<T>, Mono<PollResponse<T>>> pollOperation;
/*
* p... |
fixed. | public static OperationStatus fromString(String name, boolean isComplete) {
OperationStatus status = fromString(name, OperationStatus.class);
status.completed = isComplete;
return status;
} | OperationStatus status = fromString(name, OperationStatus.class); | public static OperationStatus fromString(String name, boolean isComplete) {
OperationStatus status = fromString(name, OperationStatus.class);
if (status != null) {
if (operationStatusMap != null && operationStatusMap.containsKey(name)) {
OperationStatus operationStatus = operationStatusMap.get(name);
if (operationStatu... | class OperationStatus extends ExpandableStringEnum<OperationStatus> {
private boolean completed;
/** Represents that polling has not yet started for this long-running operation. */
public static final OperationStatus NOT_STARTED = fromString("NOT_STARTED", false);
/** Represents that this long-running operation is in p... | class OperationStatus extends ExpandableStringEnum<OperationStatus> {
private boolean completed;
/** Represents that polling has not yet started for this long-running operation. */
public static final OperationStatus NOT_STARTED = fromString("NOT_STARTED", false);
/** Represents that this long-running operation is in p... |
if status == null, I think we should throw something because this should not happen. Not sure what you'd do with a null status. | public static OperationStatus fromString(String name, boolean isComplete) {
OperationStatus status = fromString(name, OperationStatus.class);
if (status != null) {
for (OperationStatus opStatus : values(OperationStatus.class)) {
if (opStatus.toString().equals(name)) {
if (!(opStatus.isComplete() == isComplete)) {
throw... | if (status != null) { | public static OperationStatus fromString(String name, boolean isComplete) {
OperationStatus status = fromString(name, OperationStatus.class);
if (status != null) {
if (operationStatusMap != null && operationStatusMap.containsKey(name)) {
OperationStatus operationStatus = operationStatusMap.get(name);
if (operationStatu... | class OperationStatus extends ExpandableStringEnum<OperationStatus> {
private boolean completed;
/** Represents that polling has not yet started for this long-running operation. */
public static final OperationStatus NOT_STARTED = fromString("NOT_STARTED", false);
/** Represents that this long-running operation is in p... | class OperationStatus extends ExpandableStringEnum<OperationStatus> {
private boolean completed;
/** Represents that polling has not yet started for this long-running operation. */
public static final OperationStatus NOT_STARTED = fromString("NOT_STARTED", false);
/** Represents that this long-running operation is in p... |
Why a for loop? The one returned `fromString(name, OperationStatus.class)` will return one from the dictionary if it was added before. Then you can do: ```java OperationStatus status = fromString(name, OperationStatus.class); if (status.isComplete() != isComplete) { // throw. } return status; ``` | public static OperationStatus fromString(String name, boolean isComplete) {
OperationStatus status = fromString(name, OperationStatus.class);
if (status != null) {
for (OperationStatus opStatus : values(OperationStatus.class)) {
if (opStatus.toString().equals(name)) {
if (!(opStatus.isComplete() == isComplete)) {
throw... | for (OperationStatus opStatus : values(OperationStatus.class)) { | public static OperationStatus fromString(String name, boolean isComplete) {
OperationStatus status = fromString(name, OperationStatus.class);
if (status != null) {
if (operationStatusMap != null && operationStatusMap.containsKey(name)) {
OperationStatus operationStatus = operationStatusMap.get(name);
if (operationStatu... | class OperationStatus extends ExpandableStringEnum<OperationStatus> {
private boolean completed;
/** Represents that polling has not yet started for this long-running operation. */
public static final OperationStatus NOT_STARTED = fromString("NOT_STARTED", false);
/** Represents that this long-running operation is in p... | class OperationStatus extends ExpandableStringEnum<OperationStatus> {
private boolean completed;
/** Represents that polling has not yet started for this long-running operation. */
public static final OperationStatus NOT_STARTED = fromString("NOT_STARTED", false);
/** Represents that this long-running operation is in p... |
The intention is to check against only defined by us. So replaced with a static map and check against it. | public static OperationStatus fromString(String name, boolean isComplete) {
OperationStatus status = fromString(name, OperationStatus.class);
if (status != null) {
for (OperationStatus opStatus : values(OperationStatus.class)) {
if (opStatus.toString().equals(name)) {
if (!(opStatus.isComplete() == isComplete)) {
throw... | for (OperationStatus opStatus : values(OperationStatus.class)) { | public static OperationStatus fromString(String name, boolean isComplete) {
OperationStatus status = fromString(name, OperationStatus.class);
if (status != null) {
if (operationStatusMap != null && operationStatusMap.containsKey(name)) {
OperationStatus operationStatus = operationStatusMap.get(name);
if (operationStatu... | class OperationStatus extends ExpandableStringEnum<OperationStatus> {
private boolean completed;
/** Represents that polling has not yet started for this long-running operation. */
public static final OperationStatus NOT_STARTED = fromString("NOT_STARTED", false);
/** Represents that this long-running operation is in p... | class OperationStatus extends ExpandableStringEnum<OperationStatus> {
private boolean completed;
/** Represents that polling has not yet started for this long-running operation. */
public static final OperationStatus NOT_STARTED = fromString("NOT_STARTED", false);
/** Represents that this long-running operation is in p... |
looking at expandable String enum code, it returns null if String name is null. So, we are returning null for null name input, across all classes who extend ExpandableStringEnum. This code will be consistent too. | public static OperationStatus fromString(String name, boolean isComplete) {
OperationStatus status = fromString(name, OperationStatus.class);
if (status != null) {
for (OperationStatus opStatus : values(OperationStatus.class)) {
if (opStatus.toString().equals(name)) {
if (!(opStatus.isComplete() == isComplete)) {
throw... | if (status != null) { | public static OperationStatus fromString(String name, boolean isComplete) {
OperationStatus status = fromString(name, OperationStatus.class);
if (status != null) {
if (operationStatusMap != null && operationStatusMap.containsKey(name)) {
OperationStatus operationStatus = operationStatusMap.get(name);
if (operationStatu... | class OperationStatus extends ExpandableStringEnum<OperationStatus> {
private boolean completed;
/** Represents that polling has not yet started for this long-running operation. */
public static final OperationStatus NOT_STARTED = fromString("NOT_STARTED", false);
/** Represents that this long-running operation is in p... | class OperationStatus extends ExpandableStringEnum<OperationStatus> {
private boolean completed;
/** Represents that polling has not yet started for this long-running operation. */
public static final OperationStatus NOT_STARTED = fromString("NOT_STARTED", false);
/** Represents that this long-running operation is in p... |
We add code snippets for aborting/cancelling the copy operation. | public void startCopyFromURL() {
final Poller<BlobCopyInfo, Void> poller = client.beginCopyFromUrl(url);
poller.getObserver().subscribe(response -> {
System.out.printf("Copy identifier: %s%n", response.getValue().getCopyId());
});
} | public void startCopyFromURL() {
final Poller<BlobCopyInfo, Void> poller = client.beginCopy(url, Duration.ofSeconds(2));
poller.getObserver().subscribe(response -> {
System.out.printf("Copy identifier: %s%n", response.getValue().getCopyId());
});
} | class BlobClientBaseJavaDocCodeSnippets {
private BlobClientBase client = new BlobClientBase(null);
private String leaseId = "leaseId";
private String copyId = "copyId";
private URL url = new URL("https:
private String file = "file";
private Duration timeout = Duration.ofSeconds(30);
private String key1 = "key1";
priva... | class BlobClientBaseJavaDocCodeSnippets {
private BlobClientBase client = new BlobClientBase(null);
private String leaseId = "leaseId";
private String copyId = "copyId";
private String url = "https:
private String file = "file";
private Duration timeout = Duration.ofSeconds(30);
private String key1 = "key1";
private St... | |
We should also add the copy status into this. | public void startCopyFromURL() {
final Poller<BlobCopyInfo, Void> poller = client.beginCopyFromUrl(url);
poller.getObserver().subscribe(response -> {
System.out.printf("Copy identifier: %s%n", response.getValue().getCopyId());
});
} | System.out.printf("Copy identifier: %s%n", response.getValue().getCopyId()); | public void startCopyFromURL() {
final Poller<BlobCopyInfo, Void> poller = client.beginCopy(url, Duration.ofSeconds(2));
poller.getObserver().subscribe(response -> {
System.out.printf("Copy identifier: %s%n", response.getValue().getCopyId());
});
} | class BlobClientBaseJavaDocCodeSnippets {
private BlobClientBase client = new BlobClientBase(null);
private String leaseId = "leaseId";
private String copyId = "copyId";
private URL url = new URL("https:
private String file = "file";
private Duration timeout = Duration.ofSeconds(30);
private String key1 = "key1";
priva... | class BlobClientBaseJavaDocCodeSnippets {
private BlobClientBase client = new BlobClientBase(null);
private String leaseId = "leaseId";
private String copyId = "copyId";
private String url = "https:
private String file = "file";
private Duration timeout = Duration.ofSeconds(30);
private String key1 = "key1";
private St... |
Does `FAILED` really correspond to `NOT_STARTED`? | private Mono<PollResponse<BlobCopyInfo>> onPoll(PollResponse<BlobCopyInfo> pollResponse) {
if (pollResponse.getStatus() == OperationStatus.SUCCESSFULLY_COMPLETED
|| pollResponse.getStatus() == OperationStatus.FAILED) {
return Mono.just(pollResponse);
}
final BlobCopyInfo lastInfo = pollResponse.getValue();
if (lastInfo... | return new PollResponse<>(operationStatus, result); | return getProperties().map(response -> {
final CopyStatusType status = response.getCopyStatus();
final BlobCopyInfo result = new BlobCopyInfo(response.getCopySource(), response.getCopyId(), status,
response.getETag(), response.getCopyCompletionTime(), response.getCopyStatusDescription());
OperationStatus operationStatu... | class BlobAsyncClientBase {
private static final int BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB;
private static final int BLOB_MAX_DOWNLOAD_BLOCK_SIZE = 100 * Constants.MB;
private final ClientLogger logger = new ClientLogger(BlobAsyncClientBase.class);
protected final AzureBlobStorageImpl azureBlobStorage;
pr... | class BlobAsyncClientBase {
private static final int BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB;
private static final int BLOB_MAX_DOWNLOAD_BLOCK_SIZE = 100 * Constants.MB;
private final ClientLogger logger = new ClientLogger(BlobAsyncClientBase.class);
protected final AzureBlobStorageImpl azureBlobStorage;
pr... |
Should these be `CopyStatusType.SUCCESS`? | private Mono<PollResponse<BlobCopyInfo>> onPoll(PollResponse<BlobCopyInfo> pollResponse) {
if (pollResponse.getStatus() == OperationStatus.SUCCESSFULLY_COMPLETED
|| pollResponse.getStatus() == OperationStatus.FAILED) {
return Mono.just(pollResponse);
}
final BlobCopyInfo lastInfo = pollResponse.getValue();
if (lastInfo... | "CopyStatusType is not supported. Status: " + status))); | return getProperties().map(response -> {
final CopyStatusType status = response.getCopyStatus();
final BlobCopyInfo result = new BlobCopyInfo(response.getCopySource(), response.getCopyId(), status,
response.getETag(), response.getCopyCompletionTime(), response.getCopyStatusDescription());
OperationStatus operationStatu... | class BlobAsyncClientBase {
private static final int BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB;
private static final int BLOB_MAX_DOWNLOAD_BLOCK_SIZE = 100 * Constants.MB;
private final ClientLogger logger = new ClientLogger(BlobAsyncClientBase.class);
protected final AzureBlobStorageImpl azureBlobStorage;
pr... | class BlobAsyncClientBase {
private static final int BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB;
private static final int BLOB_MAX_DOWNLOAD_BLOCK_SIZE = 100 * Constants.MB;
private final ClientLogger logger = new ClientLogger(BlobAsyncClientBase.class);
protected final AzureBlobStorageImpl azureBlobStorage;
pr... |
I added a static import for CopyStatusType, so it doesn't need it. | private Mono<PollResponse<BlobCopyInfo>> onPoll(PollResponse<BlobCopyInfo> pollResponse) {
if (pollResponse.getStatus() == OperationStatus.SUCCESSFULLY_COMPLETED
|| pollResponse.getStatus() == OperationStatus.FAILED) {
return Mono.just(pollResponse);
}
final BlobCopyInfo lastInfo = pollResponse.getValue();
if (lastInfo... | "CopyStatusType is not supported. Status: " + status))); | return getProperties().map(response -> {
final CopyStatusType status = response.getCopyStatus();
final BlobCopyInfo result = new BlobCopyInfo(response.getCopySource(), response.getCopyId(), status,
response.getETag(), response.getCopyCompletionTime(), response.getCopyStatusDescription());
OperationStatus operationStatu... | class BlobAsyncClientBase {
private static final int BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB;
private static final int BLOB_MAX_DOWNLOAD_BLOCK_SIZE = 100 * Constants.MB;
private final ClientLogger logger = new ClientLogger(BlobAsyncClientBase.class);
protected final AzureBlobStorageImpl azureBlobStorage;
pr... | class BlobAsyncClientBase {
private static final int BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB;
private static final int BLOB_MAX_DOWNLOAD_BLOCK_SIZE = 100 * Constants.MB;
private final ClientLogger logger = new ClientLogger(BlobAsyncClientBase.class);
protected final AzureBlobStorageImpl azureBlobStorage;
pr... |
check handled in impl | public void endSpan(Context context, Signal<Void> signal) {
Objects.requireNonNull(context, "'context' cannot be null.");
Objects.requireNonNull(signal, "'signal' cannot be null.");
switch (signal.getType()) {
case ON_COMPLETE:
end("success", null, context);
break;
case ON_ERROR:
String errorCondition = "";
Throwable t... | end("success", null, context); | public void endSpan(Context context, Signal<Void> signal) {
Objects.requireNonNull(context, "'context' cannot be null.");
Objects.requireNonNull(signal, "'signal' cannot be null.");
switch (signal.getType()) {
case ON_COMPLETE:
end("success", null, context);
break;
case ON_ERROR:
String errorCondition = "";
Throwable t... | class TracerProvider {
private final ClientLogger logger = new ClientLogger(TracerProvider.class);
private final List<Tracer> tracers = new ArrayList<>();
public TracerProvider(Iterable<Tracer> tracers) {
Objects.requireNonNull(tracers, "'tracers' cannot be null.");
tracers.forEach(e -> this.tracers.add(e));
}
public b... | class TracerProvider {
private final ClientLogger logger = new ClientLogger(TracerProvider.class);
private final List<Tracer> tracers = new ArrayList<>();
public TracerProvider(Iterable<Tracer> tracers) {
Objects.requireNonNull(tracers, "'tracers' cannot be null.");
tracers.forEach(e -> this.tracers.add(e));
}
public b... |
You are swallowing the `MalformedURLException` here - you should be sure to include the `e` object as well, either instead of the `IllegalArgumentException`, or as an argument into that exception if it has an appropriate constructor. | public HttpRequest(HttpMethod httpMethod, String url) {
this.httpMethod = httpMethod;
try {
this.url = new URL(url);
} catch (MalformedURLException e) {
throw logger.logExceptionAsWarning(new IllegalArgumentException("'url' must be a valid URL"));
}
this.headers = new HttpHeaders();
} | throw logger.logExceptionAsWarning(new IllegalArgumentException("'url' must be a valid URL")); | public HttpRequest(HttpMethod httpMethod, String url) {
this.httpMethod = httpMethod;
try {
this.url = new URL(url);
} catch (MalformedURLException ex) {
throw logger.logExceptionAsWarning(new IllegalArgumentException("'url' must be a valid URL", ex));
}
this.headers = new HttpHeaders();
} | class HttpRequest implements Serializable {
private static final long serialVersionUID = 6338479743058758810L;
private final ClientLogger logger = new ClientLogger(HttpRequest.class);
private HttpMethod httpMethod;
private URL url;
private HttpHeaders headers;
private Flux<ByteBuffer> body;
/**
* Create a new HttpReque... | class HttpRequest {
private final ClientLogger logger = new ClientLogger(HttpRequest.class);
private HttpMethod httpMethod;
private URL url;
private HttpHeaders headers;
private Flux<ByteBuffer> body;
/**
* Create a new HttpRequest instance.
*
* @param httpMethod the HTTP request method
* @param url the target address ... |
👍 | public HttpRequest(HttpMethod httpMethod, String url) {
this.httpMethod = httpMethod;
try {
this.url = new URL(url);
} catch (MalformedURLException e) {
throw logger.logExceptionAsWarning(new IllegalArgumentException("'url' must be a valid URL"));
}
this.headers = new HttpHeaders();
} | throw logger.logExceptionAsWarning(new IllegalArgumentException("'url' must be a valid URL")); | public HttpRequest(HttpMethod httpMethod, String url) {
this.httpMethod = httpMethod;
try {
this.url = new URL(url);
} catch (MalformedURLException ex) {
throw logger.logExceptionAsWarning(new IllegalArgumentException("'url' must be a valid URL", ex));
}
this.headers = new HttpHeaders();
} | class HttpRequest implements Serializable {
private static final long serialVersionUID = 6338479743058758810L;
private final ClientLogger logger = new ClientLogger(HttpRequest.class);
private HttpMethod httpMethod;
private URL url;
private HttpHeaders headers;
private Flux<ByteBuffer> body;
/**
* Create a new HttpReque... | class HttpRequest {
private final ClientLogger logger = new ClientLogger(HttpRequest.class);
private HttpMethod httpMethod;
private URL url;
private HttpHeaders headers;
private Flux<ByteBuffer> body;
/**
* Create a new HttpRequest instance.
*
* @param httpMethod the HTTP request method
* @param url the target address ... |
Same here. Add `e` as an argument to the `IllegalArgumentException` constructor. | public HttpRequest setUrl(String url) {
try {
this.url = new URL(url);
} catch (MalformedURLException e) {
throw logger.logExceptionAsWarning(new IllegalArgumentException("'url' must be a valid URL."));
}
return this;
} | throw logger.logExceptionAsWarning(new IllegalArgumentException("'url' must be a valid URL.")); | public HttpRequest setUrl(String url) {
try {
this.url = new URL(url);
} catch (MalformedURLException ex) {
throw logger.logExceptionAsWarning(new IllegalArgumentException("'url' must be a valid URL.", ex));
}
return this;
} | class HttpRequest implements Serializable {
private static final long serialVersionUID = 6338479743058758810L;
private final ClientLogger logger = new ClientLogger(HttpRequest.class);
private HttpMethod httpMethod;
private URL url;
private HttpHeaders headers;
private Flux<ByteBuffer> body;
/**
* Create a new HttpReque... | class HttpRequest {
private final ClientLogger logger = new ClientLogger(HttpRequest.class);
private HttpMethod httpMethod;
private URL url;
private HttpHeaders headers;
private Flux<ByteBuffer> body;
/**
* Create a new HttpRequest instance.
*
* @param httpMethod the HTTP request method
* @param url the target address ... |
Same here and in few other places. Change to `continuationToken` | public String getContinuationToken() {
return this.nextLink;
} | return this.nextLink; | public String getContinuationToken() {
return this.continuationToken;
} | class DeletedCertificatePage implements Page<DeletedCertificate> {
/**
* The link to the next page.
*/
@JsonProperty("nextLink")
private String nextLink;
/**
* The list of items.
*/
@JsonProperty("value")
private List<DeletedCertificate> items;
/**
* Gets the link to the next page. Or {@code null} if there are no more ... | class DeletedCertificatePage implements Page<DeletedCertificate> {
/**
* The link to the next page.
*/
@JsonProperty("nextLink")
private String continuationToken;
/**
* The list of items.
*/
@JsonProperty("value")
private List<DeletedCertificate> items;
/**
* Gets the link to the next page. Or {@code null} if there are... |
Should be `hostname` rather than `hostName`. | public void addDataToContext() {
final String hostNameValue = "host-name-value";
final String entityPathValue = "entity-path-value";
final String userParentSpan = "user-parent-span";
final String openCensusSpanKey = "opencensus-span";
final String hostName = "hostName-key";
final String entityPath = "entity-path-key";
... | Context updatedContext = parentSpanContext.addData(hostName, hostNameValue) | public void addDataToContext() {
final String hostNameValue = "host-name-value";
final String entityPathValue = "entity-path-value";
final String userParentSpan = "user-parent-span";
Context parentSpanContext = new Context(PARENT_SPAN_KEY, userParentSpan);
Context updatedContext = parentSpanContext.addData(HOST_NAME_KE... | class ContextJavaDocCodeSnippets {
/**
* Code snippet for {@link Context
*/
public void constructContextObject() {
Context emptyContext = Context.NONE;
final String userParentSpan = "user-parent-span";
final String openCensusSpanKey = "opencensus-span";
Context keyValueContext = new Context(openCensusSpanKey, userParen... | class ContextJavaDocCodeSnippets {
/**
* Code snippet for {@link Context
*/
public void constructContextObject() {
Context emptyContext = Context.NONE;
final String userParentSpan = "user-parent-span";
Context keyValueContext = new Context(PARENT_SPAN_KEY, userParentSpan);
}
/**
* Code snippet for creating Context obje... |
`hostnameKey` | public void startTracingSpan() {
String openCensusSpanKey = "opencensus-span";
Context traceContext = new Context(openCensusSpanKey, "<user-current-span>");
Context updatedContext = tracer.start("azure.keyvault.secrets/setsecret", traceContext);
System.out.printf("Span returned in the context object: %s%n",
updatedCont... | .addData(entityPathKey, "entity-path").addData(hostNameKey, "hostname"); | public void startTracingSpan() {
Context traceContext = new Context(PARENT_SPAN_KEY, "<user-current-span>");
Context updatedContext = tracer.start("azure.keyvault.secrets/setsecret", traceContext);
System.out.printf("Span returned in the context object: %s%n",
updatedContext.getData(PARENT_SPAN_KEY).get());
Context sen... | class TracerJavaDocCodeSnippets {
final Tracer tracer = new TracerImplementation();
/**
* Code snippet for {@link Tracer
*/
/**
* Code snippet for {@link Tracer
*/
public void endTracingSpan() {
String openCensusSpanKey = "opencensus-span";
Context traceContext = new Context(openCensusSpanKey, "<user-current-span>");
t... | class TracerJavaDocCodeSnippets {
final Tracer tracer = new TracerImplementation();
/**
* Code snippet for {@link Tracer
*/
/**
* Code snippet for {@link Tracer
*/
public void endTracingSpan() {
String openCensusSpanKey = "opencensus-span";
Context traceContext = new Context(PARENT_SPAN_KEY, "<user-current-span>");
tra... |
Instead of redefining all these strings. There is a constants class you can put these into. Or at least at the top of the file. is "entity-Path" what you intend? | private Mono<Void> sendInternalTracingEnabled(Flux<EventData> events, String partitionKey) {
return sendLinkMono.flatMap(link -> {
final AtomicReference<Context> sendSpanContext = new AtomicReference<>(Context.NONE);
return link.getLinkSize()
.flatMap(size -> {
final int batchSize = size > 0 ? size : MAX_MESSAGE_LENGTH... | Context entityContext = parentContext.addData("entity-Path", link.getEntityPath()); | private Mono<Void> sendInternalTracingEnabled(Flux<EventData> events, String partitionKey) {
return sendLinkMono.flatMap(link -> {
final AtomicReference<Context> sendSpanContext = new AtomicReference<>(Context.NONE);
return link.getLinkSize()
.flatMap(size -> {
final int batchSize = size > 0 ? size : MAX_MESSAGE_LENGTH... | class EventHubAsyncProducer implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final BatchOptions DEFAULT_BATCH_OPTIONS = new BatchOptions();
private final ClientLogger logger = new ClientLogger(EventH... | class EventHubAsyncProducer implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final BatchOptions DEFAULT_BATCH_OPTIONS = new BatchOptions();
private final ClientLogger logger = new ClientLogger(EventH... |
Use a shared constants class in event hubs so we don't have to redefine these shared strings. There is a ClientConstants class. | public void startPartitionPump(PartitionOwnership claimedOwnership) {
if (partitionPumps.containsKey(claimedOwnership.getPartitionId())) {
logger.info("Consumer is already running for this partition {}", claimedOwnership.getPartitionId());
return;
}
PartitionContext partitionContext = new PartitionContext(claimedOwner... | if (processSpanContext.getData("span-context").isPresent()) { | public void startPartitionPump(PartitionOwnership claimedOwnership) {
if (partitionPumps.containsKey(claimedOwnership.getPartitionId())) {
logger.info("Consumer is already running for this partition {}", claimedOwnership.getPartitionId());
return;
}
PartitionContext partitionContext = new PartitionContext(claimedOwner... | class PartitionPumpManager {
private final ClientLogger logger = new ClientLogger(PartitionPumpManager.class);
private final Map<String, EventHubAsyncConsumer> partitionPumps = new ConcurrentHashMap<>();
private final PartitionManager partitionManager;
private final Supplier<PartitionProcessor> partitionProcessorFactor... | class PartitionPumpManager {
private final ClientLogger logger = new ClientLogger(PartitionPumpManager.class);
private final Map<String, EventHubAsyncConsumer> partitionPumps = new ConcurrentHashMap<>();
private final PartitionManager partitionManager;
private final Supplier<PartitionProcessor> partitionProcessorFactor... |
There is a ClientConstants class. | private Mono<Void> sendInternalTracingEnabled(Flux<EventData> events, String partitionKey) {
return sendLinkMono.flatMap(link -> {
final AtomicReference<Context> sendSpanContext = new AtomicReference<>(Context.NONE);
return link.getLinkSize()
.flatMap(size -> {
final int batchSize = size > 0 ? size : MAX_MESSAGE_LENGTH... | Context entityContext = parentContext.addData("entity-Path", link.getEntityPath()); | private Mono<Void> sendInternalTracingEnabled(Flux<EventData> events, String partitionKey) {
return sendLinkMono.flatMap(link -> {
final AtomicReference<Context> sendSpanContext = new AtomicReference<>(Context.NONE);
return link.getLinkSize()
.flatMap(size -> {
final int batchSize = size > 0 ? size : MAX_MESSAGE_LENGTH... | class EventHubAsyncProducer implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final BatchOptions DEFAULT_BATCH_OPTIONS = new BatchOptions();
private final ClientLogger logger = new ClientLogger(EventH... | class EventHubAsyncProducer implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions();
private static final BatchOptions DEFAULT_BATCH_OPTIONS = new BatchOptions();
private final ClientLogger logger = new ClientLogger(EventH... |
Where is the the RuntimeException being thrown from? I'm surprised that the `withContext(…)` or underlying RestProxy isn't bubbling this to downstream. | public Mono<ConfigurationSetting> addSetting(ConfigurationSetting setting) {
try {
return withContext(context -> addSetting(setting, context))
.flatMap(response -> Mono.justOrEmpty(response.getValue()));
} catch (RuntimeException ex) {
return Mono.error(logger.logExceptionAsError(Exceptions.propagate(ex)));
}
} | try { | public Mono<ConfigurationSetting> addSetting(ConfigurationSetting setting) {
try {
return withContext(context -> addSetting(setting, context))
.flatMap(response -> Mono.justOrEmpty(response.getValue()));
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
} | class ConfigurationAsyncClient {
private final ClientLogger logger = new ClientLogger(ConfigurationAsyncClient.class);
private static final String ETAG_ANY = "*";
private static final String RANGE_QUERY = "items=%s";
private final String serviceEndpoint;
private final ConfigurationService service;
/**
* Creates a Confi... | class ConfigurationAsyncClient {
private final ClientLogger logger = new ClientLogger(ConfigurationAsyncClient.class);
private static final String ETAG_ANY = "*";
private static final String RANGE_QUERY = "items=%s";
private final String serviceEndpoint;
private final ConfigurationService service;
/**
* Creates a Confi... |
The exception is thrown in one of the methods in this class `validateSetting(setting)`. Besides, the purpose of this change is to catch all runtime exceptions before the user code - sdk api handshake and return them in the error channel. | public Mono<ConfigurationSetting> addSetting(ConfigurationSetting setting) {
try {
return withContext(context -> addSetting(setting, context))
.flatMap(response -> Mono.justOrEmpty(response.getValue()));
} catch (RuntimeException ex) {
return Mono.error(logger.logExceptionAsError(Exceptions.propagate(ex)));
}
} | try { | public Mono<ConfigurationSetting> addSetting(ConfigurationSetting setting) {
try {
return withContext(context -> addSetting(setting, context))
.flatMap(response -> Mono.justOrEmpty(response.getValue()));
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
} | class ConfigurationAsyncClient {
private final ClientLogger logger = new ClientLogger(ConfigurationAsyncClient.class);
private static final String ETAG_ANY = "*";
private static final String RANGE_QUERY = "items=%s";
private final String serviceEndpoint;
private final ConfigurationService service;
/**
* Creates a Confi... | class ConfigurationAsyncClient {
private final ClientLogger logger = new ClientLogger(ConfigurationAsyncClient.class);
private static final String ETAG_ANY = "*";
private static final String RANGE_QUERY = "items=%s";
private final String serviceEndpoint;
private final ConfigurationService service;
/**
* Creates a Confi... |
What about a `monoError` here too? | public PagedFlux<ConfigurationSetting> listSettings(SettingSelector selector) {
try {
return new PagedFlux<>(() -> withContext(context -> listFirstPageSettings(selector, context)),
continuationToken -> withContext(context -> listNextPageSettings(context, continuationToken)));
} catch (RuntimeException ex) {
return new ... | return new PagedFlux<>(() -> Mono.error(logger.logExceptionAsError(Exceptions.propagate(ex)))); | public PagedFlux<ConfigurationSetting> listSettings(SettingSelector selector) {
try {
return new PagedFlux<>(() -> withContext(context -> listFirstPageSettings(selector, context)),
continuationToken -> withContext(context -> listNextPageSettings(context, continuationToken)));
} catch (RuntimeException ex) {
return new ... | class ConfigurationAsyncClient {
private final ClientLogger logger = new ClientLogger(ConfigurationAsyncClient.class);
private static final String ETAG_ANY = "*";
private static final String RANGE_QUERY = "items=%s";
private final String serviceEndpoint;
private final ConfigurationService service;
/**
* Creates a Confi... | class ConfigurationAsyncClient {
private final ClientLogger logger = new ClientLogger(ConfigurationAsyncClient.class);
private static final String ETAG_ANY = "*";
private static final String RANGE_QUERY = "items=%s";
private final String serviceEndpoint;
private final ConfigurationService service;
/**
* Creates a Confi... |
Updated these to `monoError` as well. | public PagedFlux<ConfigurationSetting> listSettings(SettingSelector selector) {
try {
return new PagedFlux<>(() -> withContext(context -> listFirstPageSettings(selector, context)),
continuationToken -> withContext(context -> listNextPageSettings(context, continuationToken)));
} catch (RuntimeException ex) {
return new ... | return new PagedFlux<>(() -> Mono.error(logger.logExceptionAsError(Exceptions.propagate(ex)))); | public PagedFlux<ConfigurationSetting> listSettings(SettingSelector selector) {
try {
return new PagedFlux<>(() -> withContext(context -> listFirstPageSettings(selector, context)),
continuationToken -> withContext(context -> listNextPageSettings(context, continuationToken)));
} catch (RuntimeException ex) {
return new ... | class ConfigurationAsyncClient {
private final ClientLogger logger = new ClientLogger(ConfigurationAsyncClient.class);
private static final String ETAG_ANY = "*";
private static final String RANGE_QUERY = "items=%s";
private final String serviceEndpoint;
private final ConfigurationService service;
/**
* Creates a Confi... | class ConfigurationAsyncClient {
private final ClientLogger logger = new ClientLogger(ConfigurationAsyncClient.class);
private static final String ETAG_ANY = "*";
private static final String RANGE_QUERY = "items=%s";
private final String serviceEndpoint;
private final ConfigurationService service;
/**
* Creates a Confi... |
jfyi we could also do: ``` headerMapper = simpleMapper .copy() .configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true); ``` https://static.javadoc.io/com.fasterxml.jackson.core/jackson-databind/2.9.8/com/fasterxml/jackson/databind/ObjectMapper.html#copy-- | public JacksonAdapter() {
simpleMapper = initializeObjectMapper(new ObjectMapper());
xmlMapper = initializeObjectMapper(new XmlMapper());
xmlMapper.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);
xmlMapper.setDefaultUseWrapper(false);
ObjectMapper flatteningMapper = initializeObjectMapper(new ObjectMappe... | headerMapper = initializeHeaderMapper(new ObjectMapper()); | public JacksonAdapter() {
simpleMapper = initializeObjectMapper(new ObjectMapper());
xmlMapper = initializeObjectMapper(new XmlMapper());
xmlMapper.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);
xmlMapper.setDefaultUseWrapper(false);
ObjectMapper flatteningMapper = initializeObjectMapper(new ObjectMappe... | class JacksonAdapter implements SerializerAdapter {
private final ClientLogger logger = new ClientLogger(JacksonAdapter.class);
/**
* An instance of {@link ObjectMapper} to serialize/deserialize objects.
*/
private final ObjectMapper mapper;
/**
* An instance of {@link ObjectMapper} that does not do flattening.
*/
priv... | class JacksonAdapter implements SerializerAdapter {
private final ClientLogger logger = new ClientLogger(JacksonAdapter.class);
/**
* An instance of {@link ObjectMapper} to serialize/deserialize objects.
*/
private final ObjectMapper mapper;
/**
* An instance of {@link ObjectMapper} that does not do flattening.
*/
priv... |
Just to confirm all exceptions including null pointer will flow through Mono.error ? | public Mono<Response<Key>> getKeyWithResponse(KeyProperties keyProperties) {
try {
Objects.requireNonNull(keyProperties, "The Key Properties parameter cannot be null.");
return withContext(context -> getKeyWithResponse(keyProperties.getName(), keyProperties.getVersion() == null ? ""
: keyProperties.getVersion(), contex... | Objects.requireNonNull(keyProperties, "The Key Properties parameter cannot be null."); | return withContext(context -> getKeyWithResponse(keyProperties.getName(), keyProperties.getVersion() == null ? ""
: keyProperties.getVersion(), context));
} catch (RuntimeException ex) {
return monoError(logger, ex);
} | class KeyAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
static final String KEY_VAULT_SCOPE = "https:
private final String endpoint;
private final Ke... | class KeyAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
static final String KEY_VAULT_SCOPE = "https:
private final String endpoint;
private final Ke... |
Yes | public Mono<Response<Key>> getKeyWithResponse(KeyProperties keyProperties) {
try {
Objects.requireNonNull(keyProperties, "The Key Properties parameter cannot be null.");
return withContext(context -> getKeyWithResponse(keyProperties.getName(), keyProperties.getVersion() == null ? ""
: keyProperties.getVersion(), contex... | Objects.requireNonNull(keyProperties, "The Key Properties parameter cannot be null."); | return withContext(context -> getKeyWithResponse(keyProperties.getName(), keyProperties.getVersion() == null ? ""
: keyProperties.getVersion(), context));
} catch (RuntimeException ex) {
return monoError(logger, ex);
} | class KeyAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
static final String KEY_VAULT_SCOPE = "https:
private final String endpoint;
private final Ke... | class KeyAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
static final String KEY_VAULT_SCOPE = "https:
private final String endpoint;
private final Ke... |
nit; alternatively we can use `count()` operator https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html#count-- | public Mono<Integer> forceCloseAllHandles(boolean recursive) {
return fluxContext(context -> forceCloseAllHandlesWithTimeout(recursive, null, context))
.reduce(0, Integer::sum);
} | .reduce(0, Integer::sum); | public Mono<Integer> forceCloseAllHandles(boolean recursive) {
try {
return withContext(context -> forceCloseAllHandlesWithTimeout(recursive, null, context)
.reduce(0, Integer::sum));
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
} | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
private final String accountName;
/**
* Creates a D... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
private final String accountName;
/**
* Creates a D... |
Let's continue using reduce for now as we won't need to do another mapping to downcast. | public Mono<Integer> forceCloseAllHandles(boolean recursive) {
return fluxContext(context -> forceCloseAllHandlesWithTimeout(recursive, null, context))
.reduce(0, Integer::sum);
} | .reduce(0, Integer::sum); | public Mono<Integer> forceCloseAllHandles(boolean recursive) {
try {
return withContext(context -> forceCloseAllHandlesWithTimeout(recursive, null, context)
.reduce(0, Integer::sum));
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
} | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
private final String accountName;
/**
* Creates a D... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
private final String accountName;
/**
* Creates a D... |
Sounds good. | public Mono<Integer> forceCloseAllHandles(boolean recursive) {
return fluxContext(context -> forceCloseAllHandlesWithTimeout(recursive, null, context))
.reduce(0, Integer::sum);
} | .reduce(0, Integer::sum); | public Mono<Integer> forceCloseAllHandles(boolean recursive) {
try {
return withContext(context -> forceCloseAllHandlesWithTimeout(recursive, null, context)
.reduce(0, Integer::sum));
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
} | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
private final String accountName;
/**
* Creates a D... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
private final String accountName;
/**
* Creates a D... |
nit: `urlPath += "?" + urlQuery;` ? | private Mono<HttpResponse> setupBatchOperation(HttpRequest request) {
return Mono.fromRunnable(() -> {
int contentId = Integer.parseInt(request.getHeaders().remove(CONTENT_ID).getValue());
StringBuilder batchRequestBuilder = new StringBuilder();
appendWithNewline(batchRequestBuilder, "--" + batchBoundary);
appendWithNe... | urlPath = urlPath + "?" + urlQuery; | private Mono<HttpResponse> setupBatchOperation(HttpRequest request) {
return Mono.fromRunnable(() -> {
int contentId = Integer.parseInt(request.getHeaders().remove(CONTENT_ID).getValue());
StringBuilder batchRequestBuilder = new StringBuilder();
appendWithNewline(batchRequestBuilder, "--" + batchBoundary);
appendWithNe... | class BlobBatch {
private static final String X_MS_VERSION = "x-ms-version";
private static final String BATCH_REQUEST_CONTENT_ID = "Batch-Request-Content-Id";
private static final String BATCH_REQUEST_URL_PATH = "Batch-Request-Url-Path";
private static final String CONTENT_ID = "Content-Id";
private static final Strin... | class BlobBatch {
private static final String X_MS_VERSION = "x-ms-version";
private static final String BATCH_REQUEST_CONTENT_ID = "Batch-Request-Content-Id";
private static final String BATCH_REQUEST_URL_PATH = "Batch-Request-Url-Path";
private static final String CONTENT_ID = "Content-Id";
private static final Strin... |
I will add an issue to change this next week as it won't touch API | private Mono<HttpResponse> setupBatchOperation(HttpRequest request) {
return Mono.fromRunnable(() -> {
int contentId = Integer.parseInt(request.getHeaders().remove(CONTENT_ID).getValue());
StringBuilder batchRequestBuilder = new StringBuilder();
appendWithNewline(batchRequestBuilder, "--" + batchBoundary);
appendWithNe... | urlPath = urlPath + "?" + urlQuery; | private Mono<HttpResponse> setupBatchOperation(HttpRequest request) {
return Mono.fromRunnable(() -> {
int contentId = Integer.parseInt(request.getHeaders().remove(CONTENT_ID).getValue());
StringBuilder batchRequestBuilder = new StringBuilder();
appendWithNewline(batchRequestBuilder, "--" + batchBoundary);
appendWithNe... | class BlobBatch {
private static final String X_MS_VERSION = "x-ms-version";
private static final String BATCH_REQUEST_CONTENT_ID = "Batch-Request-Content-Id";
private static final String BATCH_REQUEST_URL_PATH = "Batch-Request-Url-Path";
private static final String CONTENT_ID = "Content-Id";
private static final Strin... | class BlobBatch {
private static final String X_MS_VERSION = "x-ms-version";
private static final String BATCH_REQUEST_CONTENT_ID = "Batch-Request-Content-Id";
private static final String BATCH_REQUEST_URL_PATH = "Batch-Request-Url-Path";
private static final String CONTENT_ID = "Content-Id";
private static final Strin... |
https://github.com/Azure/azure-sdk-for-java/issues/5942 | private Mono<HttpResponse> setupBatchOperation(HttpRequest request) {
return Mono.fromRunnable(() -> {
int contentId = Integer.parseInt(request.getHeaders().remove(CONTENT_ID).getValue());
StringBuilder batchRequestBuilder = new StringBuilder();
appendWithNewline(batchRequestBuilder, "--" + batchBoundary);
appendWithNe... | urlPath = urlPath + "?" + urlQuery; | private Mono<HttpResponse> setupBatchOperation(HttpRequest request) {
return Mono.fromRunnable(() -> {
int contentId = Integer.parseInt(request.getHeaders().remove(CONTENT_ID).getValue());
StringBuilder batchRequestBuilder = new StringBuilder();
appendWithNewline(batchRequestBuilder, "--" + batchBoundary);
appendWithNe... | class BlobBatch {
private static final String X_MS_VERSION = "x-ms-version";
private static final String BATCH_REQUEST_CONTENT_ID = "Batch-Request-Content-Id";
private static final String BATCH_REQUEST_URL_PATH = "Batch-Request-Url-Path";
private static final String CONTENT_ID = "Content-Id";
private static final Strin... | class BlobBatch {
private static final String X_MS_VERSION = "x-ms-version";
private static final String BATCH_REQUEST_CONTENT_ID = "Batch-Request-Content-Id";
private static final String BATCH_REQUEST_URL_PATH = "Batch-Request-Url-Path";
private static final String CONTENT_ID = "Content-Id";
private static final Strin... |
If they pass in null, just have that clear out the whitelist. | public HttpLogOptions setAllowedHeaderNames(final Set<String> allowedHeaderNames) {
this.allowedHeaderNames = allowedHeaderNames == null ? this.allowedHeaderNames : allowedHeaderNames;
return this;
} | this.allowedHeaderNames = allowedHeaderNames == null ? this.allowedHeaderNames : allowedHeaderNames; | public HttpLogOptions setAllowedHeaderNames(final Set<String> allowedHeaderNames) {
this.allowedHeaderNames = allowedHeaderNames == null ? new HashSet<>() : allowedHeaderNames;
return this;
} | class HttpLogOptions {
private HttpLogDetailLevel logLevel;
private Set<String> allowedHeaderNames;
private Set<String> allowedQueryParamNames;
public HttpLogOptions() {
logLevel = HttpLogDetailLevel.NONE;
allowedHeaderNames = new HashSet<>(Arrays.asList(
"x-ms-client-request-id",
"x-ms-return-client-request-id",
"trac... | class HttpLogOptions {
private HttpLogDetailLevel logLevel;
private Set<String> allowedHeaderNames;
private Set<String> allowedQueryParamNames;
private static final List<String> DEFAULT_HEADERS_WHITELIST = Arrays.asList(
"x-ms-client-request-id",
"x-ms-return-client-request-id",
"traceparent",
"Accept",
"Cache-Control"... |
Should there be a convenience API to remove headers too? Because in most cases, users just want to redact one or two headers from the default set that may contain sensitive info. | public HttpLogOptions setAllowedHeaderNames(final Set<String> allowedHeaderNames) {
this.allowedHeaderNames = allowedHeaderNames == null ? this.allowedHeaderNames : allowedHeaderNames;
return this;
} | this.allowedHeaderNames = allowedHeaderNames == null ? this.allowedHeaderNames : allowedHeaderNames; | public HttpLogOptions setAllowedHeaderNames(final Set<String> allowedHeaderNames) {
this.allowedHeaderNames = allowedHeaderNames == null ? new HashSet<>() : allowedHeaderNames;
return this;
} | class HttpLogOptions {
private HttpLogDetailLevel logLevel;
private Set<String> allowedHeaderNames;
private Set<String> allowedQueryParamNames;
public HttpLogOptions() {
logLevel = HttpLogDetailLevel.NONE;
allowedHeaderNames = new HashSet<>(Arrays.asList(
"x-ms-client-request-id",
"x-ms-return-client-request-id",
"trac... | class HttpLogOptions {
private HttpLogDetailLevel logLevel;
private Set<String> allowedHeaderNames;
private Set<String> allowedQueryParamNames;
private static final List<String> DEFAULT_HEADERS_WHITELIST = Arrays.asList(
"x-ms-client-request-id",
"x-ms-return-client-request-id",
"traceparent",
"Accept",
"Cache-Control"... |
On line 75 and 114: Should we return an immutable copy of the HashSet instead of returning the reference to the HashSet this class uses? If we return the reference, then user can add/delete to the original set outside of this class. | public HttpLogOptions setAllowedHeaderNames(final Set<String> allowedHeaderNames) {
this.allowedHeaderNames = allowedHeaderNames == null ? this.allowedHeaderNames : allowedHeaderNames;
return this;
} | this.allowedHeaderNames = allowedHeaderNames == null ? this.allowedHeaderNames : allowedHeaderNames; | public HttpLogOptions setAllowedHeaderNames(final Set<String> allowedHeaderNames) {
this.allowedHeaderNames = allowedHeaderNames == null ? new HashSet<>() : allowedHeaderNames;
return this;
} | class HttpLogOptions {
private HttpLogDetailLevel logLevel;
private Set<String> allowedHeaderNames;
private Set<String> allowedQueryParamNames;
public HttpLogOptions() {
logLevel = HttpLogDetailLevel.NONE;
allowedHeaderNames = new HashSet<>(Arrays.asList(
"x-ms-client-request-id",
"x-ms-return-client-request-id",
"trac... | class HttpLogOptions {
private HttpLogDetailLevel logLevel;
private Set<String> allowedHeaderNames;
private Set<String> allowedQueryParamNames;
private static final List<String> DEFAULT_HEADERS_WHITELIST = Arrays.asList(
"x-ms-client-request-id",
"x-ms-return-client-request-id",
"traceparent",
"Accept",
"Cache-Control"... |
Extract the `Arrays.asList()` into a static field and reuse. Don't have to create a list and a hashset each time an instance of HttpLogOptions is created. | public HttpLogOptions() {
logLevel = HttpLogDetailLevel.NONE;
allowedHeaderNames = new HashSet<>(Arrays.asList(
"x-ms-client-request-id",
"x-ms-return-client-request-id",
"traceparent",
"Accept",
"Cache-Control",
"Connection",
"Content-Length",
"Content-Type",
"Date",
"ETag",
"Expires",
"If-Match",
"If-Modified-Since",... | allowedHeaderNames = new HashSet<>(Arrays.asList( | public HttpLogOptions() {
logLevel = HttpLogDetailLevel.NONE;
allowedHeaderNames = new HashSet<>();
allowedQueryParamNames = new HashSet<>(DEFAULT_HEADERS_WHITELIST);
} | class HttpLogOptions {
private HttpLogDetailLevel logLevel;
private Set<String> allowedHeaderNames;
private Set<String> allowedQueryParamNames;
/**
* Gets the level of detail to log on HTTP messages.
*
* @return The {@link HttpLogDetailLevel}.
*/
public HttpLogDetailLevel getLogLevel() {
return logLevel;
}
/**
* Sets t... | class HttpLogOptions {
private HttpLogDetailLevel logLevel;
private Set<String> allowedHeaderNames;
private Set<String> allowedQueryParamNames;
private static final List<String> DEFAULT_HEADERS_WHITELIST = Arrays.asList(
"x-ms-client-request-id",
"x-ms-return-client-request-id",
"traceparent",
"Accept",
"Cache-Control"... |
This can be done via `getAllowedHeaderNames().remove(..)`, so we don't need a convenience API. | public HttpLogOptions setAllowedHeaderNames(final Set<String> allowedHeaderNames) {
this.allowedHeaderNames = allowedHeaderNames == null ? this.allowedHeaderNames : allowedHeaderNames;
return this;
} | this.allowedHeaderNames = allowedHeaderNames == null ? this.allowedHeaderNames : allowedHeaderNames; | public HttpLogOptions setAllowedHeaderNames(final Set<String> allowedHeaderNames) {
this.allowedHeaderNames = allowedHeaderNames == null ? new HashSet<>() : allowedHeaderNames;
return this;
} | class HttpLogOptions {
private HttpLogDetailLevel logLevel;
private Set<String> allowedHeaderNames;
private Set<String> allowedQueryParamNames;
public HttpLogOptions() {
logLevel = HttpLogDetailLevel.NONE;
allowedHeaderNames = new HashSet<>(Arrays.asList(
"x-ms-client-request-id",
"x-ms-return-client-request-id",
"trac... | class HttpLogOptions {
private HttpLogDetailLevel logLevel;
private Set<String> allowedHeaderNames;
private Set<String> allowedQueryParamNames;
private static final List<String> DEFAULT_HEADERS_WHITELIST = Arrays.asList(
"x-ms-client-request-id",
"x-ms-return-client-request-id",
"traceparent",
"Accept",
"Cache-Control"... |
I partially agree. The Arrays.asList(...) call can be a private static final field, but there should be a new set per instance, so that it can be modified via the API. | public HttpLogOptions() {
logLevel = HttpLogDetailLevel.NONE;
allowedHeaderNames = new HashSet<>(Arrays.asList(
"x-ms-client-request-id",
"x-ms-return-client-request-id",
"traceparent",
"Accept",
"Cache-Control",
"Connection",
"Content-Length",
"Content-Type",
"Date",
"ETag",
"Expires",
"If-Match",
"If-Modified-Since",... | allowedHeaderNames = new HashSet<>(Arrays.asList( | public HttpLogOptions() {
logLevel = HttpLogDetailLevel.NONE;
allowedHeaderNames = new HashSet<>();
allowedQueryParamNames = new HashSet<>(DEFAULT_HEADERS_WHITELIST);
} | class HttpLogOptions {
private HttpLogDetailLevel logLevel;
private Set<String> allowedHeaderNames;
private Set<String> allowedQueryParamNames;
/**
* Gets the level of detail to log on HTTP messages.
*
* @return The {@link HttpLogDetailLevel}.
*/
public HttpLogDetailLevel getLogLevel() {
return logLevel;
}
/**
* Sets t... | class HttpLogOptions {
private HttpLogDetailLevel logLevel;
private Set<String> allowedHeaderNames;
private Set<String> allowedQueryParamNames;
private static final List<String> DEFAULT_HEADERS_WHITELIST = Arrays.asList(
"x-ms-client-request-id",
"x-ms-return-client-request-id",
"traceparent",
"Accept",
"Cache-Control"... |
updated | public HttpLogOptions() {
logLevel = HttpLogDetailLevel.NONE;
allowedHeaderNames = new HashSet<>(Arrays.asList(
"x-ms-client-request-id",
"x-ms-return-client-request-id",
"traceparent",
"Accept",
"Cache-Control",
"Connection",
"Content-Length",
"Content-Type",
"Date",
"ETag",
"Expires",
"If-Match",
"If-Modified-Since",... | allowedHeaderNames = new HashSet<>(Arrays.asList( | public HttpLogOptions() {
logLevel = HttpLogDetailLevel.NONE;
allowedHeaderNames = new HashSet<>();
allowedQueryParamNames = new HashSet<>(DEFAULT_HEADERS_WHITELIST);
} | class HttpLogOptions {
private HttpLogDetailLevel logLevel;
private Set<String> allowedHeaderNames;
private Set<String> allowedQueryParamNames;
/**
* Gets the level of detail to log on HTTP messages.
*
* @return The {@link HttpLogDetailLevel}.
*/
public HttpLogDetailLevel getLogLevel() {
return logLevel;
}
/**
* Sets t... | class HttpLogOptions {
private HttpLogDetailLevel logLevel;
private Set<String> allowedHeaderNames;
private Set<String> allowedQueryParamNames;
private static final List<String> DEFAULT_HEADERS_WHITELIST = Arrays.asList(
"x-ms-client-request-id",
"x-ms-return-client-request-id",
"traceparent",
"Accept",
"Cache-Control"... |
Should this be changed based on the service version work that @samvaity has been doing (which is now in the repo)? | private void ensureState() {
if (version == null) {
version = Constants.HeaderConstants.TARGET_STORAGE_VERSION;
}
if (ImplUtils.isNullOrEmpty(blobName)) {
resource = SAS_CONTAINER_CONSTANT;
} else if (snapshotId != null) {
resource = SAS_BLOB_SNAPSHOT_CONSTANT;
} else {
resource = SAS_BLOB_CONSTANT;
}
if (permissions !... | version = Constants.HeaderConstants.TARGET_STORAGE_VERSION; | private void ensureState() {
if (version == null) {
version = BlobServiceVersion.getLatest().getVersion();
}
if (ImplUtils.isNullOrEmpty(blobName)) {
resource = SAS_CONTAINER_CONSTANT;
} else if (snapshotId != null) {
resource = SAS_BLOB_SNAPSHOT_CONSTANT;
} else {
resource = SAS_BLOB_CONSTANT;
}
if (permissions != nul... | class level JavaDocs for code snippets.
*
* @param delegationKey A {@link UserDelegationKey} | class level JavaDocs for code snippets.
*
* @param delegationKey A {@link UserDelegationKey} |
getKey().block().getKey() ? | private boolean ensureValidKeyAvailable() {
boolean keyAvailableLocally = true;
if (this.key == null) {
try {
this.key = getKey().block().getKey();
keyAvailableLocally = this.key.isValid();
initializeCryptoClients();
} catch (HttpResponseException | NullPointerException e) {
logger.info("Failed to retrieve key from key... | this.key = getKey().block().getKey(); | private boolean ensureValidKeyAvailable() {
boolean keyAvailableLocally = true;
if (this.key == null) {
try {
KeyVaultKey keyVaultKey = getKey().block();
this.key = keyVaultKey.getKey();
keyAvailableLocally = this.key.isValid();
initializeCryptoClients();
} catch (HttpResponseException | NullPointerException e) {
logge... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... |
Should we log the exception here as well, since it can be either and it might help the user to actually know what happened. | private boolean ensureValidKeyAvailable() {
boolean keyAvailableLocally = true;
if (this.key == null) {
try {
this.key = getKey().block().getKey();
keyAvailableLocally = this.key.isValid();
initializeCryptoClients();
} catch (HttpResponseException | NullPointerException e) {
logger.info("Failed to retrieve key from key... | } catch (HttpResponseException | NullPointerException e) { | private boolean ensureValidKeyAvailable() {
boolean keyAvailableLocally = true;
if (this.key == null) {
try {
KeyVaultKey keyVaultKey = getKey().block();
this.key = keyVaultKey.getKey();
keyAvailableLocally = this.key.isValid();
initializeCryptoClients();
} catch (HttpResponseException | NullPointerException e) {
logge... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... |
``` .setKeyType(createKeyOptions.getKeyType()) ``` | Mono<Response<KeyVaultKey>> createKeyWithResponse(CreateKeyOptions createKeyOptions, Context context) {
Objects.requireNonNull(createKeyOptions, "The key create options parameter cannot be null.");
KeyRequestParameters parameters = new KeyRequestParameters()
.setKty(createKeyOptions.getKeyType())
.setKeyOps(createKeyOp... | .setKty(createKeyOptions.getKeyType()) | new KeyRequestParameters().setKty(keyType);
return service.createKey(vaultUrl, name, API_VERSION, ACCEPT_LANGUAGE, parameters, CONTENT_TYPE_HEADER_VALUE,
context)
.doOnRequest(ignored -> logger.info("Creating key - {} | class KeyAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
static final String KEY_VAULT_SCOPE = "https:
private final String endpoint;
private final Ke... | class KeyAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
static final String KEY_VAULT_SCOPE = "https:
private final String vaultUrl;
private final Ke... |
``` .setKeyOperations(createKeyOptions.keyOperations()) ``` | Mono<Response<KeyVaultKey>> createKeyWithResponse(CreateKeyOptions createKeyOptions, Context context) {
Objects.requireNonNull(createKeyOptions, "The key create options parameter cannot be null.");
KeyRequestParameters parameters = new KeyRequestParameters()
.setKty(createKeyOptions.getKeyType())
.setKeyOps(createKeyOp... | .setKeyOps(createKeyOptions.keyOperations()) | new KeyRequestParameters().setKty(keyType);
return service.createKey(vaultUrl, name, API_VERSION, ACCEPT_LANGUAGE, parameters, CONTENT_TYPE_HEADER_VALUE,
context)
.doOnRequest(ignored -> logger.info("Creating key - {} | class KeyAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
static final String KEY_VAULT_SCOPE = "https:
private final String endpoint;
private final Ke... | class KeyAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
static final String KEY_VAULT_SCOPE = "https:
private final String vaultUrl;
private final Ke... |
internal class, mapping to swagger/REST API Best to keep it same as swagger/REST API | Mono<Response<KeyVaultKey>> createKeyWithResponse(CreateKeyOptions createKeyOptions, Context context) {
Objects.requireNonNull(createKeyOptions, "The key create options parameter cannot be null.");
KeyRequestParameters parameters = new KeyRequestParameters()
.setKty(createKeyOptions.getKeyType())
.setKeyOps(createKeyOp... | .setKty(createKeyOptions.getKeyType()) | new KeyRequestParameters().setKty(keyType);
return service.createKey(vaultUrl, name, API_VERSION, ACCEPT_LANGUAGE, parameters, CONTENT_TYPE_HEADER_VALUE,
context)
.doOnRequest(ignored -> logger.info("Creating key - {} | class KeyAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
static final String KEY_VAULT_SCOPE = "https:
private final String endpoint;
private final Ke... | class KeyAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
static final String KEY_VAULT_SCOPE = "https:
private final String vaultUrl;
private final Ke... |
`UnsupportedOperationException` should be wrapped with `logger.logAsError()` | Mono<DecryptResult> decrypt(EncryptionAlgorithm algorithm, byte[] cipherText, Context context) {
Objects.requireNonNull(algorithm, "Encryption algorithm cannot be null.");
Objects.requireNonNull(cipherText, "Cipher text content to be decrypted cannot be null.");
boolean keyAvailableLocally = ensureValidKeyAvailable();
... | + "key with id %s", key.getKeyId()))); | Mono<DecryptResult> decrypt(EncryptionAlgorithm algorithm, byte[] cipherText, Context context) {
Objects.requireNonNull(algorithm, "Encryption algorithm cannot be null.");
Objects.requireNonNull(cipherText, "Cipher text content to be decrypted cannot be null.");
boolean keyAvailableLocally = ensureValidKeyAvailable();
... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... |
done | Mono<DecryptResult> decrypt(EncryptionAlgorithm algorithm, byte[] cipherText, Context context) {
Objects.requireNonNull(algorithm, "Encryption algorithm cannot be null.");
Objects.requireNonNull(cipherText, "Cipher text content to be decrypted cannot be null.");
boolean keyAvailableLocally = ensureValidKeyAvailable();
... | + "key with id %s", key.getKeyId()))); | Mono<DecryptResult> decrypt(EncryptionAlgorithm algorithm, byte[] cipherText, Context context) {
Objects.requireNonNull(algorithm, "Encryption algorithm cannot be null.");
Objects.requireNonNull(cipherText, "Cipher text content to be decrypted cannot be null.");
boolean keyAvailableLocally = ensureValidKeyAvailable();
... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... |
internal class, mapping to swagger/REST API Best to keep it same as swagger/REST API | Mono<Response<KeyVaultKey>> createKeyWithResponse(CreateKeyOptions createKeyOptions, Context context) {
Objects.requireNonNull(createKeyOptions, "The key create options parameter cannot be null.");
KeyRequestParameters parameters = new KeyRequestParameters()
.setKty(createKeyOptions.getKeyType())
.setKeyOps(createKeyOp... | .setKeyOps(createKeyOptions.keyOperations()) | new KeyRequestParameters().setKty(keyType);
return service.createKey(vaultUrl, name, API_VERSION, ACCEPT_LANGUAGE, parameters, CONTENT_TYPE_HEADER_VALUE,
context)
.doOnRequest(ignored -> logger.info("Creating key - {} | class KeyAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
static final String KEY_VAULT_SCOPE = "https:
private final String endpoint;
private final Ke... | class KeyAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
static final String KEY_VAULT_SCOPE = "https:
private final String vaultUrl;
private final Ke... |
added the log for exception. | private boolean ensureValidKeyAvailable() {
boolean keyAvailableLocally = true;
if (this.key == null) {
try {
this.key = getKey().block().getKey();
keyAvailableLocally = this.key.isValid();
initializeCryptoClients();
} catch (HttpResponseException | NullPointerException e) {
logger.info("Failed to retrieve key from key... | } catch (HttpResponseException | NullPointerException e) { | private boolean ensureValidKeyAvailable() {
boolean keyAvailableLocally = true;
if (this.key == null) {
try {
KeyVaultKey keyVaultKey = getKey().block();
this.key = keyVaultKey.getKey();
keyAvailableLocally = this.key.isValid();
initializeCryptoClients();
} catch (HttpResponseException | NullPointerException e) {
logge... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... |
this is internal. first getKey is the KeyVaultKey, refactored the code to make it look readable. | private boolean ensureValidKeyAvailable() {
boolean keyAvailableLocally = true;
if (this.key == null) {
try {
this.key = getKey().block().getKey();
keyAvailableLocally = this.key.isValid();
initializeCryptoClients();
} catch (HttpResponseException | NullPointerException e) {
logger.info("Failed to retrieve key from key... | this.key = getKey().block().getKey(); | private boolean ensureValidKeyAvailable() {
boolean keyAvailableLocally = true;
if (this.key == null) {
try {
KeyVaultKey keyVaultKey = getKey().block();
this.key = keyVaultKey.getKey();
keyAvailableLocally = this.key.isValid();
initializeCryptoClients();
} catch (HttpResponseException | NullPointerException e) {
logge... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... |
General feedback (don't worry about doing it): This code block would look nicer as a switch statement | private void initializeCryptoClients() {
if (localKeyCryptographyClient != null) {
return;
}
if (key.getKeyType().equals(RSA) || key.getKeyType().equals(RSA_HSM)) {
localKeyCryptographyClient = new RsaKeyCryptographyClient(key, cryptographyServiceClient);
} else if (key.getKeyType().equals(EC) || key.getKeyType().equal... | "The Json Web Key Type: %s is not supported.", key.getKeyType().toString()))); | private void initializeCryptoClients() {
if (localKeyCryptographyClient != null) {
return;
}
if (key.getKeyType().equals(RSA) || key.getKeyType().equals(RSA_HSM)) {
localKeyCryptographyClient = new RsaKeyCryptographyClient(key, cryptographyServiceClient);
} else if (key.getKeyType().equals(EC) || key.getKeyType().equal... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... |
Why only commented out instead of just removed? | public void deleteKey() {
} | public void deleteKey() {
deleteKeyRunner((keyToDelete) -> {
StepVerifier.create(client.createKey(keyToDelete))
.assertNext(keyResponse -> assertKeyEquals(keyToDelete, keyResponse)).verifyComplete();
Poller<DeletedKey, Void> poller = client.beginDeleteKey(keyToDelete.getName());
poller.blockUntil(PollResponse.Operation... | class KeyAsyncClientTest extends KeyClientTestBase {
private KeyAsyncClient client;
@Override
protected void beforeTest() {
beforeTestSetup();
if (interceptorManager.isPlaybackMode()) {
client = clientSetup(pipeline -> new KeyClientBuilder()
.vaultEndpoint(getEndpoint())
.pipeline(pipeline)
.buildAsyncClient());
} else... | class KeyAsyncClientTest extends KeyClientTestBase {
private KeyAsyncClient client;
@Override
protected void beforeTest() {
beforeTestSetup();
if (interceptorManager.isPlaybackMode()) {
client = clientSetup(pipeline -> new KeyClientBuilder()
.vaultUrl(getEndpoint())
.pipeline(pipeline)
.buildAsyncClient());
} else {
cl... | |
Taken as future improvement. | private void initializeCryptoClients() {
if (localKeyCryptographyClient != null) {
return;
}
if (key.getKeyType().equals(RSA) || key.getKeyType().equals(RSA_HSM)) {
localKeyCryptographyClient = new RsaKeyCryptographyClient(key, cryptographyServiceClient);
} else if (key.getKeyType().equals(EC) || key.getKeyType().equal... | "The Json Web Key Type: %s is not supported.", key.getKeyType().toString()))); | private void initializeCryptoClients() {
if (localKeyCryptographyClient != null) {
return;
}
if (key.getKeyType().equals(RSA) || key.getKeyType().equals(RSA_HSM)) {
localKeyCryptographyClient = new RsaKeyCryptographyClient(key, cryptographyServiceClient);
} else if (key.getKeyType().equals(EC) || key.getKeyType().equal... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... | class CryptographyAsyncClient {
static final String KEY_VAULT_SCOPE = "https:
JsonWebKey key;
private final CryptographyService service;
private final CryptographyServiceClient cryptographyServiceClient;
private LocalKeyCryptographyClient localKeyCryptographyClient;
private final ClientLogger logger = new ClientLogger(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.