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
It would be nice to standardise between 'namespace' and 'namespaceName', which is used interchangeably in a few files I've reviewed so far. I suspect everything should be referred to as 'namespace'.
public String getNamespace() { return namespaceName; }
}
public String getNamespace() { return namespace; }
class ErrorContext implements Serializable { static final String MESSAGE_PARAMETER_DELIMITER = ", "; private static final long serialVersionUID = -2819764407122954922L; private final String namespaceName; /** * Creates a new instance with the provided {@code namespaceName}. * * @param namespaceName The service namespac...
class ErrorContext implements Serializable { static final String MESSAGE_PARAMETER_DELIMITER = ", "; private static final long serialVersionUID = -2819764407122954922L; private final String namespace; /** * Creates a new instance with the provided {@code namespace}. * * @param namespace The service namespace of the err...
I removed this line because after adding the default case, this line can never be reached. Let me know if there is concern here.
public Single<HttpResponse> sendAsync(HttpRequest request) { this.factory.tryNumber++; if (this.factory.tryNumber > this.factory.options.maxTries()) { throw new IllegalArgumentException("Try number has exceeded max tries"); } String expectedHost = RETRY_TEST_PRIMARY_HOST; if (this.factory.tryNumber % 2 == 0) { /* Speci...
throw new IllegalArgumentException("Invalid retry test scenario.");
public Single<HttpResponse> sendAsync(HttpRequest request) { this.factory.tryNumber++; if (this.factory.tryNumber > this.factory.options.maxTries()) { throw new IllegalArgumentException("Try number has exceeded max tries"); } String expectedHost = RETRY_TEST_PRIMARY_HOST; if (this.factory.tryNumber % 2 == 0) { /* Speci...
class RetryTestPolicy implements RequestPolicy { private RequestRetryTestFactory factory; RetryTestPolicy(RequestRetryTestFactory parent) { this.factory = parent; } @Override /* Calculate the delay in seconds. Round up to ensure we include the maximum value and some offset for the code executing between the original ca...
class RetryTestPolicy implements RequestPolicy { private RequestRetryTestFactory factory; RetryTestPolicy(RequestRetryTestFactory parent) { this.factory = parent; } @Override /* Calculate the delay in seconds. Round up to ensure we include the maximum value and some offset for the code executing between the original ca...
both tests are tested in test cases: (1) isRetriable: https://github.com/Azure/azure-sdk-for-java/pull/3818/files#diff-88f19a64404192ec0b032ec6f648b628R57 (2) Excess max retry: https://github.com/Azure/azure-sdk-for-java/pull/3818/files#diff-88f19a64404192ec0b032ec6f648b628R72
public Duration getNextRetryInterval(Exception lastException, Duration remainingTime) { int baseWaitTime = 0; if (lastException == null || !(lastException instanceof AmqpException)) { return this.onGetNextRetryInterval(lastException, remainingTime, baseWaitTime, this.getRetryCount()); } if (((AmqpException) lastExcepti...
if (lastException == null || !(lastException instanceof AmqpException)) {
public Duration getNextRetryInterval(Exception lastException, Duration remainingTime) { int baseWaitTime = 0; if (!isRetriableException(lastException)) { return null; } if (retryCount.get() >= maxRetryCount) { return null; } if (((AmqpException) lastException).getErrorCondition() == ErrorCondition.SERVER_BUSY_ERROR) { ...
class Retry { public static final Retry NO_RETRY = new RetryExponential(Duration.ofSeconds(0), Duration.ofSeconds(0), 0); private AtomicInteger retryCount = new AtomicInteger(0); /** * Check if the existing exception is a retryable exception. * * @param exception A exception that was observed for the operation to be re...
class Retry { public static final Duration DEFAULT_RETRY_MIN_BACKOFF = Duration.ofSeconds(0); public static final Duration DEFAULT_RETRY_MAX_BACKOFF = Duration.ofSeconds(30); public static final int DEFAULT_MAX_RETRY_COUNT = 10; private final AtomicInteger retryCount = new AtomicInteger(); private final int maxRetryCou...
Is it possible that the environment variable is not set? ``` if (ImplUtils.IsNullOrEmpty(connStr)) { // throw here. } ```
public EventHubClient build() { this.configuration = this.configuration == null ? ConfigurationManager.getConfiguration().clone() : this.configuration; this.proxyConfiguration = constructDefaultProxyConfiguration(this.configuration); if (this.credentials == null) { String connStr = this.configuration.get(AZURE_EVENT_HU...
String connStr = this.configuration.get(AZURE_EVENT_HUB_CONNECTION_STRING);
public EventHubClient build() { configuration = configuration == null ? ConfigurationManager.getConfiguration().clone() : configuration; if (credentials == null) { String connectionString = configuration.get(AZURE_EVENT_HUBS_CONNECTION_STRING); if (ImplUtils.isNullOrEmpty(connectionString)) { throw new IllegalArgumentE...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUB_CONNECTION_STRING = "AZURE_EVENT_HUB_CONNECTION_STRING"; private CredentialInfo credentials; private TransportType transport; private Duration duration; private Scheduler scheduler; private ProxyConfiguration proxyConfiguration; private RetryPoli...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private CredentialInfo credentials; private Configuration configuration; private Duration timeout; private ProxyConfiguration proxyConfiguration; private Retry retry; private Scheduler sc...
There is a default in ClientConstants. OperationTimeout. I believe it's 1 minute.
public EventHubClient build() { this.configuration = this.configuration == null ? ConfigurationManager.getConfiguration().clone() : this.configuration; this.proxyConfiguration = constructDefaultProxyConfiguration(this.configuration); if (this.credentials == null) { String connStr = this.configuration.get(AZURE_EVENT_HU...
this.duration = Duration.ofSeconds(5);
public EventHubClient build() { configuration = configuration == null ? ConfigurationManager.getConfiguration().clone() : configuration; if (credentials == null) { String connectionString = configuration.get(AZURE_EVENT_HUBS_CONNECTION_STRING); if (ImplUtils.isNullOrEmpty(connectionString)) { throw new IllegalArgumentE...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUB_CONNECTION_STRING = "AZURE_EVENT_HUB_CONNECTION_STRING"; private CredentialInfo credentials; private TransportType transport; private Duration duration; private Scheduler scheduler; private ProxyConfiguration proxyConfiguration; private RetryPoli...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private CredentialInfo credentials; private Configuration configuration; private Duration timeout; private ProxyConfiguration proxyConfiguration; private Retry retry; private Scheduler sc...
```java ProxyAuthenticationType authentication = ProxyAuthenticationType.NONE; if (this.proxyConfiguration != null) { authentication = this.proxyConfiguration.authentication(); } ```
private ProxyConfiguration constructDefaultProxyConfiguration(Configuration configuration) { ProxyAuthenticationType authentication = null; if (this.proxyConfiguration != null) { authentication = this.proxyConfiguration.authentication(); } authentication = authentication == null ? ProxyAuthenticationType.NONE : authent...
ProxyAuthenticationType authentication = null;
private ProxyConfiguration constructDefaultProxyConfiguration(Configuration configuration) { ProxyAuthenticationType authentication = ProxyAuthenticationType.NONE; if (proxyConfiguration != null) { authentication = proxyConfiguration.authentication(); } String proxyAddress = configuration.get(BaseConfigurations.HTTP_PR...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUB_CONNECTION_STRING = "AZURE_EVENT_HUB_CONNECTION_STRING"; private CredentialInfo credentials; private TransportType transport; private Duration duration; private Scheduler scheduler; private ProxyConfiguration proxyConfiguration; private RetryPoli...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private CredentialInfo credentials; private Configuration configuration; private Duration timeout; private ProxyConfiguration proxyConfiguration; private Retry retry; private Scheduler sc...
In general, move your public methods to the top. Then private methods to the bottom. Users will interact with public methods first before looking at these private helper methods.
private static URI getURI(String endpointFormat, String namespaceName, String domainName) { try { return new URI(String.format(Locale.US, endpointFormat, namespaceName, domainName)); } catch (URISyntaxException exception) { throw new IllegalArgumentException(String.format(Locale.US, "Invalid namespace name: %s", namesp...
return new URI(String.format(Locale.US, endpointFormat, namespaceName, domainName));
private static URI getURI(String endpointFormat, String namespaceName, String domainName) { try { return new URI(String.format(Locale.US, endpointFormat, namespaceName, domainName)); } catch (URISyntaxException exception) { throw new IllegalArgumentException(String.format(Locale.US, "Invalid namespace name: %s", namesp...
class EventHubClientBuilderTest { private static final String END_POINT_FORMAT = "sb: private static final String NAMESPACE_NAME = "dummyNamespaceName"; private static final String DEFAULT_DOMAIN_NAME = "servicebus.windows.net/"; private static final String SHARED_ACCESS_KEY_NAME = "dummySasKeyName"; private static fin...
class EventHubClientBuilderTest { private static final String NAMESPACE_NAME = "dummyNamespaceName"; private static final String DEFAULT_DOMAIN_NAME = "servicebus.windows.net/"; private static final String ENTITY_PATH = "dummyEntityPath"; private static final String SHARED_ACCESS_KEY_NAME = "dummySasKeyName"; private s...
What are we expecting? Should be outlined in the method docs what components there are.
public static CredentialInfo from(String connectionString) { CredentialInfo credentialInfo = new CredentialInfo(); if (ImplUtils.isNullOrEmpty(connectionString)) { throw new IllegalArgumentException(connectionString); } String[] args = connectionString.split(";"); if (args.length < 3) { throw new IllegalArgumentExcepti...
throw new IllegalArgumentException("invalid connection string segment count");
public static CredentialInfo from(String connectionString) { return createCredentialInfo(connectionString, null); }
class CredentialInfo { private static final String ENDPOINT = "Endpoint="; private static final String SHARED_ACCESS_KEY_NAME = "SharedAccessKeyName="; private static final String SHARED_ACCESS_KEY = "SharedAccessKey="; private static final String ENTITY_PATH = "EntityPath="; private static URI endpoint; private static...
class CredentialInfo { private static final String TOKEN_VALUE_SEPERATOR = "="; private static final String TOKEN_VALUE_PAIR_DELIMITER = ";"; private static final String ENDPOINT = "Endpoint"; private static final String SHARED_ACCESS_KEY_NAME = "SharedAccessKeyName"; private static final String SHARED_ACCESS_KEY = "Sh...
This should be a message, not the variable, which will be null or empty.
public static CredentialInfo from(String connectionString) { CredentialInfo credentialInfo = new CredentialInfo(); if (ImplUtils.isNullOrEmpty(connectionString)) { throw new IllegalArgumentException(connectionString); } String[] args = connectionString.split(";"); if (args.length < 3) { throw new IllegalArgumentExcepti...
throw new IllegalArgumentException(connectionString);
public static CredentialInfo from(String connectionString) { return createCredentialInfo(connectionString, null); }
class CredentialInfo { private static final String ENDPOINT = "Endpoint="; private static final String SHARED_ACCESS_KEY_NAME = "SharedAccessKeyName="; private static final String SHARED_ACCESS_KEY = "SharedAccessKey="; private static final String ENTITY_PATH = "EntityPath="; private static URI endpoint; private static...
class CredentialInfo { private static final String TOKEN_VALUE_SEPERATOR = "="; private static final String TOKEN_VALUE_PAIR_DELIMITER = ";"; private static final String ENDPOINT = "Endpoint"; private static final String SHARED_ACCESS_KEY_NAME = "SharedAccessKeyName"; private static final String SHARED_ACCESS_KEY = "Sh...
The .NET one does an "ordinal ignore case" comparison. We should try to do the ignore case to these too.
public static CredentialInfo from(String connectionString) { CredentialInfo credentialInfo = new CredentialInfo(); if (ImplUtils.isNullOrEmpty(connectionString)) { throw new IllegalArgumentException(connectionString); } String[] args = connectionString.split(";"); if (args.length < 3) { throw new IllegalArgumentExcepti...
if (segment.startsWith(ENDPOINT)) {
public static CredentialInfo from(String connectionString) { return createCredentialInfo(connectionString, null); }
class CredentialInfo { private static final String ENDPOINT = "Endpoint="; private static final String SHARED_ACCESS_KEY_NAME = "SharedAccessKeyName="; private static final String SHARED_ACCESS_KEY = "SharedAccessKey="; private static final String ENTITY_PATH = "EntityPath="; private static URI endpoint; private static...
class CredentialInfo { private static final String TOKEN_VALUE_SEPERATOR = "="; private static final String TOKEN_VALUE_PAIR_DELIMITER = ";"; private static final String ENDPOINT = "Endpoint"; private static final String SHARED_ACCESS_KEY_NAME = "SharedAccessKeyName"; private static final String SHARED_ACCESS_KEY = "Sh...
Use the error message from: https://github.com/Azure/azure-sdk-for-java/pull/3791/files#diff-a814032d30ff1457abeea40ac2ea360aR64
public static CredentialInfo from(String connectionString) { CredentialInfo credentialInfo = new CredentialInfo(); if (ImplUtils.isNullOrEmpty(connectionString)) { throw new IllegalArgumentException(connectionString); } String[] args = connectionString.split(";"); if (args.length < 3) { throw new IllegalArgumentExcepti...
throw new IllegalArgumentException("invalid connection string segment count");
public static CredentialInfo from(String connectionString) { return createCredentialInfo(connectionString, null); }
class CredentialInfo { private static final String ENDPOINT = "Endpoint="; private static final String SHARED_ACCESS_KEY_NAME = "SharedAccessKeyName="; private static final String SHARED_ACCESS_KEY = "SharedAccessKey="; private static final String ENTITY_PATH = "EntityPath="; private static URI endpoint; private static...
class CredentialInfo { private static final String TOKEN_VALUE_SEPERATOR = "="; private static final String TOKEN_VALUE_PAIR_DELIMITER = ";"; private static final String ENDPOINT = "Endpoint"; private static final String SHARED_ACCESS_KEY_NAME = "SharedAccessKeyName"; private static final String SHARED_ACCESS_KEY = "Sh...
nit: rename to connectionString rather than `connStr`. It's hard to read. This should be a message, not the variable itself.
public EventHubClient build() throws IllegalArgumentException { this.configuration = this.configuration == null ? ConfigurationManager.getConfiguration().clone() : this.configuration; this.proxyConfiguration = constructDefaultProxyConfiguration(this.configuration); if (this.credentials == null) { String connStr = this....
throw new IllegalArgumentException(connStr);
public EventHubClient build() { configuration = configuration == null ? ConfigurationManager.getConfiguration().clone() : configuration; if (credentials == null) { String connectionString = configuration.get(AZURE_EVENT_HUBS_CONNECTION_STRING); if (ImplUtils.isNullOrEmpty(connectionString)) { throw new IllegalArgumentE...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private CredentialInfo credentials; private TransportType transport; private Duration duration; private Scheduler scheduler; private ProxyConfiguration proxyConfiguration; private RetryPo...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private CredentialInfo credentials; private Configuration configuration; private Duration timeout; private ProxyConfiguration proxyConfiguration; private Retry retry; private Scheduler sc...
These variables (host, port, and proxy) can live inside the `if (proxyAddress != null) {` block. They aren't used outside of its scope.
private ProxyConfiguration constructDefaultProxyConfiguration(Configuration configuration) { ProxyAuthenticationType authentication = ProxyAuthenticationType.NONE; if (this.proxyConfiguration != null) { authentication = this.proxyConfiguration.authentication(); } String proxyAddress = configuration.get(BaseConfiguratio...
String host;
private ProxyConfiguration constructDefaultProxyConfiguration(Configuration configuration) { ProxyAuthenticationType authentication = ProxyAuthenticationType.NONE; if (proxyConfiguration != null) { authentication = proxyConfiguration.authentication(); } String proxyAddress = configuration.get(BaseConfigurations.HTTP_PR...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private CredentialInfo credentials; private TransportType transport; private Duration duration; private Scheduler scheduler; private ProxyConfiguration proxyConfiguration; private RetryPo...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private CredentialInfo credentials; private Configuration configuration; private Duration timeout; private ProxyConfiguration proxyConfiguration; private Retry retry; private Scheduler sc...
This if check can be removed. in the case that They want to use BASIC or DIGEST and do not pass in a username or password, the WebProxyHandler will fetch the System Defaults.
private ProxyConfiguration constructDefaultProxyConfiguration(Configuration configuration) { ProxyAuthenticationType authentication = ProxyAuthenticationType.NONE; if (this.proxyConfiguration != null) { authentication = this.proxyConfiguration.authentication(); } String proxyAddress = configuration.get(BaseConfiguratio...
if (authentication == ProxyAuthenticationType.BASIC || authentication == ProxyAuthenticationType.DIGEST) {
private ProxyConfiguration constructDefaultProxyConfiguration(Configuration configuration) { ProxyAuthenticationType authentication = ProxyAuthenticationType.NONE; if (proxyConfiguration != null) { authentication = proxyConfiguration.authentication(); } String proxyAddress = configuration.get(BaseConfigurations.HTTP_PR...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private CredentialInfo credentials; private TransportType transport; private Duration duration; private Scheduler scheduler; private ProxyConfiguration proxyConfiguration; private RetryPo...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private CredentialInfo credentials; private Configuration configuration; private Duration timeout; private ProxyConfiguration proxyConfiguration; private Retry retry; private Scheduler sc...
I think a smarter way to do this comparison is to do an additional split here on "=", and then compare the key of that path rather than the current way we are doing it. Having all these .toLowerCase() makes it unreadable where we could be using .equalsIgnoreCase(). If you need a reference, look at the .NET ConnectionSt...
public static CredentialInfo from(String connectionString) { CredentialInfo credentialInfo = new CredentialInfo(); if (ImplUtils.isNullOrEmpty(connectionString)) { throw new IllegalArgumentException("connection string is null or empty."); } String[] args = connectionString.split(";"); for (String arg : args) { String s...
if (lowerCaseSegment.startsWith(ENDPOINT.toLowerCase(Locale.ENGLISH))) {
public static CredentialInfo from(String connectionString) { return createCredentialInfo(connectionString, null); }
class CredentialInfo { private static final String ENDPOINT = "Endpoint="; private static final String SHARED_ACCESS_KEY_NAME = "SharedAccessKeyName="; private static final String SHARED_ACCESS_KEY = "SharedAccessKey="; private static final String ENTITY_PATH = "EntityPath="; private URI endpoint; private String shared...
class CredentialInfo { private static final String TOKEN_VALUE_SEPERATOR = "="; private static final String TOKEN_VALUE_PAIR_DELIMITER = ";"; private static final String ENDPOINT = "Endpoint"; private static final String SHARED_ACCESS_KEY_NAME = "SharedAccessKeyName"; private static final String SHARED_ACCESS_KEY = "Sh...
Private method is still up here.
private static URI getURI(String endpointFormat, String namespaceName, String domainName) { try { return new URI(String.format(Locale.US, endpointFormat, namespaceName, domainName)); } catch (URISyntaxException exception) { throw new IllegalArgumentException(String.format(Locale.US, "Invalid namespace name: %s", namesp...
return new URI(String.format(Locale.US, endpointFormat, namespaceName, domainName));
private static URI getURI(String endpointFormat, String namespaceName, String domainName) { try { return new URI(String.format(Locale.US, endpointFormat, namespaceName, domainName)); } catch (URISyntaxException exception) { throw new IllegalArgumentException(String.format(Locale.US, "Invalid namespace name: %s", namesp...
class EventHubClientBuilderTest { private static final String END_POINT_FORMAT = "sb: private static final String NAMESPACE_NAME = "dummyNamespaceName"; private static final String DEFAULT_DOMAIN_NAME = "servicebus.windows.net/"; private static final String SHARED_ACCESS_KEY_NAME = "dummySasKeyName"; private static fin...
class EventHubClientBuilderTest { private static final String NAMESPACE_NAME = "dummyNamespaceName"; private static final String DEFAULT_DOMAIN_NAME = "servicebus.windows.net/"; private static final String ENTITY_PATH = "dummyEntityPath"; private static final String SHARED_ACCESS_KEY_NAME = "dummySasKeyName"; private s...
nit: You don't need to specify `this` for all your variable accesses in this method. There is no confusion between whether the variable belongs to the class or is scoped locally. imho, it adds extra reading when I already know we are trying to set the variables for the class. In the case of the constructor, where it's ...
public EventHubClient build() { this.configuration = this.configuration == null ? ConfigurationManager.getConfiguration().clone() : this.configuration; if (this.credentials == null) { String connectionString = this.configuration.get(AZURE_EVENT_HUBS_CONNECTION_STRING); if (ImplUtils.isNullOrEmpty(connectionString)) { t...
this.configuration = this.configuration == null ? ConfigurationManager.getConfiguration().clone() : this.configuration;
public EventHubClient build() { configuration = configuration == null ? ConfigurationManager.getConfiguration().clone() : configuration; if (credentials == null) { String connectionString = configuration.get(AZURE_EVENT_HUBS_CONNECTION_STRING); if (ImplUtils.isNullOrEmpty(connectionString)) { throw new IllegalArgumentE...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private CredentialInfo credentials; private Configuration configuration; private Duration timeout; private ProxyConfiguration proxyConfiguration; private Retry retry; private Scheduler sc...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private CredentialInfo credentials; private Configuration configuration; private Duration timeout; private ProxyConfiguration proxyConfiguration; private Retry retry; private Scheduler sc...
Since you're covering this case below, should we consider removing this so that the message is consistent for `null` and `""` ?
public ErrorContext(final Throwable exception, final String namespaceName) { Objects.requireNonNull(exception); if (ImplUtils.isNullOrEmpty(namespaceName)) { throw new IllegalArgumentException("'namespaceName' cannot be null or empty"); } this.namespaceName = namespaceName; this.exception = exception; }
Objects.requireNonNull(exception);
public ErrorContext(final Throwable exception, final String namespaceName) { Objects.requireNonNull(exception); if (ImplUtils.isNullOrEmpty(namespaceName)) { throw new IllegalArgumentException("'namespaceName' cannot be null or empty"); } this.namespaceName = namespaceName; this.exception = exception; }
class ErrorContext implements Serializable { private static final long serialVersionUID = -2819764407122954922L; private final String namespaceName; private final Throwable exception; /** * Creates a new instance with the provided {@code namespaceName}. * * @param exception Exception that caused this error. * @param na...
class ErrorContext implements Serializable { private static final long serialVersionUID = -2819764407122954922L; private final String namespaceName; private final Throwable exception; /** * Creates a new instance with the provided {@code namespaceName}. * * @param exception Exception that caused this error. * @param na...
It will throw a NullPointerException if exception == null. I updated the docs to state this.
public ErrorContext(final Throwable exception, final String namespaceName) { Objects.requireNonNull(exception); if (ImplUtils.isNullOrEmpty(namespaceName)) { throw new IllegalArgumentException("'namespaceName' cannot be null or empty"); } this.namespaceName = namespaceName; this.exception = exception; }
Objects.requireNonNull(exception);
public ErrorContext(final Throwable exception, final String namespaceName) { Objects.requireNonNull(exception); if (ImplUtils.isNullOrEmpty(namespaceName)) { throw new IllegalArgumentException("'namespaceName' cannot be null or empty"); } this.namespaceName = namespaceName; this.exception = exception; }
class ErrorContext implements Serializable { private static final long serialVersionUID = -2819764407122954922L; private final String namespaceName; private final Throwable exception; /** * Creates a new instance with the provided {@code namespaceName}. * * @param exception Exception that caused this error. * @param na...
class ErrorContext implements Serializable { private static final long serialVersionUID = -2819764407122954922L; private final String namespaceName; private final Throwable exception; /** * Creates a new instance with the provided {@code namespaceName}. * * @param exception Exception that caused this error. * @param na...
Should this be an AmqpException?
public void close() { if (hasConnection.getAndSet(false)) { try { final AmqpConnection connection = connectionMono.block(timeout); if (connection != null) { connection.close(); } } catch (IOException exception) { throw new AzureException("Unable to close connection to service", exception); } } }
throw new AzureException("Unable to close connection to service", exception);
public void close() { if (hasConnection.getAndSet(false)) { try { final AmqpConnection connection = connectionMono.block(timeout); if (connection != null) { connection.close(); } } catch (IOException exception) { throw new AmqpException(false, "Unable to close connection to service", exception); } } }
class EventHubClient implements Closeable { private final String connectionId; private final Mono<AmqpConnection> connectionMono; private final String host; private final AtomicBoolean hasConnection = new AtomicBoolean(false); private final ConnectionStringBuilder connectionStringBuilder; private final Duration timeout...
class EventHubClient implements Closeable { private final String connectionId; private final Mono<AmqpConnection> connectionMono; private final String host; private final AtomicBoolean hasConnection = new AtomicBoolean(false); private final ConnectionStringBuilder connectionStringBuilder; private final Duration timeout...
If the lastException is null or not an instance of AmqpException, we should return `null`. For example, an IllegalArgumentException is not retriable.
public Duration getNextRetryInterval(Exception lastException, Duration remainingTime) { int baseWaitTime = 0; if (lastException == null || !(lastException instanceof AmqpException)) { return this.onGetNextRetryInterval(lastException, remainingTime, baseWaitTime, this.getRetryCount()); } if (((AmqpException) lastExcepti...
if (lastException == null || !(lastException instanceof AmqpException)) {
public Duration getNextRetryInterval(Exception lastException, Duration remainingTime) { int baseWaitTime = 0; if (!isRetriableException(lastException)) { return null; } if (retryCount.get() >= maxRetryCount) { return null; } if (((AmqpException) lastException).getErrorCondition() == ErrorCondition.SERVER_BUSY_ERROR) { ...
class Retry { public static final Retry NO_RETRY = new RetryExponential(Duration.ofSeconds(0), Duration.ofSeconds(0), 0); private AtomicInteger retryCount = new AtomicInteger(0); /** * Check if the existing exception is a retryable exception. * * @param exception A exception that was observed for the operation to be re...
class Retry { public static final Duration DEFAULT_RETRY_MIN_BACKOFF = Duration.ofSeconds(0); public static final Duration DEFAULT_RETRY_MAX_BACKOFF = Duration.ofSeconds(30); public static final int DEFAULT_MAX_RETRY_COUNT = 10; private final AtomicInteger retryCount = new AtomicInteger(); private final int maxRetryCou...
You should also test that the exception is retryable or not, and if they have hit the maximum number of attempts. These are checks that are agnostic of the retry algorithm.
public Duration getNextRetryInterval(Exception lastException, Duration remainingTime) { int baseWaitTime = 0; if (lastException == null || !(lastException instanceof AmqpException)) { return this.onGetNextRetryInterval(lastException, remainingTime, baseWaitTime, this.getRetryCount()); } if (((AmqpException) lastExcepti...
if (lastException == null || !(lastException instanceof AmqpException)) {
public Duration getNextRetryInterval(Exception lastException, Duration remainingTime) { int baseWaitTime = 0; if (!isRetriableException(lastException)) { return null; } if (retryCount.get() >= maxRetryCount) { return null; } if (((AmqpException) lastException).getErrorCondition() == ErrorCondition.SERVER_BUSY_ERROR) { ...
class Retry { public static final Retry NO_RETRY = new RetryExponential(Duration.ofSeconds(0), Duration.ofSeconds(0), 0); private AtomicInteger retryCount = new AtomicInteger(0); /** * Check if the existing exception is a retryable exception. * * @param exception A exception that was observed for the operation to be re...
class Retry { public static final Duration DEFAULT_RETRY_MIN_BACKOFF = Duration.ofSeconds(0); public static final Duration DEFAULT_RETRY_MAX_BACKOFF = Duration.ofSeconds(30); public static final int DEFAULT_MAX_RETRY_COUNT = 10; private final AtomicInteger retryCount = new AtomicInteger(); private final int maxRetryCou...
What I mean is that the logic for if the exception is retryable or not and max attempts (including maxRetryCount) should be in Retry.java rather than ExponentialRetry.java because the max retries and is transient applies to _all_ retry policies.
public Duration getNextRetryInterval(Exception lastException, Duration remainingTime) { int baseWaitTime = 0; if (lastException == null || !(lastException instanceof AmqpException)) { return this.onGetNextRetryInterval(lastException, remainingTime, baseWaitTime, this.getRetryCount()); } if (((AmqpException) lastExcepti...
if (lastException == null || !(lastException instanceof AmqpException)) {
public Duration getNextRetryInterval(Exception lastException, Duration remainingTime) { int baseWaitTime = 0; if (!isRetriableException(lastException)) { return null; } if (retryCount.get() >= maxRetryCount) { return null; } if (((AmqpException) lastException).getErrorCondition() == ErrorCondition.SERVER_BUSY_ERROR) { ...
class Retry { public static final Retry NO_RETRY = new RetryExponential(Duration.ofSeconds(0), Duration.ofSeconds(0), 0); private AtomicInteger retryCount = new AtomicInteger(0); /** * Check if the existing exception is a retryable exception. * * @param exception A exception that was observed for the operation to be re...
class Retry { public static final Duration DEFAULT_RETRY_MIN_BACKOFF = Duration.ofSeconds(0); public static final Duration DEFAULT_RETRY_MAX_BACKOFF = Duration.ofSeconds(30); public static final int DEFAULT_MAX_RETRY_COUNT = 10; private final AtomicInteger retryCount = new AtomicInteger(); private final int maxRetryCou...
you're missing a verification that this AmqpException is also transient.
public Duration getNextRetryInterval(Exception lastException, Duration remainingTime) { int baseWaitTime = 0; if (lastException == null || !(lastException instanceof AmqpException)) { return null; } if (this.retryCount.get() >= maxRetryCount) { return null; } if (((AmqpException) lastException).getErrorCondition() == E...
if (this.retryCount.get() >= maxRetryCount) {
public Duration getNextRetryInterval(Exception lastException, Duration remainingTime) { int baseWaitTime = 0; if (!isRetriableException(lastException)) { return null; } if (retryCount.get() >= maxRetryCount) { return null; } if (((AmqpException) lastException).getErrorCondition() == ErrorCondition.SERVER_BUSY_ERROR) { ...
class Retry { public static final Duration DEFAULT_RETRY_MIN_BACKOFF = Duration.ofSeconds(0); public static final Duration DEFAULT_RETRY_MAX_BACKOFF = Duration.ofSeconds(30); public static final int DEFAULT_MAX_RETRY_COUNT = 10; private final AtomicInteger retryCount = new AtomicInteger(); private final int maxRetryCou...
class Retry { public static final Duration DEFAULT_RETRY_MIN_BACKOFF = Duration.ofSeconds(0); public static final Duration DEFAULT_RETRY_MAX_BACKOFF = Duration.ofSeconds(30); public static final int DEFAULT_MAX_RETRY_COUNT = 10; private final AtomicInteger retryCount = new AtomicInteger(); private final int maxRetryCou...
nit: you don't need to specify `this`. There is no other variable declared in this scope with the same name.
public int maxRetryCount() { return this.maxRetryCount; }
return this.maxRetryCount;
public int maxRetryCount() { return maxRetryCount; }
class Retry { public static final Duration DEFAULT_RETRY_MIN_BACKOFF = Duration.ofSeconds(0); public static final Duration DEFAULT_RETRY_MAX_BACKOFF = Duration.ofSeconds(30); public static final int DEFAULT_MAX_RETRY_COUNT = 10; private final AtomicInteger retryCount = new AtomicInteger(); private final int maxRetryCou...
class Retry { public static final Duration DEFAULT_RETRY_MIN_BACKOFF = Duration.ofSeconds(0); public static final Duration DEFAULT_RETRY_MAX_BACKOFF = Duration.ofSeconds(30); public static final int DEFAULT_MAX_RETRY_COUNT = 10; private final AtomicInteger retryCount = new AtomicInteger(); private final int maxRetryCou...
nit: you don't need to specify `this`. There is no other variable declared in this scope with the same name.
private double computeRetryFactor() { final long deltaBackoff = this.maxBackoff.minus(this.minBackoff).getSeconds(); if (deltaBackoff <= 0 || super.maxRetryCount() <= 0) { return 0; } return Math.log(deltaBackoff) / Math.log(super.maxRetryCount()); }
final long deltaBackoff = this.maxBackoff.minus(this.minBackoff).getSeconds();
private double computeRetryFactor() { final long deltaBackoff = maxBackoff.minus(minBackoff).getSeconds(); if (deltaBackoff <= 0 || super.maxRetryCount() <= 0) { return 0; } return Math.log(deltaBackoff) / Math.log(super.maxRetryCount()); }
class ExponentialRetry extends Retry { public static final Duration TIMER_TOLERANCE = Duration.ofSeconds(1); private final Duration minBackoff; private final Duration maxBackoff; private final double retryFactor; /** * @param minBackoff The minimum time period permissible for backing off between retries. * @param maxBa...
class ExponentialRetry extends Retry { public static final Duration TIMER_TOLERANCE = Duration.ofSeconds(1); private final Duration minBackoff; private final Duration maxBackoff; private final double retryFactor; /** * Creates a new instance with a minimum and maximum retry period in addition to maximum number of retry...
nit: Any reason each parameter is on a new line? Does it reach the 120 characters/line limit?
public static Retry getDefaultRetry() { return new ExponentialRetry( DEFAULT_RETRY_MIN_BACKOFF, DEFAULT_RETRY_MAX_BACKOFF, DEFAULT_MAX_RETRY_COUNT); }
DEFAULT_RETRY_MIN_BACKOFF,
public static Retry getDefaultRetry() { return new ExponentialRetry(DEFAULT_RETRY_MIN_BACKOFF, DEFAULT_RETRY_MAX_BACKOFF, DEFAULT_MAX_RETRY_COUNT); }
class Retry { public static final Duration DEFAULT_RETRY_MIN_BACKOFF = Duration.ofSeconds(0); public static final Duration DEFAULT_RETRY_MAX_BACKOFF = Duration.ofSeconds(30); public static final int DEFAULT_MAX_RETRY_COUNT = 10; private final AtomicInteger retryCount = new AtomicInteger(); private final int maxRetryCou...
class Retry { public static final Duration DEFAULT_RETRY_MIN_BACKOFF = Duration.ofSeconds(0); public static final Duration DEFAULT_RETRY_MAX_BACKOFF = Duration.ofSeconds(30); public static final int DEFAULT_MAX_RETRY_COUNT = 10; private final AtomicInteger retryCount = new AtomicInteger(); private final int maxRetryCou...
> return new String[] { resource + "/.default" }; [](start = 7, length = 48) Should this use the DEFAULT_SUFFIX constant above?
public static String[] resourceToScopes(String resource) { Objects.requireNonNull(resource); return new String[] { resource + "/.default" }; }
return new String[] { resource + "/.default" };
public static String[] resourceToScopes(String resource) { Objects.requireNonNull(resource); return new String[] { resource + DEFAULT_SUFFIX }; }
class ScopeUtil { private static final String DEFAULT_SUFFIX = "/.defualt"; /** * Convert a list of scopes to a resource for Azure Active Directory. * @param scopes the list of scopes to authenticate to * @return the resource to authenticate with Azure Active Directory. * @throws IllegalArgumentException if scopes is e...
class ScopeUtil { private static final String DEFAULT_SUFFIX = "/.default"; /** * Convert a list of scopes to a resource for Azure Active Directory. * @param scopes the list of scopes to authenticate to * @return the resource to authenticate with Azure Active Directory. * @throws IllegalArgumentException if scopes is e...
This should be a CheckStyle warning. No left curly brace for a new line.
public String toString() { if (StringUtil.isNullOrWhiteSpace(this.connectionString)) { StringBuilder connectionStringBuilder = new StringBuilder(); if (this.endpoint != null) { connectionStringBuilder.append(String.format(Locale.US, "%s%s%s%s", ENDPOINT_CONFIG_NAME, KEY_VALUE_SEPARATOR, this.endpoint.toString(), KEY_VA...
{
public String toString() { if (StringUtil.isNullOrWhiteSpace(this.connectionString)) { StringBuilder connectionStringBuilder = new StringBuilder(); if (this.endpoint != null) { connectionStringBuilder.append(String.format(Locale.US, "%s%s%s%s", ENDPOINT_CONFIG_NAME, KEY_VALUE_SEPARATOR, this.endpoint.toString(), KEY_VA...
class ConnectionStringBuilder { private static final String END_POINT_RAW_FORMAT = "amqps: private static final String HOSTNAME_CONFIG_NAME = "Hostname"; private static final String ENDPOINT_CONFIG_NAME = "Endpoint"; private static final String SHARED_ACCESS_KEY_NAME_CONFIG_NAME = "SharedAccessKeyName"; private static ...
class ConnectionStringBuilder { private static final String END_POINT_RAW_FORMAT = "amqps: private static final String HOSTNAME_CONFIG_NAME = "Hostname"; private static final String ENDPOINT_CONFIG_NAME = "Endpoint"; private static final String SHARED_ACCESS_KEY_NAME_CONFIG_NAME = "SharedAccessKeyName"; private static ...
I have tested what happen if I put empty string for date. It did not pass then. At the time we tested the API, the input and output I got is like: Header as input ``` headers: { Content-Length:0 If-Match: null ... } ``` The string after we built: ``` 0 null ``` Null are not supposed to appear in the string. This...
private String buildStringToSign(URL requestURL, String httpMethod, Map<String, String> headers) { String contentLength = headers.get("Content-Length"); contentLength = contentLength.equals("0") ? "" : contentLength; String dateHeader = (headers.containsKey("x-ms-date")) ? "" : headers.getOrDefault("Date", ""); return ...
String dateHeader = (headers.containsKey("x-ms-date")) ? "" : headers.getOrDefault("Date", "");
private String buildStringToSign(URL requestURL, String httpMethod, Map<String, String> headers) { String contentLength = headers.get("Content-Length"); contentLength = contentLength.equals("0") ? "" : contentLength; String dateHeader = (headers.containsKey("x-ms-date")) ? "" : headers.getOrDefault("Date", ""); return ...
class SharedKeyCredential { private static final String AUTHORIZATION_HEADER_FORMAT = "SharedKey %s:%s"; private static final String ACCOUNT_NAME = "AccountName".toLowerCase(); private static final String ACCOUNT_KEY = "AccountKey".toLowerCase(); private final String accountName; private final byte[] accountKey; /** * ...
class SharedKeyCredential { private static final String AUTHORIZATION_HEADER_FORMAT = "SharedKey %s:%s"; private static final String ACCOUNT_NAME = "AccountName".toLowerCase(); private static final String ACCOUNT_KEY = "AccountKey".toLowerCase(); private final String accountName; private final byte[] accountKey; /** * ...
Does this get the value for an environment variable by the name `AZURE_EVENT_HUBS_CONNECTION_STRING`? I don't believe any of the other languages support reading from env variables at the moment. Was this feature ported over from Track1?
public EventHubClient build() { configuration = configuration == null ? ConfigurationManager.getConfiguration().clone() : configuration; if (credentials == null) { final String connectionString = configuration.get(AZURE_EVENT_HUBS_CONNECTION_STRING); if (ImplUtils.isNullOrEmpty(connectionString)) { throw new IllegalArg...
final String connectionString = configuration.get(AZURE_EVENT_HUBS_CONNECTION_STRING);
public EventHubClient build() { configuration = configuration == null ? ConfigurationManager.getConfiguration().clone() : configuration; if (credentials == null) { final String connectionString = configuration.get(AZURE_EVENT_HUBS_CONNECTION_STRING); if (ImplUtils.isNullOrEmpty(connectionString)) { throw new IllegalArg...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private TokenCredential credentials; private Configuration configuration; private Duration timeout; private ProxyConfiguration proxyConfiguration; private Retry retry; private Scheduler s...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private TokenCredential credentials; private Configuration configuration; private Duration timeout; private ProxyConfiguration proxyConfiguration; private Retry retry; private Scheduler s...
no. It was something we added. is there no mention of reading from env vars? i can rmeove it.
public EventHubClient build() { configuration = configuration == null ? ConfigurationManager.getConfiguration().clone() : configuration; if (credentials == null) { final String connectionString = configuration.get(AZURE_EVENT_HUBS_CONNECTION_STRING); if (ImplUtils.isNullOrEmpty(connectionString)) { throw new IllegalArg...
final String connectionString = configuration.get(AZURE_EVENT_HUBS_CONNECTION_STRING);
public EventHubClient build() { configuration = configuration == null ? ConfigurationManager.getConfiguration().clone() : configuration; if (credentials == null) { final String connectionString = configuration.get(AZURE_EVENT_HUBS_CONNECTION_STRING); if (ImplUtils.isNullOrEmpty(connectionString)) { throw new IllegalArg...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private TokenCredential credentials; private Configuration configuration; private Duration timeout; private ProxyConfiguration proxyConfiguration; private Retry retry; private Scheduler s...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private TokenCredential credentials; private Configuration configuration; private Duration timeout; private ProxyConfiguration proxyConfiguration; private Retry retry; private Scheduler s...
You don't **have** to remove it, just don't document it until we have a consensus around it :) We can discuss this on Monday's sync up
public EventHubClient build() { configuration = configuration == null ? ConfigurationManager.getConfiguration().clone() : configuration; if (credentials == null) { final String connectionString = configuration.get(AZURE_EVENT_HUBS_CONNECTION_STRING); if (ImplUtils.isNullOrEmpty(connectionString)) { throw new IllegalArg...
final String connectionString = configuration.get(AZURE_EVENT_HUBS_CONNECTION_STRING);
public EventHubClient build() { configuration = configuration == null ? ConfigurationManager.getConfiguration().clone() : configuration; if (credentials == null) { final String connectionString = configuration.get(AZURE_EVENT_HUBS_CONNECTION_STRING); if (ImplUtils.isNullOrEmpty(connectionString)) { throw new IllegalArg...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private TokenCredential credentials; private Configuration configuration; private Duration timeout; private ProxyConfiguration proxyConfiguration; private Retry retry; private Scheduler s...
class EventHubClientBuilder { private static final String AZURE_EVENT_HUBS_CONNECTION_STRING = "AZURE_EVENT_HUBS_CONNECTION_STRING"; private TokenCredential credentials; private Configuration configuration; private Duration timeout; private ProxyConfiguration proxyConfiguration; private Retry retry; private Scheduler s...
nice. You've got an elegant way to do this, at least.
public Mono<Void> send(EventData event) { Objects.requireNonNull(event); return send(Flux.just(event)); }
return send(Flux.just(event));
public Mono<Void> send(EventData event) { Objects.requireNonNull(event); return send(Flux.just(event)); }
class EventSender implements Closeable { /** * The default maximum allowable size, in bytes, for a batch to be sent. */ public static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024; private static final int MAX_PARTITION_KEY_LENGTH = 128; private static final SendOptions DEFAULT_BATCHING_OPTIONS = new SendOptions(); p...
class EventSender implements Closeable { /** * The default maximum allowable size, in bytes, for a batch to be sent. */ public static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024; private static final int MAX_PARTITION_KEY_LENGTH = 128; private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions(); priva...
I do not see need for it now and confirmed with Alan as well.
public void log(String format, Object... args) { if (canLogAtLevel(level)) { performLogging(format, args); } }
}
public void log(String format, Object... args) { if (canLogAtLevel(level)) { performLogging(format, args); } }
class name using the {@link LoggerFactory}
class name using the {@link LoggerFactory}
I believe this is incorrect - if no configuration is specified, we should use the global configuration, not 'no' configuration (i.e. an empty Map). Please confirm with @alzimmermsft (and maybe ensure that all other client libraries aren't doing this either!)
private AzureBlobStorageBuilder buildImpl() { Objects.requireNonNull(endpoint); Objects.requireNonNull(containerName); Objects.requireNonNull(blobName); final List<HttpPipelinePolicy> policies = new ArrayList<>(); if (configuration == null) { configuration = Configuration.NONE; } policies.add(new UserAgentPolicy(BlobCo...
}
private AzureBlobStorageBuilder buildImpl() { Objects.requireNonNull(endpoint); Objects.requireNonNull(containerName); Objects.requireNonNull(blobName); final List<HttpPipelinePolicy> policies = new ArrayList<>(); if (configuration == null) { configuration = ConfigurationManager.getConfiguration(); } policies.add(new U...
class AppendBlobClientBuilder { private static final String ACCOUNT_NAME = "AccountName".toLowerCase(); private static final String ACCOUNT_KEY = "AccountKey".toLowerCase(); private static final String ENDPOINT_PROTOCOL = "DefaultEndpointsProtocol".toLowerCase(); private static final String ENDPOINT_SUFFIX = "EndpointS...
class AppendBlobClientBuilder { private static final String ACCOUNT_NAME = "accountname"; private static final String ACCOUNT_KEY = "accountkey"; private static final String ENDPOINT_PROTOCOL = "defaultendpointsprotocol"; private static final String ENDPOINT_SUFFIX = "endpointsuffix"; private final List<HttpPipelinePol...
This type of URL parsing will be used a lot in the Storage SDKs, should we promote this functionality to a utility class in commons? Potentially move this into Azure Core if we see fit?
public BlobClientBuilder endpoint(String endpoint) { Objects.requireNonNull(endpoint); URL url; try { url = new URL(endpoint); this.endpoint = new URL(url.getProtocol() + ": String path = url.getPath(); if (path != null && !path.isEmpty() && !path.equals("/")) { path = path.replaceAll("^/", "").replaceAll("/$", ""); St...
url = new URL(endpoint);
public BlobClientBuilder endpoint(String endpoint) { Objects.requireNonNull(endpoint); URL url; try { url = new URL(endpoint); BlobURLParts parts = URLParser.parse(url); this.endpoint = parts.scheme() + ": if (parts.containerName() != null) { this.containerName = parts.containerName(); } if (parts.blobName() != null) {...
class BlobClientBuilder { private static final String ACCOUNT_NAME = "AccountName".toLowerCase(); private static final String ACCOUNT_KEY = "AccountKey".toLowerCase(); private static final String ENDPOINT_PROTOCOL = "DefaultEndpointsProtocol".toLowerCase(); private static final String ENDPOINT_SUFFIX = "EndpointSuffix"...
class BlobClientBuilder { private static final String ACCOUNT_NAME = "accountname"; private static final String ACCOUNT_KEY = "accountkey"; private static final String ENDPOINT_PROTOCOL = "defaultendpointsprotocol"; private static final String ENDPOINT_SUFFIX = "endpointsuffix"; private final List<HttpPipelinePolicy> p...
In the other SDKs the default is to use the global configuration, it is a fair question to ask if the configuration store should be opt-in (default to Configuration.NONE) or opt-out (default to the global configuration store). Both approaches have their pros and cons. For now we should switch this to align with the ot...
private AzureBlobStorageBuilder buildImpl() { Objects.requireNonNull(endpoint); Objects.requireNonNull(containerName); Objects.requireNonNull(blobName); final List<HttpPipelinePolicy> policies = new ArrayList<>(); if (configuration == null) { configuration = Configuration.NONE; } policies.add(new UserAgentPolicy(BlobCo...
}
private AzureBlobStorageBuilder buildImpl() { Objects.requireNonNull(endpoint); Objects.requireNonNull(containerName); Objects.requireNonNull(blobName); final List<HttpPipelinePolicy> policies = new ArrayList<>(); if (configuration == null) { configuration = ConfigurationManager.getConfiguration(); } policies.add(new U...
class AppendBlobClientBuilder { private static final String ACCOUNT_NAME = "AccountName".toLowerCase(); private static final String ACCOUNT_KEY = "AccountKey".toLowerCase(); private static final String ENDPOINT_PROTOCOL = "DefaultEndpointsProtocol".toLowerCase(); private static final String ENDPOINT_SUFFIX = "EndpointS...
class AppendBlobClientBuilder { private static final String ACCOUNT_NAME = "accountname"; private static final String ACCOUNT_KEY = "accountkey"; private static final String ENDPOINT_PROTOCOL = "defaultendpointsprotocol"; private static final String ENDPOINT_SUFFIX = "endpointsuffix"; private final List<HttpPipelinePol...
This is not always true. If the customer has set up a root container, it's possible to have a blobUrl of the format: myaccount.blob.core.windows.net/blobName
public AppendBlobClientBuilder endpoint(String endpoint) { Objects.requireNonNull(endpoint); URL url; try { url = new URL(endpoint); this.endpoint = new URL(url.getProtocol() + ": String path = url.getPath(); if (path != null && !path.isEmpty() && !path.equals("/")) { path = path.replaceAll("^/", "").replaceAll("/$", "...
throw new IllegalArgumentException("Endpoint should contain 0 or at least 2 path segments");
public AppendBlobClientBuilder endpoint(String endpoint) { Objects.requireNonNull(endpoint); URL url; try { url = new URL(endpoint); BlobURLParts parts = URLParser.parse(url); this.endpoint = parts.scheme() + ": if (parts.containerName() != null) { this.containerName = parts.containerName(); } if (parts.blobName() != n...
class AppendBlobClientBuilder { private static final String ACCOUNT_NAME = "AccountName".toLowerCase(); private static final String ACCOUNT_KEY = "AccountKey".toLowerCase(); private static final String ENDPOINT_PROTOCOL = "DefaultEndpointsProtocol".toLowerCase(); private static final String ENDPOINT_SUFFIX = "EndpointS...
class AppendBlobClientBuilder { private static final String ACCOUNT_NAME = "accountname"; private static final String ACCOUNT_KEY = "accountkey"; private static final String ENDPOINT_PROTOCOL = "defaultendpointsprotocol"; private static final String ENDPOINT_SUFFIX = "endpointsuffix"; private final List<HttpPipelinePol...
I'm using BlobUrlParts now with UrlParser.
public AppendBlobClientBuilder endpoint(String endpoint) { Objects.requireNonNull(endpoint); URL url; try { url = new URL(endpoint); this.endpoint = new URL(url.getProtocol() + ": String path = url.getPath(); if (path != null && !path.isEmpty() && !path.equals("/")) { path = path.replaceAll("^/", "").replaceAll("/$", "...
throw new IllegalArgumentException("Endpoint should contain 0 or at least 2 path segments");
public AppendBlobClientBuilder endpoint(String endpoint) { Objects.requireNonNull(endpoint); URL url; try { url = new URL(endpoint); BlobURLParts parts = URLParser.parse(url); this.endpoint = parts.scheme() + ": if (parts.containerName() != null) { this.containerName = parts.containerName(); } if (parts.blobName() != n...
class AppendBlobClientBuilder { private static final String ACCOUNT_NAME = "AccountName".toLowerCase(); private static final String ACCOUNT_KEY = "AccountKey".toLowerCase(); private static final String ENDPOINT_PROTOCOL = "DefaultEndpointsProtocol".toLowerCase(); private static final String ENDPOINT_SUFFIX = "EndpointS...
class AppendBlobClientBuilder { private static final String ACCOUNT_NAME = "accountname"; private static final String ACCOUNT_KEY = "accountkey"; private static final String ENDPOINT_PROTOCOL = "defaultendpointsprotocol"; private static final String ENDPOINT_SUFFIX = "endpointsuffix"; private final List<HttpPipelinePol...
There turns out to be a utility already - BlobUrlParts can be created from UrlParser.
public BlobClientBuilder endpoint(String endpoint) { Objects.requireNonNull(endpoint); URL url; try { url = new URL(endpoint); this.endpoint = new URL(url.getProtocol() + ": String path = url.getPath(); if (path != null && !path.isEmpty() && !path.equals("/")) { path = path.replaceAll("^/", "").replaceAll("/$", ""); St...
url = new URL(endpoint);
public BlobClientBuilder endpoint(String endpoint) { Objects.requireNonNull(endpoint); URL url; try { url = new URL(endpoint); BlobURLParts parts = URLParser.parse(url); this.endpoint = parts.scheme() + ": if (parts.containerName() != null) { this.containerName = parts.containerName(); } if (parts.blobName() != null) {...
class BlobClientBuilder { private static final String ACCOUNT_NAME = "AccountName".toLowerCase(); private static final String ACCOUNT_KEY = "AccountKey".toLowerCase(); private static final String ENDPOINT_PROTOCOL = "DefaultEndpointsProtocol".toLowerCase(); private static final String ENDPOINT_SUFFIX = "EndpointSuffix"...
class BlobClientBuilder { private static final String ACCOUNT_NAME = "accountname"; private static final String ACCOUNT_KEY = "accountkey"; private static final String ENDPOINT_PROTOCOL = "defaultendpointsprotocol"; private static final String ENDPOINT_SUFFIX = "endpointsuffix"; private final List<HttpPipelinePolicy> p...
You'd want to strip all but the first, not the last. Blob names can have forward slashes in them. Example: `https://myaccoutn/blob.core.windows.net/containername/blobname/stillblobname/evenMoreOfTheSameBlobNameContainingSlashes`. Unless I'm wrong as to what this utility method does, in which case I'd ask it be renamed ...
public ContainerAsyncClient getContainerAsyncClient() { return new ContainerAsyncClient(new AzureBlobStorageBuilder() .url(Utility.stripLastPathSegment(getBlobUrl()).toString()) .pipeline(blobAsyncRawClient.azureBlobStorage.httpPipeline())); }
.url(Utility.stripLastPathSegment(getBlobUrl()).toString())
public ContainerAsyncClient getContainerAsyncClient() { try { BlobURLParts parts = URLParser.parse(getBlobUrl()); return new ContainerAsyncClient(new AzureBlobStorageBuilder() .url(String.format("%s: .pipeline(blobAsyncRawClient.azureBlobStorage.httpPipeline())); } catch (UnknownHostException e) { throw new RuntimeExce...
class BlobAsyncClient { private static final long BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB; final BlobAsyncRawClient blobAsyncRawClient; private final String snapshot; /** * Package-private constructor for use by {@link BlobClientBuilder}. * @param azureBlobStorageBuilder the API client builder for blob stor...
class BlobAsyncClient { private static final int BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB; private static final int BLOB_MAX_DOWNLOAD_BLOCK_SIZE = 100 * Constants.MB; final BlobAsyncRawClient blobAsyncRawClient; /** * Package-private constructor for use by {@link BlobClientBuilder}. * @param azureBlobStorage...
We can't make an extra getProperties call just to get the size. This potentially doubles the number of IO operations. Is there a reason why we didn't just pull the implementation from v11?
private Mono<BlobRange> getFullBlobRange(BlobAccessConditions accessConditions) { return getProperties(accessConditions).map(rb -> new BlobRange(0, rb.value().blobSize())); }
return getProperties(accessConditions).map(rb -> new BlobRange(0, rb.value().blobSize()));
private Mono<BlobRange> getFullBlobRange(BlobAccessConditions accessConditions) { return getProperties(accessConditions).map(rb -> new BlobRange(0, rb.value().blobSize())); }
class BlobAsyncClient { private static final long BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB; final BlobAsyncRawClient blobAsyncRawClient; private final String snapshot; /** * Package-private constructor for use by {@link BlobClientBuilder}. * @param azureBlobStorageBuilder the API client builder for blob stor...
class BlobAsyncClient { private static final int BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB; private static final int BLOB_MAX_DOWNLOAD_BLOCK_SIZE = 100 * Constants.MB; final BlobAsyncRawClient blobAsyncRawClient; /** * Package-private constructor for use by {@link BlobClientBuilder}. * @param azureBlobStorage...
This also does not support etag locking or progress reporting.
private Mono<BlobRange> getFullBlobRange(BlobAccessConditions accessConditions) { return getProperties(accessConditions).map(rb -> new BlobRange(0, rb.value().blobSize())); }
return getProperties(accessConditions).map(rb -> new BlobRange(0, rb.value().blobSize()));
private Mono<BlobRange> getFullBlobRange(BlobAccessConditions accessConditions) { return getProperties(accessConditions).map(rb -> new BlobRange(0, rb.value().blobSize())); }
class BlobAsyncClient { private static final long BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB; final BlobAsyncRawClient blobAsyncRawClient; private final String snapshot; /** * Package-private constructor for use by {@link BlobClientBuilder}. * @param azureBlobStorageBuilder the API client builder for blob stor...
class BlobAsyncClient { private static final int BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB; private static final int BLOB_MAX_DOWNLOAD_BLOCK_SIZE = 100 * Constants.MB; final BlobAsyncRawClient blobAsyncRawClient; /** * Package-private constructor for use by {@link BlobClientBuilder}. * @param azureBlobStorage...
This is called only once for each large file download, how is it doubling the number of IOs? If the files are really small, then yes - but without the full length the client is not able to parallelize the download work. The best way to avoid it is to provide the `BlobRange` parameter and I'll document it here.
private Mono<BlobRange> getFullBlobRange(BlobAccessConditions accessConditions) { return getProperties(accessConditions).map(rb -> new BlobRange(0, rb.value().blobSize())); }
return getProperties(accessConditions).map(rb -> new BlobRange(0, rb.value().blobSize()));
private Mono<BlobRange> getFullBlobRange(BlobAccessConditions accessConditions) { return getProperties(accessConditions).map(rb -> new BlobRange(0, rb.value().blobSize())); }
class BlobAsyncClient { private static final long BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB; final BlobAsyncRawClient blobAsyncRawClient; private final String snapshot; /** * Package-private constructor for use by {@link BlobClientBuilder}. * @param azureBlobStorageBuilder the API client builder for blob stor...
class BlobAsyncClient { private static final int BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB; private static final int BLOB_MAX_DOWNLOAD_BLOCK_SIZE = 100 * Constants.MB; final BlobAsyncRawClient blobAsyncRawClient; /** * Package-private constructor for use by {@link BlobClientBuilder}. * @param azureBlobStorage...
I don't understand what is etag locking so feel free to contribute. What kind of progress reporting are you looking for?
private Mono<BlobRange> getFullBlobRange(BlobAccessConditions accessConditions) { return getProperties(accessConditions).map(rb -> new BlobRange(0, rb.value().blobSize())); }
return getProperties(accessConditions).map(rb -> new BlobRange(0, rb.value().blobSize()));
private Mono<BlobRange> getFullBlobRange(BlobAccessConditions accessConditions) { return getProperties(accessConditions).map(rb -> new BlobRange(0, rb.value().blobSize())); }
class BlobAsyncClient { private static final long BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB; final BlobAsyncRawClient blobAsyncRawClient; private final String snapshot; /** * Package-private constructor for use by {@link BlobClientBuilder}. * @param azureBlobStorageBuilder the API client builder for blob stor...
class BlobAsyncClient { private static final int BLOB_DEFAULT_DOWNLOAD_BLOCK_SIZE = 4 * Constants.MB; private static final int BLOB_MAX_DOWNLOAD_BLOCK_SIZE = 100 * Constants.MB; final BlobAsyncRawClient blobAsyncRawClient; /** * Package-private constructor for use by {@link BlobClientBuilder}. * @param azureBlobStorage...
>MSICredentials() [](start = 49, length = 16) Replaced our custom implementations with this API. Verified it works on vm. #Resolved
public CompletableFuture<SecurityToken> getSecurityTokenAsync(String audience) { CompletableFuture<SecurityToken> tokenGeneratingFuture = new CompletableFuture<>(); MessagingFactory.INTERNAL_THREAD_POOL.execute(() -> { try { MSICredentials credentials = new MSICredentials(); String rawToken = credentials.getToken(Secur...
MSICredentials credentials = new MSICredentials();
public CompletableFuture<SecurityToken> getSecurityTokenAsync(String audience) { CompletableFuture<SecurityToken> tokenGeneratingFuture = new CompletableFuture<>(); MessagingFactory.INTERNAL_THREAD_POOL.execute(() -> { try { MSICredentials credentials = new MSICredentials(); String rawToken = credentials.getToken(Secur...
class ManagedIdentityTokenProvider extends TokenProvider { private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(ManagedIdentityTokenProvider.class); @Override static Date getExpirationDateTimeUtcFromToken(String token) throws ParseException { JWT jwt = JWTParser.parse(token); JWTClaimsSet claims = jwt.get...
class ManagedIdentityTokenProvider extends TokenProvider { private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(ManagedIdentityTokenProvider.class); @Override private static Date getExpirationDateTimeUtcFromToken(String token) throws ParseException { JWT jwt = JWTParser.parse(token); JWTClaimsSet claims =...
These three lines can be made into one line - you're concatenating three string constants.
public Mono<AccessToken> authenticateToManagedIdentityEnpoint(String msiEndpoint, String msiSecret, String clientId, String[] scopes) { String resource = ScopeUtil.scopesToResource(scopes); HttpURLConnection connection = null; try { StringBuilder urlStringBuilder = new StringBuilder(String.format("%s?resource=%s&api-ve...
urlStringBuilder.append("=");
public Mono<AccessToken> authenticateToManagedIdentityEnpoint(String msiEndpoint, String msiSecret, String clientId, String[] scopes) { String resource = ScopeUtil.scopesToResource(scopes); HttpURLConnection connection = null; StringBuilder payload = new StringBuilder(); try { payload.append("resource="); payload.appen...
class IdentityClient { private final IdentityClientOptions options; private final SerializerAdapter adapter = JacksonAdapter.createDefaultSerializerAdapter(); private static final Random RANDOM = new Random(); /** * Creates an IdentityClient with default options. */ public IdentityClient() { this.options = new Identity...
class IdentityClient { private final IdentityClientOptions options; private final SerializerAdapter adapter = JacksonAdapter.createDefaultSerializerAdapter(); private static final Random RANDOM = new Random(); /** * Creates an IdentityClient with default options. */ public IdentityClient() { this.options = new Identity...
It's weird that you're using string.format within a string builder. You should do only one (stringbuilder I would say).
public Mono<AccessToken> authenticateToManagedIdentityEnpoint(String msiEndpoint, String msiSecret, String clientId, String[] scopes) { String resource = ScopeUtil.scopesToResource(scopes); HttpURLConnection connection = null; try { StringBuilder urlStringBuilder = new StringBuilder(String.format("%s?resource=%s&api-ve...
StringBuilder urlStringBuilder = new StringBuilder(String.format("%s?resource=%s&api-version=2017-09-01", msiEndpoint, resource));
public Mono<AccessToken> authenticateToManagedIdentityEnpoint(String msiEndpoint, String msiSecret, String clientId, String[] scopes) { String resource = ScopeUtil.scopesToResource(scopes); HttpURLConnection connection = null; StringBuilder payload = new StringBuilder(); try { payload.append("resource="); payload.appen...
class IdentityClient { private final IdentityClientOptions options; private final SerializerAdapter adapter = JacksonAdapter.createDefaultSerializerAdapter(); private static final Random RANDOM = new Random(); /** * Creates an IdentityClient with default options. */ public IdentityClient() { this.options = new Identity...
class IdentityClient { private final IdentityClientOptions options; private final SerializerAdapter adapter = JacksonAdapter.createDefaultSerializerAdapter(); private static final Random RANDOM = new Random(); /** * Creates an IdentityClient with default options. */ public IdentityClient() { this.options = new Identity...
Same issue here in code that isn't changed - excessive string builder operations that could be made simpler
public Mono<AccessToken> authenticateToIMDSEndpoint(String clientId, String[] scopes) { String resource = ScopeUtil.scopesToResource(scopes); StringBuilder payload = new StringBuilder(); final int imdsUpgradeTimeInMs = 70 * 1000; try { payload.append("api-version"); payload.append("="); payload.append(URLEncoder.encode...
payload.append(URLEncoder.encode(clientId, "UTF-8"));
public Mono<AccessToken> authenticateToIMDSEndpoint(String clientId, String[] scopes) { String resource = ScopeUtil.scopesToResource(scopes); StringBuilder payload = new StringBuilder(); final int imdsUpgradeTimeInMs = 70 * 1000; try { payload.append("api-version="); payload.append(URLEncoder.encode("2018-02-01", "UTF-...
class IdentityClient { private final IdentityClientOptions options; private final SerializerAdapter adapter = JacksonAdapter.createDefaultSerializerAdapter(); private static final Random RANDOM = new Random(); /** * Creates an IdentityClient with default options. */ public IdentityClient() { this.options = new Identity...
class IdentityClient { private final IdentityClientOptions options; private final SerializerAdapter adapter = JacksonAdapter.createDefaultSerializerAdapter(); private static final Random RANDOM = new Random(); /** * Creates an IdentityClient with default options. */ public IdentityClient() { this.options = new Identity...
>String.format("%s?resource=%s&api-version=2017-09-01", msiEndpoint, resource) [](start = 63, length = 77) Not sure if URL handles this but it's most likely that the resource needs to be url encoded as a data string.
public Mono<AccessToken> authenticateToManagedIdentityEnpoint(String msiEndpoint, String msiSecret, String clientId, String[] scopes) { String resource = ScopeUtil.scopesToResource(scopes); HttpURLConnection connection = null; try { StringBuilder urlStringBuilder = new StringBuilder(String.format("%s?resource=%s&api-ve...
StringBuilder urlStringBuilder = new StringBuilder(String.format("%s?resource=%s&api-version=2017-09-01", msiEndpoint, resource));
public Mono<AccessToken> authenticateToManagedIdentityEnpoint(String msiEndpoint, String msiSecret, String clientId, String[] scopes) { String resource = ScopeUtil.scopesToResource(scopes); HttpURLConnection connection = null; StringBuilder payload = new StringBuilder(); try { payload.append("resource="); payload.appen...
class IdentityClient { private final IdentityClientOptions options; private final SerializerAdapter adapter = JacksonAdapter.createDefaultSerializerAdapter(); private static final Random RANDOM = new Random(); /** * Creates an IdentityClient with default options. */ public IdentityClient() { this.options = new Identity...
class IdentityClient { private final IdentityClientOptions options; private final SerializerAdapter adapter = JacksonAdapter.createDefaultSerializerAdapter(); private static final Random RANDOM = new Random(); /** * Creates an IdentityClient with default options. */ public IdentityClient() { this.options = new Identity...
Updated. StringBuilder not needed here anymore
public Mono<AccessToken> authenticateToManagedIdentityEnpoint(String msiEndpoint, String msiSecret, String clientId, String[] scopes) { String resource = ScopeUtil.scopesToResource(scopes); HttpURLConnection connection = null; try { StringBuilder urlStringBuilder = new StringBuilder(String.format("%s?resource=%s&api-ve...
StringBuilder urlStringBuilder = new StringBuilder(String.format("%s?resource=%s&api-version=2017-09-01", msiEndpoint, resource));
public Mono<AccessToken> authenticateToManagedIdentityEnpoint(String msiEndpoint, String msiSecret, String clientId, String[] scopes) { String resource = ScopeUtil.scopesToResource(scopes); HttpURLConnection connection = null; StringBuilder payload = new StringBuilder(); try { payload.append("resource="); payload.appen...
class IdentityClient { private final IdentityClientOptions options; private final SerializerAdapter adapter = JacksonAdapter.createDefaultSerializerAdapter(); private static final Random RANDOM = new Random(); /** * Creates an IdentityClient with default options. */ public IdentityClient() { this.options = new Identity...
class IdentityClient { private final IdentityClientOptions options; private final SerializerAdapter adapter = JacksonAdapter.createDefaultSerializerAdapter(); private static final Random RANDOM = new Random(); /** * Creates an IdentityClient with default options. */ public IdentityClient() { this.options = new Identity...
Your string replace has done too much, hasn't it? This is still a secrets sample?
public static void main(String[] args) throws IllegalArgumentException { SecretClient client = SecretClient.builder() .endpoint("https: .credential(new AzureCredential()) .build(); client.setSecret(new Secret("StorageAccountPassword", "f4G34fMh8v-fdsgjsk2323=-asdsdfsdf") .expires(OffsetDateTime.now().plusYears(1))); cl...
public static void main(String[] args) throws IllegalArgumentException { SecretClient client = SecretClient.builder() .endpoint("https: .credential(new DefaultAzureCredential()) .build(); client.setSecret(new Secret("StorageAccountPassword", "f4G34fMh8v-fdsgjsk2323=-asdsdfsdf") .expires(OffsetDateTime.now().plusYears(1...
class ListOperations { /** * Authenticates with the key vault and shows how to list keys and list versions of a specific secret in the key vault. * * @param args Unused. Arguments to the program. * @throws IllegalArgumentException when invalid key vault endpoint is passed. */ }
class ListOperations { /** * Authenticates with the key vault and shows how to list secrets and list versions of a specific secret in the key vault. * * @param args Unused. Arguments to the program. * @throws IllegalArgumentException when invalid key vault endpoint is passed. */ }
Just use `System.out.printf`, rather than String.format inside a println
public static void main(String[] args) throws InterruptedException { Semaphore semaphore = new Semaphore(1); String connectionString = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};SharedAccessKey={sharedAccessKey};EntityPath={eventHubPath}"; EventHubClient client = new EventHubClientBuilder() .connect...
System.out.println(String.format(
public static void main(String[] args) throws InterruptedException { Semaphore semaphore = new Semaphore(1); String connectionString = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};SharedAccessKey={sharedAccessKey};EntityPath={eventHubPath}"; EventHubClient client = new EventHubClientBuilder() .connect...
class GetEventHubMetadata { /** * Demonstrates how to get metadata from an Event Hub's partitions. * * @param args Unused arguments to the sample. * @throws InterruptedException if the semaphore could not be acquired. */ }
class GetEventHubMetadata { /** * Demonstrates how to get metadata from an Event Hub's partitions. * * @param args Unused arguments to the sample. * @throws InterruptedException if the semaphore could not be acquired. */ }
Do a static import of OperationStatus so you don't need to fully-qualify the `PollResponse.` part.
public void initialise(String otherStatus, T value) { PollResponse<String> inProgressPollResponse = new PollResponse<>(PollResponse.OperationStatus.fromString("CUSTOM_OTHER_STATUS"), "my custom response"); }
= new PollResponse<>(PollResponse.OperationStatus.fromString("CUSTOM_OTHER_STATUS"), "my custom response");
public void initialise(String otherStatus, T value) { PollResponse<String> inProgressPollResponse = new PollResponse<>(OperationStatus.fromString("CUSTOM_OTHER_STATUS"), "my custom response"); }
class PollResponseJavaDocCodeSnippets<T> { /** * * @param otherStatus v * @param value v */ /** * * @param otherStatus v * @param value v * @param retryAfterDuration v */ public void initialise(String otherStatus, T value, Duration retryAfterDuration) { PollResponse<String> inProgressPollResponse = new PollResponse<>(P...
class PollResponseJavaDocCodeSnippets<T> { /** * * @param otherStatus v * @param value v */ /** * * @param otherStatus v * @param value v * @param retryAfterDuration v */ public void initialise(String otherStatus, T value, Duration retryAfterDuration) { PollResponse<String> inProgressPollResponse = new PollResponse<>(O...
Fix up these as well so you don't specify `PollResponse.`
public void initialise(String otherStatus, T value, Duration retryAfterDuration) { PollResponse<String> inProgressPollResponse = new PollResponse<>(PollResponse.OperationStatus.fromString("CUSTOM_OTHER_STATUS"), "my custom response", Duration.ofMillis(5000)); }
= new PollResponse<>(PollResponse.OperationStatus.fromString("CUSTOM_OTHER_STATUS"),
public void initialise(String otherStatus, T value, Duration retryAfterDuration) { PollResponse<String> inProgressPollResponse = new PollResponse<>(OperationStatus.fromString("CUSTOM_OTHER_STATUS"), "my custom response", Duration.ofMillis(5000)); }
class PollResponseJavaDocCodeSnippets<T> { /** * * @param otherStatus v * @param value v */ public void initialise(String otherStatus, T value) { PollResponse<String> inProgressPollResponse = new PollResponse<>(PollResponse.OperationStatus.fromString("CUSTOM_OTHER_STATUS"), "my custom response"); } /** * * @param other...
class PollResponseJavaDocCodeSnippets<T> { /** * * @param otherStatus v * @param value v */ public void initialise(String otherStatus, T value) { PollResponse<String> inProgressPollResponse = new PollResponse<>(OperationStatus.fromString("CUSTOM_OTHER_STATUS"), "my custom response"); } /** * * @param otherStatus v * @p...
We really need to rename max results. It's not intuitive that it limits the items per page of response. Not necessary for this review; I'm tracking that discussion elsewhere.
public static void main(String[] args) throws Exception { /** * From the Azure portal, get your Storage account's name and account key. */ String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your ...
containerClient.listBlobsFlat(new ListBlobsOptions().maxResults(1), null)
public static void main(String[] args) throws Exception { /** * From the Azure portal, get your Storage account's name and account key. */ String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your ...
class BasicExample { private static String getAccountName() { return ConfigurationManager.getConfiguration().get("PRIMARY_STORAGE_ACCOUNT_NAME"); } private static String getAccountKey() { return ConfigurationManager.getConfiguration().get("PRIMARY_STORAGE_ACCOUNT_KEY"); } }
class BasicExample { }
I'm not convinced we need this extra complexity. Could we just call `logger.error("", runtimeException)` without changing level or modifying any of the other code?
public void logAndThrow(RuntimeException runtimeException) { if (runtimeException == null) { return; } int currentLevel = level; if (level == DISABLED_LEVEL) { level = ERROR_LEVEL; } if (canLogAtLevel(level)) { performLogging(runtimeException.getClass().getName(), false, runtimeException); } level = currentLevel; throw...
level = currentLevel;
public void logAndThrow(RuntimeException runtimeException) { if (runtimeException == null) { return; } if (canLogAtLevel(ERROR_LEVEL)) { logger.error(runtimeException.getMessage(), runtimeException); } throw runtimeException; }
class name using the {@link LoggerFactory}
class name using the {@link LoggerFactory}
It is good suggestion to use logger.error directly.
public void logAndThrow(RuntimeException runtimeException) { if (runtimeException == null) { return; } int currentLevel = level; if (level == DISABLED_LEVEL) { level = ERROR_LEVEL; } if (canLogAtLevel(level)) { performLogging(runtimeException.getClass().getName(), false, runtimeException); } level = currentLevel; throw...
level = currentLevel;
public void logAndThrow(RuntimeException runtimeException) { if (runtimeException == null) { return; } if (canLogAtLevel(ERROR_LEVEL)) { logger.error(runtimeException.getMessage(), runtimeException); } throw runtimeException; }
class name using the {@link LoggerFactory}
class name using the {@link LoggerFactory}
Can we use `runtimeException.getMessage()` instead of empty string?
public void logAndThrow(RuntimeException runtimeException) { if (runtimeException == null) { return; } if (canLogAtLevel(level)) { logger.error("", runtimeException); } throw runtimeException; }
logger.error("", runtimeException);
public void logAndThrow(RuntimeException runtimeException) { if (runtimeException == null) { return; } if (canLogAtLevel(ERROR_LEVEL)) { logger.error(runtimeException.getMessage(), runtimeException); } throw runtimeException; }
class name using the {@link LoggerFactory}
class name using the {@link LoggerFactory}
This check won't always work as expected and won't comply with the changes made in PR #4194.
public void logAndThrow(RuntimeException runtimeException) { if (runtimeException == null) { return; } if (canLogAtLevel(level)) { logger.error("", runtimeException); } throw runtimeException; }
if (canLogAtLevel(level)) {
public void logAndThrow(RuntimeException runtimeException) { if (runtimeException == null) { return; } if (canLogAtLevel(ERROR_LEVEL)) { logger.error(runtimeException.getMessage(), runtimeException); } throw runtimeException; }
class name using the {@link LoggerFactory}
class name using the {@link LoggerFactory}
This is needed as the exception will be redacted from logging if the logging level doesn't include debugging/verbose logs.
public void logAndThrow(RuntimeException runtimeException) { if (runtimeException == null) { return; } if (canLogAtLevel(level)) { logger.error("", runtimeException); } throw runtimeException; }
logger.error("", runtimeException);
public void logAndThrow(RuntimeException runtimeException) { if (runtimeException == null) { return; } if (canLogAtLevel(ERROR_LEVEL)) { logger.error(runtimeException.getMessage(), runtimeException); } throw runtimeException; }
class name using the {@link LoggerFactory}
class name using the {@link LoggerFactory}
@hemanttanwar Did you reconcile what this comment means? It would be good to see a follow-up comment to clarify we're on the same page.
public void logAndThrow(RuntimeException runtimeException) { if (runtimeException == null) { return; } if (canLogAtLevel(level)) { logger.error("", runtimeException); } throw runtimeException; }
if (canLogAtLevel(level)) {
public void logAndThrow(RuntimeException runtimeException) { if (runtimeException == null) { return; } if (canLogAtLevel(ERROR_LEVEL)) { logger.error(runtimeException.getMessage(), runtimeException); } throw runtimeException; }
class name using the {@link LoggerFactory}
class name using the {@link LoggerFactory}
Spoke to @alzimmermsft and he is fine with the changes done to handle this case.
public void logAndThrow(RuntimeException runtimeException) { if (runtimeException == null) { return; } if (canLogAtLevel(level)) { logger.error("", runtimeException); } throw runtimeException; }
if (canLogAtLevel(level)) {
public void logAndThrow(RuntimeException runtimeException) { if (runtimeException == null) { return; } if (canLogAtLevel(ERROR_LEVEL)) { logger.error(runtimeException.getMessage(), runtimeException); } throw runtimeException; }
class name using the {@link LoggerFactory}
class name using the {@link LoggerFactory}
Would it make more sense to add an intermediate sample of getting the blob properties and retrieving the blobSize from BlobProperties to set the initial stream size? I would think that would be the more common way to determine this.
public static void main(String[] args) throws Exception { /** * From the Azure portal, get your Storage account's name and account key. */ String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your ...
OutputStream outputStream = new ByteArrayOutputStream(data.length());
public static void main(String[] args) throws Exception { /** * From the Azure portal, get your Storage account's name and account key. */ String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your ...
class BasicExample { private static String getAccountName() { return ConfigurationManager.getConfiguration().get("PRIMARY_STORAGE_ACCOUNT_NAME"); } private static String getAccountKey() { return ConfigurationManager.getConfiguration().get("PRIMARY_STORAGE_ACCOUNT_KEY"); } }
class BasicExample { }
Using maxResults here is a bit misleading, that field will determine the number of results a single page will return. I think this should be removed.
public static void main(String[] args) throws Exception { /** * From the Azure portal, get your Storage account's name and account key. */ String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your ...
containerClient.listBlobsFlat(new ListBlobsOptions().maxResults(1), null)
public static void main(String[] args) throws Exception { /** * From the Azure portal, get your Storage account's name and account key. */ String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your ...
class BasicExample { private static String getAccountName() { return ConfigurationManager.getConfiguration().get("PRIMARY_STORAGE_ACCOUNT_NAME"); } private static String getAccountKey() { return ConfigurationManager.getConfiguration().get("PRIMARY_STORAGE_ACCOUNT_KEY"); } }
class BasicExample { }
Since these are examples we should just use the long primitive instead of the Long object. When our API uses the Long object we should use Long.
public static void main(String[] args) throws Exception { /** * From the Azure portal, get your Storage account's name and account key. */ String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your ...
Long fileSize = 100 * 1024 * 1024L;
public static void main(String[] args) throws Exception { /** * From the Azure portal, get your Storage account's name and account key. */ String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your ...
class FileTransferExample { private static final String LARGE_TEST_FOLDER = "test-large-files/"; private static File createTempEmptyFile(String fileName) throws Exception{ URL folderUrl = FileTransferExample.class.getClassLoader().getResource("."); File dirPath = new File(folderUrl.getPath() + LARGE_TEST_FOLDER); if (d...
class FileTransferExample { private static final String LARGE_TEST_FOLDER = "test-large-files/"; private static File createTempEmptyFile(String fileName) throws Exception{ URL folderUrl = FileTransferExample.class.getClassLoader().getResource("."); File dirPath = new File(folderUrl.getPath() + LARGE_TEST_FOLDER); if (d...
Should we show off StorageClient.deleteContainer here instead of ContainerClient.delete?
public static void main (String[] args) { String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your account. */ SharedKeyCredential credential = new SharedKeyCredential(accountName, accountKey); /*...
);
public static void main (String[] args) { String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your account. */ SharedKeyCredential credential = new SharedKeyCredential(accountName, accountKey); /*...
class ListContainersExample { private static String getAccountName() { return ConfigurationManager.getConfiguration().get("PRIMARY_STORAGE_ACCOUNT_NAME"); } private static String getAccountKey() { return ConfigurationManager.getConfiguration().get("PRIMARY_STORAGE_ACCOUNT_KEY"); } }
class ListContainersExample { }
Especially if we already are at the storage client instead of the container client. We should, however, leave a comment saying that it's a shortcut for the code currently here.
public static void main (String[] args) { String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your account. */ SharedKeyCredential credential = new SharedKeyCredential(accountName, accountKey); /*...
);
public static void main (String[] args) { String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your account. */ SharedKeyCredential credential = new SharedKeyCredential(accountName, accountKey); /*...
class ListContainersExample { private static String getAccountName() { return ConfigurationManager.getConfiguration().get("PRIMARY_STORAGE_ACCOUNT_NAME"); } private static String getAccountKey() { return ConfigurationManager.getConfiguration().get("PRIMARY_STORAGE_ACCOUNT_KEY"); } }
class ListContainersExample { }
I have tried to delete at the storage client level. I did not find the deleteContainer API. Are we supposed to have the API?
public static void main (String[] args) { String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your account. */ SharedKeyCredential credential = new SharedKeyCredential(accountName, accountKey); /*...
);
public static void main (String[] args) { String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your account. */ SharedKeyCredential credential = new SharedKeyCredential(accountName, accountKey); /*...
class ListContainersExample { private static String getAccountName() { return ConfigurationManager.getConfiguration().get("PRIMARY_STORAGE_ACCOUNT_NAME"); } private static String getAccountKey() { return ConfigurationManager.getConfiguration().get("PRIMARY_STORAGE_ACCOUNT_KEY"); } }
class ListContainersExample { }
Huh, it does appear to be missing deleteContainer, open up an issue for that and we'll resolve. @jaschrep-msft and @rickle-msft good with resolving this in preview 2?
public static void main (String[] args) { String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your account. */ SharedKeyCredential credential = new SharedKeyCredential(accountName, accountKey); /*...
);
public static void main (String[] args) { String accountName = getAccountName(); String accountKey = getAccountKey(); /** * Use your Storage account's name and key to create a credential object; this is used to access your account. */ SharedKeyCredential credential = new SharedKeyCredential(accountName, accountKey); /*...
class ListContainersExample { private static String getAccountName() { return ConfigurationManager.getConfiguration().get("PRIMARY_STORAGE_ACCOUNT_NAME"); } private static String getAccountKey() { return ConfigurationManager.getConfiguration().get("PRIMARY_STORAGE_ACCOUNT_KEY"); } }
class ListContainersExample { }
This first check can be rolled into your isValidLibrary method because it appears you're also doing a validity check in this if statement. ```java private String getInvalidTypeNameFromTypeArgument(DetailAST typeArgumentToken) { … if (identToken == null) { return null; } final String typeName = identToken.g...
private String getInvalidTypeNameFromTypeArgument(DetailAST typeArgumentToken) { if (typeArgumentToken == null) { return null; } final DetailAST identToken = typeArgumentToken.findFirstToken(TokenTypes.IDENT); if (identToken != null) { final String typeName = identToken.getText(); if (classPathMap.containsKey(typeName)...
if (classPathMap.containsKey(typeName) && !isValidLibrary(classPathMap.get(typeName))) {
private String getInvalidTypeNameFromTypeArgument(DetailAST typeArgumentToken) { final DetailAST identToken = typeArgumentToken.findFirstToken(TokenTypes.IDENT); if (identToken == null) { return null; } final String typeName = identToken.getText(); return isValidClassDependency(typeName) ? null : typeName; }
class and value is the full package path of class. * * @param token the IMPORT AST node */ private void addImportedClassPath(DetailAST token) { final String importClassPath = FullIdent.createFullIdentBelow(token).getText(); final String className = importClassPath.substring(importClassPath.lastIndexOf(DOT) + 1); classP...
class and value is the full package path of class. final String importClassPath = FullIdent.createFullIdentBelow(token).getText(); final String className = importClassPath.substring(importClassPath.lastIndexOf(".") + 1); simpleClassNameToQualifiedNameMap.put(className, importClassPath); break; case TokenTypes.METHOD_DE...
You're not checking if the "library" is valid, you're checking if it's a valid class dependency. imho, a library is a collection of related classes
private String getInvalidTypeNameFromTypeArgument(DetailAST typeArgumentToken) { if (typeArgumentToken == null) { return null; } final DetailAST identToken = typeArgumentToken.findFirstToken(TokenTypes.IDENT); if (identToken != null) { final String typeName = identToken.getText(); if (classPathMap.containsKey(typeName)...
if (classPathMap.containsKey(typeName) && !isValidLibrary(classPathMap.get(typeName))) {
private String getInvalidTypeNameFromTypeArgument(DetailAST typeArgumentToken) { final DetailAST identToken = typeArgumentToken.findFirstToken(TokenTypes.IDENT); if (identToken == null) { return null; } final String typeName = identToken.getText(); return isValidClassDependency(typeName) ? null : typeName; }
class and value is the full package path of class. * * @param token the IMPORT AST node */ private void addImportedClassPath(DetailAST token) { final String importClassPath = FullIdent.createFullIdentBelow(token).getText(); final String className = importClassPath.substring(importClassPath.lastIndexOf(DOT) + 1); classP...
class and value is the full package path of class. final String importClassPath = FullIdent.createFullIdentBelow(token).getText(); final String className = importClassPath.substring(importClassPath.lastIndexOf(".") + 1); simpleClassNameToQualifiedNameMap.put(className, importClassPath); break; case TokenTypes.METHOD_DE...
I'd like to see some comments throughout your code saying what is being done, to make it easier for readers to determine. e.g. "Getting the modifier of the method to determine if it is public or protected"
private void checkNoExternalDependencyExposed(DetailAST methodDefToken) { final DetailAST modifiersToken = methodDefToken.findFirstToken(TokenTypes.MODIFIERS); if (modifiersToken == null) { return; } AccessModifier accessModifier = CheckUtil.getAccessModifierFromModifiersToken(modifiersToken); if (!accessModifier.equal...
AccessModifier accessModifier = CheckUtil.getAccessModifierFromModifiersToken(modifiersToken);
private void checkNoExternalDependencyExposed(DetailAST methodDefToken) { final DetailAST modifiersToken = methodDefToken.findFirstToken(TokenTypes.MODIFIERS); final AccessModifier accessModifier = CheckUtil.getAccessModifierFromModifiersToken(modifiersToken); if (!accessModifier.equals(AccessModifier.PUBLIC) && !acces...
class and value is the full package path of class. * * @param token the IMPORT AST node */ private void addImportedClassPath(DetailAST token) { final String importClassPath = FullIdent.createFullIdentBelow(token).getText(); final String className = importClassPath.substring(importClassPath.lastIndexOf(DOT) + 1); simple...
class and value is the full package path of class. final String importClassPath = FullIdent.createFullIdentBelow(token).getText(); final String className = importClassPath.substring(importClassPath.lastIndexOf(".") + 1); simpleClassNameToQualifiedNameMap.put(className, importClassPath); break; case TokenTypes.METHOD_DE...
Rather than `@ServiceClient`, are you able to state the class name? Also, small wording suggestion: ```suggestion log(modifiersToken, String.format("The variable field ''%s'' of @ServiceClient should be final. Classes annotated with @ServiceClient are supposed to be immutable.", ```
private void checkClassField(DetailAST objBlockToken) { for (DetailAST ast = objBlockToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { if (TokenTypes.VARIABLE_DEF != ast.getType()) { continue; } final DetailAST modifiersToken = ast.findFirstToken(TokenTypes.MODIFIERS); if (!modifiersToken.branchContains...
log(modifiersToken, String.format("The variable field ''%s'' of @ServiceClient should be final. The class annotated with @ServiceClient supposed to be immutable.",
private void checkClassField(DetailAST objBlockToken) { for (DetailAST ast = objBlockToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { if (TokenTypes.VARIABLE_DEF != ast.getType()) { continue; } final DetailAST modifiersToken = ast.findFirstToken(TokenTypes.MODIFIERS); if (!modifiersToken.branchContains...
class of ServiceClient. * These fields should be final because these classes supposed to be immutable class. * * @param objBlockToken the OBJBLOCK AST node */
class should not have a public static method named ''builder''."); } } /** * Checks that the field variables in the @ServiceClient are final. ServiceClients should be immutable. * * @param objBlockToken the OBJBLOCK AST node */
```suggestion log(classDefToken, String.format("Async class ''%s'' must be named <ServiceName>AsyncClient ", className)); ```
private void checkServiceClientNaming(DetailAST classDefToken) { if (!hasServiceClientAnnotation) { return; } final String className = classDefToken.findFirstToken(TokenTypes.IDENT).getText(); if (isAsync && !className.endsWith(ASYNC_CLIENT)) { log(classDefToken, String.format("Async class ''%s'' should named <ServiceN...
log(classDefToken, String.format("Async class ''%s'' should named <ServiceName>AsyncClient ", className));
private void checkServiceClientNaming(DetailAST classDefToken) { final String className = classDefToken.findFirstToken(TokenTypes.IDENT).getText(); if (isAsync && !className.endsWith(ASYNC_CLIENT)) { log(classDefToken, String.format("Async class ''%s'' must be named <ServiceName>AsyncClient ", className)); } if (!isAsy...
class name of Service Client. It should be named <ServiceName>AsyncClient or <ServiceName>Client. * * @param classDefToken the CLASS_DEF AST node */
class name of Service Client. It should be named <ServiceName>AsyncClient or <ServiceName>Client. * * @param classDefToken the CLASS_DEF AST node */
```suggestion log(classDefToken, String.format("Sync class %s should named <ServiceName>Client.", className)); ``` ```suggestion log(classDefToken, String.format("Sync class %s must be named <ServiceName>Client.", className)); ```
private void checkServiceClientNaming(DetailAST classDefToken) { if (!hasServiceClientAnnotation) { return; } final String className = classDefToken.findFirstToken(TokenTypes.IDENT).getText(); if (isAsync && !className.endsWith(ASYNC_CLIENT)) { log(classDefToken, String.format("Async class ''%s'' should named <ServiceN...
log(classDefToken, String.format("Sync class %s should named <ServiceName>Client.", className));
private void checkServiceClientNaming(DetailAST classDefToken) { final String className = classDefToken.findFirstToken(TokenTypes.IDENT).getText(); if (isAsync && !className.endsWith(ASYNC_CLIENT)) { log(classDefToken, String.format("Async class ''%s'' must be named <ServiceName>AsyncClient ", className)); } if (!isAsy...
class name of Service Client. It should be named <ServiceName>AsyncClient or <ServiceName>Client. * * @param classDefToken the CLASS_DEF AST node */
class name of Service Client. It should be named <ServiceName>AsyncClient or <ServiceName>Client. * * @param classDefToken the CLASS_DEF AST node */
I would add pre-emptive checks on these constructor and method_def checks that: ```java if (hasServiceClientAnnotation) { // then do the check. Otherwise, you're doing the check on classes that aren't serviceclients. } ```
public void visitToken(DetailAST token) { if (!hasServiceClientAnnotation) { return; } switch (token.getType()) { case TokenTypes.CLASS_DEF: hasServiceClientAnnotation = hasServiceClientAnnotation(token); checkServiceClientNaming(token); break; case TokenTypes.CTOR_DEF: checkConstructor(token); break; case TokenTypes.M...
checkConstructor(token);
public void visitToken(DetailAST token) { if (isImplPackage) { return; } switch (token.getType()) { case TokenTypes.PACKAGE_DEF: String packageName = FullIdent.createFullIdent(token.findFirstToken(TokenTypes.DOT)).getText(); isImplPackage = packageName.contains(".implementation"); break; case TokenTypes.CLASS_DEF: hasS...
class ServiceClientInstantiationCheck extends AbstractCheck { private static final String SERVICE_CLIENT = "ServiceClient"; private static final String BUILDER = "builder"; private static final String ASYNC_CLIENT ="AsyncClient"; private static final String CLIENT = "Client"; private static final String IS_ASYNC = "isA...
class ServiceClientInstantiationCheck extends AbstractCheck { private static final String SERVICE_CLIENT = "ServiceClient"; private static final String BUILDER = "builder"; private static final String ASYNC_CLIENT ="AsyncClient"; private static final String CLIENT = "Client"; private static final String IS_ASYNC = "isA...
The condition is already checked in at beginning of visitToken()
public void visitToken(DetailAST token) { if (!hasServiceClientAnnotation) { return; } switch (token.getType()) { case TokenTypes.CLASS_DEF: hasServiceClientAnnotation = hasServiceClientAnnotation(token); checkServiceClientNaming(token); break; case TokenTypes.CTOR_DEF: checkConstructor(token); break; case TokenTypes.M...
checkConstructor(token);
public void visitToken(DetailAST token) { if (isImplPackage) { return; } switch (token.getType()) { case TokenTypes.PACKAGE_DEF: String packageName = FullIdent.createFullIdent(token.findFirstToken(TokenTypes.DOT)).getText(); isImplPackage = packageName.contains(".implementation"); break; case TokenTypes.CLASS_DEF: hasS...
class ServiceClientInstantiationCheck extends AbstractCheck { private static final String SERVICE_CLIENT = "ServiceClient"; private static final String BUILDER = "builder"; private static final String ASYNC_CLIENT ="AsyncClient"; private static final String CLIENT = "Client"; private static final String IS_ASYNC = "isA...
class ServiceClientInstantiationCheck extends AbstractCheck { private static final String SERVICE_CLIENT = "ServiceClient"; private static final String BUILDER = "builder"; private static final String ASYNC_CLIENT ="AsyncClient"; private static final String CLIENT = "Client"; private static final String IS_ASYNC = "isA...
Seems odd you would pre-emptively set the field to "true" when beginning a walk because you don't really know if that file has a ServiceClient annotation, yet.
public void visitToken(DetailAST token) { if (!hasServiceClientAnnotation) { return; } switch (token.getType()) { case TokenTypes.CLASS_DEF: hasServiceClientAnnotation = hasServiceClientAnnotation(token); checkServiceClientNaming(token); break; case TokenTypes.CTOR_DEF: checkConstructor(token); break; case TokenTypes.M...
checkConstructor(token);
public void visitToken(DetailAST token) { if (isImplPackage) { return; } switch (token.getType()) { case TokenTypes.PACKAGE_DEF: String packageName = FullIdent.createFullIdent(token.findFirstToken(TokenTypes.DOT)).getText(); isImplPackage = packageName.contains(".implementation"); break; case TokenTypes.CLASS_DEF: hasS...
class ServiceClientInstantiationCheck extends AbstractCheck { private static final String SERVICE_CLIENT = "ServiceClient"; private static final String BUILDER = "builder"; private static final String ASYNC_CLIENT ="AsyncClient"; private static final String CLIENT = "Client"; private static final String IS_ASYNC = "isA...
class ServiceClientInstantiationCheck extends AbstractCheck { private static final String SERVICE_CLIENT = "ServiceClient"; private static final String BUILDER = "builder"; private static final String ASYNC_CLIENT ="AsyncClient"; private static final String CLIENT = "Client"; private static final String IS_ASYNC = "isA...
Setting 'true' value to be able to walk the tree, The DFS tree traversal will first visit CLASS_DEF. If the class is annotated with @ServiceClient, the hasServiceClientAnnotation() method will return true, otherwise, it will return false.
public void visitToken(DetailAST token) { if (!hasServiceClientAnnotation) { return; } switch (token.getType()) { case TokenTypes.CLASS_DEF: hasServiceClientAnnotation = hasServiceClientAnnotation(token); checkServiceClientNaming(token); break; case TokenTypes.CTOR_DEF: checkConstructor(token); break; case TokenTypes.M...
checkConstructor(token);
public void visitToken(DetailAST token) { if (isImplPackage) { return; } switch (token.getType()) { case TokenTypes.PACKAGE_DEF: String packageName = FullIdent.createFullIdent(token.findFirstToken(TokenTypes.DOT)).getText(); isImplPackage = packageName.contains(".implementation"); break; case TokenTypes.CLASS_DEF: hasS...
class ServiceClientInstantiationCheck extends AbstractCheck { private static final String SERVICE_CLIENT = "ServiceClient"; private static final String BUILDER = "builder"; private static final String ASYNC_CLIENT ="AsyncClient"; private static final String CLIENT = "Client"; private static final String IS_ASYNC = "isA...
class ServiceClientInstantiationCheck extends AbstractCheck { private static final String SERVICE_CLIENT = "ServiceClient"; private static final String BUILDER = "builder"; private static final String ASYNC_CLIENT ="AsyncClient"; private static final String CLIENT = "Client"; private static final String IS_ASYNC = "isA...
I have made a wrong assumption. I thought one tree traversal will only have one CLASS_DEF. But it could have a nest inner class.
public void visitToken(DetailAST token) { if (!hasServiceClientAnnotation) { return; } switch (token.getType()) { case TokenTypes.CLASS_DEF: hasServiceClientAnnotation = hasServiceClientAnnotation(token); checkServiceClientNaming(token); break; case TokenTypes.CTOR_DEF: checkConstructor(token); break; case TokenTypes.M...
checkConstructor(token);
public void visitToken(DetailAST token) { if (isImplPackage) { return; } switch (token.getType()) { case TokenTypes.PACKAGE_DEF: String packageName = FullIdent.createFullIdent(token.findFirstToken(TokenTypes.DOT)).getText(); isImplPackage = packageName.contains(".implementation"); break; case TokenTypes.CLASS_DEF: hasS...
class ServiceClientInstantiationCheck extends AbstractCheck { private static final String SERVICE_CLIENT = "ServiceClient"; private static final String BUILDER = "builder"; private static final String ASYNC_CLIENT ="AsyncClient"; private static final String CLIENT = "Client"; private static final String IS_ASYNC = "isA...
class ServiceClientInstantiationCheck extends AbstractCheck { private static final String SERVICE_CLIENT = "ServiceClient"; private static final String BUILDER = "builder"; private static final String ASYNC_CLIENT ="AsyncClient"; private static final String CLIENT = "Client"; private static final String IS_ASYNC = "isA...
You can merge these two `if` conditions into one
private void checkServiceInterface(DetailAST interfaceDefToken) { DetailAST serviceInterfaceAnnotationNode = null; String nameValue = null; DetailAST modifiersToken = interfaceDefToken.findFirstToken(TokenTypes.MODIFIERS); for (DetailAST ast = modifiersToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { i...
if ("name".equals(annotationChild.findFirstToken(TokenTypes.IDENT).getText())) {
private void checkServiceInterface(DetailAST interfaceDefToken) { DetailAST serviceInterfaceAnnotationNode = null; String nameValue = null; DetailAST modifiersToken = interfaceDefToken.findFirstToken(TokenTypes.MODIFIERS); for (DetailAST ast = modifiersToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { i...
class should have the following rules: * 1) The annotation property 'name' should be non-empty * 2) The length of value of property 'name' should be less than 10 characters and without space * * @param interfaceDefToken INTERFACE_DEF AST node */
class should have the following rules: * 1) The annotation property 'name' should be non-empty * 2) The length of value of property 'name' should be less than 20 characters and without space * * @param interfaceDefToken INTERFACE_DEF AST node */
You can `break` after you have found the `nameValue`
private void checkServiceInterface(DetailAST interfaceDefToken) { DetailAST serviceInterfaceAnnotationNode = null; String nameValue = null; DetailAST modifiersToken = interfaceDefToken.findFirstToken(TokenTypes.MODIFIERS); for (DetailAST ast = modifiersToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { i...
nameValue = getNamePropertyValue(annotationChild.findFirstToken(TokenTypes.EXPR));
private void checkServiceInterface(DetailAST interfaceDefToken) { DetailAST serviceInterfaceAnnotationNode = null; String nameValue = null; DetailAST modifiersToken = interfaceDefToken.findFirstToken(TokenTypes.MODIFIERS); for (DetailAST ast = modifiersToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { i...
class should have the following rules: * 1) The annotation property 'name' should be non-empty * 2) The length of value of property 'name' should be less than 10 characters and without space * * @param interfaceDefToken INTERFACE_DEF AST node */
class should have the following rules: * 1) The annotation property 'name' should be non-empty * 2) The length of value of property 'name' should be less than 20 characters and without space * * @param interfaceDefToken INTERFACE_DEF AST node */
I think you can use a simple regex to check all these 3 rules at once. ``` Pattern serviceNamePattern = Pattern.compile("^[a-zA-Z0-9]{1,10}$"); if (!serviceNamePattern.matcher(nameValue).find()) { log(serviceInterfaceAnnotationNode, String.format( "The ''name'' property of @ServiceInterface, ''%s'' should be non-em...
private void checkServiceInterface(DetailAST interfaceDefToken) { DetailAST serviceInterfaceAnnotationNode = null; String nameValue = null; DetailAST modifiersToken = interfaceDefToken.findFirstToken(TokenTypes.MODIFIERS); for (DetailAST ast = modifiersToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { i...
if (nameValue.isEmpty()) {
private void checkServiceInterface(DetailAST interfaceDefToken) { DetailAST serviceInterfaceAnnotationNode = null; String nameValue = null; DetailAST modifiersToken = interfaceDefToken.findFirstToken(TokenTypes.MODIFIERS); for (DetailAST ast = modifiersToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { i...
class should have the following rules: * 1) The annotation property 'name' should be non-empty * 2) The length of value of property 'name' should be less than 10 characters and without space * * @param interfaceDefToken INTERFACE_DEF AST node */
class should have the following rules: * 1) The annotation property 'name' should be non-empty * 2) The length of value of property 'name' should be less than 20 characters and without space * * @param interfaceDefToken INTERFACE_DEF AST node */
Consider extracting some parts of this for loop into smaller methods for better readability.
private void checkServiceInterface(DetailAST interfaceDefToken) { DetailAST serviceInterfaceAnnotationNode = null; String nameValue = null; DetailAST modifiersToken = interfaceDefToken.findFirstToken(TokenTypes.MODIFIERS); for (DetailAST ast = modifiersToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { i...
for (DetailAST ast = modifiersToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) {
private void checkServiceInterface(DetailAST interfaceDefToken) { DetailAST serviceInterfaceAnnotationNode = null; String nameValue = null; DetailAST modifiersToken = interfaceDefToken.findFirstToken(TokenTypes.MODIFIERS); for (DetailAST ast = modifiersToken.getFirstChild(); ast != null; ast = ast.getNextSibling()) { i...
class should have the following rules: * 1) The annotation property 'name' should be non-empty * 2) The length of value of property 'name' should be less than 10 characters and without space * * @param interfaceDefToken INTERFACE_DEF AST node */
class should have the following rules: * 1) The annotation property 'name' should be non-empty * 2) The length of value of property 'name' should be less than 20 characters and without space * * @param interfaceDefToken INTERFACE_DEF AST node */
There should also be a check to ensure there is at least one method that starts with "build".
public void visitToken(DetailAST token) { switch (token.getType()) { case TokenTypes.CLASS_DEF: hasServiceClientBuilderAnnotationStack.push(hasServiceClientBuilderAnnotation); final DetailAST serviceClientAnnotationBuilderToken = getServiceClientBuilderAnnotation(token); final String className = token.findFirstToken(To...
if (methodName.startsWith("build") && !BUILD_ASYNC_CLIENT.equals(methodName) && !BUILD_CLIENT.equals(methodName)) {
public void visitToken(DetailAST token) { switch (token.getType()) { case TokenTypes.CLASS_DEF: hasServiceClientBuilderAnnotationStack.push(hasServiceClientBuilderAnnotation); hasBuildMethodStack.push(hasBuildMethod); final DetailAST serviceClientAnnotationBuilderToken = getServiceClientBuilderAnnotation(token); final ...
class ServiceClientBuilderCheck extends AbstractCheck { private static final String SERVICE_CLIENT_BUILDER = "ServiceClientBuilder"; private static final String BUILD_CLIENT = "buildClient"; private static final String BUILD_ASYNC_CLIENT = "buildAsyncClient"; private Stack<Boolean> hasServiceClientBuilderAnnotationStac...
class ServiceClientBuilderCheck extends AbstractCheck { private static final String SERVICE_CLIENT_BUILDER = "ServiceClientBuilder"; private Stack<Boolean> hasServiceClientBuilderAnnotationStack = new Stack(); private Stack<Boolean> hasBuildMethodStack = new Stack<>(); private boolean hasServiceClientBuilderAnnotation;...
Same here. Only one `case` here - replace `switch` with `if`.
public void leaveToken(DetailAST token) { switch (token.getType()) { case TokenTypes.CLASS_DEF: hasServiceClientBuilderAnnotation = hasServiceClientBuilderAnnotationStack.pop(); break; default: break; } }
case TokenTypes.CLASS_DEF:
public void leaveToken(DetailAST token) { if (token.getType() == TokenTypes.CLASS_DEF) { hasServiceClientBuilderAnnotation = hasServiceClientBuilderAnnotationStack.pop(); hasBuildMethod = hasBuildMethodStack.pop(); if (hasServiceClientBuilderAnnotation && !hasBuildMethod) { log(token, "Class with @ServiceClientBuilder ...
class ServiceClientBuilderCheck extends AbstractCheck { private static final String SERVICE_CLIENT_BUILDER = "ServiceClientBuilder"; private static final String BUILD_CLIENT = "buildClient"; private static final String BUILD_ASYNC_CLIENT = "buildAsyncClient"; private Stack<Boolean> hasServiceClientBuilderAnnotationStac...
class ServiceClientBuilderCheck extends AbstractCheck { private static final String SERVICE_CLIENT_BUILDER = "ServiceClientBuilder"; private Stack<Boolean> hasServiceClientBuilderAnnotationStack = new Stack(); private Stack<Boolean> hasBuildMethodStack = new Stack<>(); private boolean hasServiceClientBuilderAnnotation;...
Should look into having a ConnectionStringParser class in Azure Core, I've been seeing this functionality in a lot of places.
private void getEndPointFromConnectionString(String connectionString) { HashMap<String, String> connectionStringPieces = new HashMap<>(); for (String connectionStringPiece : connectionString.split(";")) { String[] kvp = connectionStringPiece.split("=", 2); connectionStringPieces.put(kvp[0].toLowerCase(Locale.ROOT), kvp...
for (String connectionStringPiece : connectionString.split(";")) {
private void getEndPointFromConnectionString(String connectionString) { HashMap<String, String> connectionStringPieces = new HashMap<>(); for (String connectionStringPiece : connectionString.split(";")) { String[] kvp = connectionStringPiece.split("=", 2); connectionStringPieces.put(kvp[0].toLowerCase(Locale.ROOT), kvp...
class QueueClientBuilder { private static final String ACCOUNT_NAME = "accountname"; private final List<HttpPipelinePolicy> policies; private URL endpoint; private String queueName; private SASTokenCredential sasTokenCredential; private SharedKeyCredential sharedKeyCredential; private HttpClient httpClient; private Htt...
class QueueClientBuilder { private static final ClientLogger LOGGER = new ClientLogger(QueueClientBuilder.class); private static final String ACCOUNT_NAME = "accountname"; private final List<HttpPipelinePolicy> policies; private URL endpoint; private String queueName; private SASTokenCredential sasTokenCredential; priv...
Blobs has a postResponseProcess helper method to convert the StorageErrorException into a StorageException, we should standardize this across the Storage libraries.
public Mono<Response<QueueAsyncClient>> createQueue(String queueName, Map<String, String> metadata) { QueueAsyncClient queueAsyncClient = new QueueAsyncClient(client, queueName); return queueAsyncClient.create(metadata) .map(response -> new SimpleResponse<>(response, queueAsyncClient)); }
.map(response -> new SimpleResponse<>(response, queueAsyncClient));
new QueueAsyncClient(client, queueName); } /** * Creates a queue in the storage account with the specified name and returns a QueueAsyncClient to interact * with it. * * <p><strong>Code Samples</strong></p> * * <p>Create the queue "test"</p> * * {@codesnippet com.azure.storage.queue.queueServiceAsyncClient.createQueue
class QueueServiceAsyncClient { private final AzureQueueStorageImpl client; /** * Creates a QueueServiceAsyncClient that sends requests to the storage account at {@code endpoint}. * Each service call goes through the {@code httpPipeline}. * * @param endpoint URL for the Storage Queue service * @param httpPipeline HttpP...
class QueueServiceAsyncClient { private static final ClientLogger LOGGER = new ClientLogger(QueueServiceAsyncClient.class); private final AzureQueueStorageImpl client; /** * Creates a QueueServiceAsyncClient that sends requests to the storage account at {@code endpoint}. * Each service call goes through the {@code http...
This doesn't seem to be the correct way to chain Reactor requests, I think `then()` should be used
public static void main(String[] args) { String queueURL = String.format("https: QueueAsyncClient queueAsyncClient = new QueueClientBuilder().endpoint(queueURL).buildAsyncClient(); queueAsyncClient.create() .flatMap(response -> queueAsyncClient.enqueueMessage("This is message 1")) .flatMap(response -> queueAsyncClient....
.flatMap(response -> queueAsyncClient.enqueueMessage("This is message 1"))
public static void main(String[] args) { String queueURL = String.format("https: QueueAsyncClient queueAsyncClient = new QueueClientBuilder().endpoint(queueURL).buildAsyncClient(); queueAsyncClient.create() .doOnSuccess(response -> queueAsyncClient.enqueueMessage("This is message 1")) .then(queueAsyncClient.enqueueMess...
class AsyncSamples { private static final String ACCOUNT_NAME = System.getenv("AZURE_STORAGE_ACCOUNT_NAME"); private static final String SAS_TOKEN = System.getenv("PRIMARY_SAS_TOKEN"); private static final String QUEUE_NAME = generateRandomName("async-call", 16); /** * The main method shows how we do the basic operatio...
class AsyncSamples { private static final String ACCOUNT_NAME = System.getenv("AZURE_STORAGE_ACCOUNT_NAME"); private static final String SAS_TOKEN = System.getenv("PRIMARY_SAS_TOKEN"); private static final String QUEUE_NAME = generateRandomName("async-call", 16); /** * The main method shows how we do the basic operatio...
Make sense. Did not turn Mono to Flux and next operation did not depend on the response from the async request.
public static void main(String[] args) { String queueURL = String.format("https: QueueAsyncClient queueAsyncClient = new QueueClientBuilder().endpoint(queueURL).buildAsyncClient(); queueAsyncClient.create() .flatMap(response -> queueAsyncClient.enqueueMessage("This is message 1")) .flatMap(response -> queueAsyncClient....
.flatMap(response -> queueAsyncClient.enqueueMessage("This is message 1"))
public static void main(String[] args) { String queueURL = String.format("https: QueueAsyncClient queueAsyncClient = new QueueClientBuilder().endpoint(queueURL).buildAsyncClient(); queueAsyncClient.create() .doOnSuccess(response -> queueAsyncClient.enqueueMessage("This is message 1")) .then(queueAsyncClient.enqueueMess...
class AsyncSamples { private static final String ACCOUNT_NAME = System.getenv("AZURE_STORAGE_ACCOUNT_NAME"); private static final String SAS_TOKEN = System.getenv("PRIMARY_SAS_TOKEN"); private static final String QUEUE_NAME = generateRandomName("async-call", 16); /** * The main method shows how we do the basic operatio...
class AsyncSamples { private static final String ACCOUNT_NAME = System.getenv("AZURE_STORAGE_ACCOUNT_NAME"); private static final String SAS_TOKEN = System.getenv("PRIMARY_SAS_TOKEN"); private static final String QUEUE_NAME = generateRandomName("async-call", 16); /** * The main method shows how we do the basic operatio...
Will change the first one to doOnSuccess, and second one change to then.
public static void main(String[] args) { String queueURL = String.format("https: QueueAsyncClient queueAsyncClient = new QueueClientBuilder().endpoint(queueURL).buildAsyncClient(); queueAsyncClient.create() .flatMap(response -> queueAsyncClient.enqueueMessage("This is message 1")) .flatMap(response -> queueAsyncClient....
.flatMap(response -> queueAsyncClient.enqueueMessage("This is message 1"))
public static void main(String[] args) { String queueURL = String.format("https: QueueAsyncClient queueAsyncClient = new QueueClientBuilder().endpoint(queueURL).buildAsyncClient(); queueAsyncClient.create() .doOnSuccess(response -> queueAsyncClient.enqueueMessage("This is message 1")) .then(queueAsyncClient.enqueueMess...
class AsyncSamples { private static final String ACCOUNT_NAME = System.getenv("AZURE_STORAGE_ACCOUNT_NAME"); private static final String SAS_TOKEN = System.getenv("PRIMARY_SAS_TOKEN"); private static final String QUEUE_NAME = generateRandomName("async-call", 16); /** * The main method shows how we do the basic operatio...
class AsyncSamples { private static final String ACCOUNT_NAME = System.getenv("AZURE_STORAGE_ACCOUNT_NAME"); private static final String SAS_TOKEN = System.getenv("PRIMARY_SAS_TOKEN"); private static final String QUEUE_NAME = generateRandomName("async-call", 16); /** * The main method shows how we do the basic operatio...
Good call out. I can add a feature issue in epic. I's wish we push the basic one to feature branch first. Then address these things.
public Mono<Response<QueueAsyncClient>> createQueue(String queueName, Map<String, String> metadata) { QueueAsyncClient queueAsyncClient = new QueueAsyncClient(client, queueName); return queueAsyncClient.create(metadata) .map(response -> new SimpleResponse<>(response, queueAsyncClient)); }
.map(response -> new SimpleResponse<>(response, queueAsyncClient));
new QueueAsyncClient(client, queueName); } /** * Creates a queue in the storage account with the specified name and returns a QueueAsyncClient to interact * with it. * * <p><strong>Code Samples</strong></p> * * <p>Create the queue "test"</p> * * {@codesnippet com.azure.storage.queue.queueServiceAsyncClient.createQueue
class QueueServiceAsyncClient { private final AzureQueueStorageImpl client; /** * Creates a QueueServiceAsyncClient that sends requests to the storage account at {@code endpoint}. * Each service call goes through the {@code httpPipeline}. * * @param endpoint URL for the Storage Queue service * @param httpPipeline HttpP...
class QueueServiceAsyncClient { private static final ClientLogger LOGGER = new ClientLogger(QueueServiceAsyncClient.class); private final AzureQueueStorageImpl client; /** * Creates a QueueServiceAsyncClient that sends requests to the storage account at {@code endpoint}. * Each service call goes through the {@code http...
ClientLogger.logAndThrow all exceptions. Please search for all cases because soon Shawn will check in his CheckStyle rule and it will break the build.
public URL getQueueUrl() { try { return new URL(client.url()); } catch (MalformedURLException ex) { throw new RuntimeException("Queue URL is malformed"); } }
throw new RuntimeException("Queue URL is malformed");
public URL getQueueUrl() { try { return new URL(client.url()); } catch (MalformedURLException ex) { LOGGER.asError().log("Queue URL is malformed"); throw new RuntimeException("Queue URL is malformed"); } }
class QueueAsyncClient { private final AzureQueueStorageImpl client; private final String queueName; /** * Creates a QueueAsyncClient that sends requests to the storage queue service at {@link AzureQueueStorageImpl * Each service call goes through the {@link HttpPipeline pipeline} in the {@code client}. * * @param clie...
class QueueAsyncClient { private static 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 {@code AzureQueueStorageImpl * Each service call ...
Do you mean I added a log message before throw statement. Done.
public URL getQueueUrl() { try { return new URL(client.url()); } catch (MalformedURLException ex) { throw new RuntimeException("Queue URL is malformed"); } }
throw new RuntimeException("Queue URL is malformed");
public URL getQueueUrl() { try { return new URL(client.url()); } catch (MalformedURLException ex) { LOGGER.asError().log("Queue URL is malformed"); throw new RuntimeException("Queue URL is malformed"); } }
class QueueAsyncClient { private final AzureQueueStorageImpl client; private final String queueName; /** * Creates a QueueAsyncClient that sends requests to the storage queue service at {@link AzureQueueStorageImpl * Each service call goes through the {@link HttpPipeline pipeline} in the {@code client}. * * @param clie...
class QueueAsyncClient { private static 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 {@code AzureQueueStorageImpl * Each service call ...
No. Just call `Logger.logAndThrow(new RuntimeException("....")` and then `return null` afterwards.
public URL getQueueUrl() { try { return new URL(client.url()); } catch (MalformedURLException ex) { throw new RuntimeException("Queue URL is malformed"); } }
throw new RuntimeException("Queue URL is malformed");
public URL getQueueUrl() { try { return new URL(client.url()); } catch (MalformedURLException ex) { LOGGER.asError().log("Queue URL is malformed"); throw new RuntimeException("Queue URL is malformed"); } }
class QueueAsyncClient { private final AzureQueueStorageImpl client; private final String queueName; /** * Creates a QueueAsyncClient that sends requests to the storage queue service at {@link AzureQueueStorageImpl * Each service call goes through the {@link HttpPipeline pipeline} in the {@code client}. * * @param clie...
class QueueAsyncClient { private static 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 {@code AzureQueueStorageImpl * Each service call ...
There's a CheckUtil method you used in the same file that gives you the modifier. `final AccessModifier accessModifier = CheckUtil.getAccessModifierFromModifiersToken(modifiersToken);`
public void visitToken(DetailAST token) { switch (token.getType()) { case TokenTypes.IMPORT: final String importClassPath = FullIdent.createFullIdentBelow(token).getText(); final String className = importClassPath.substring(importClassPath.lastIndexOf(".") + 1); simpleClassNameToQualifiedNameMap.put(className, importCl...
final DetailAST modifiersToken = token.findFirstToken(TokenTypes.MODIFIERS);
public void visitToken(DetailAST token) { switch (token.getType()) { case TokenTypes.IMPORT: final String importClassPath = FullIdent.createFullIdentBelow(token).getText(); final String className = importClassPath.substring(importClassPath.lastIndexOf(".") + 1); simpleClassNameToQualifiedNameMap.put(className, importCl...
class from external dependency. You should not use it as a return or method argument type."; private static final Set<String> VALID_DEPENDENCY_SET = Collections.unmodifiableSet(new HashSet<>(Arrays.asList( "java", "com.azure", "reactor", "io.netty.buffer.ByteBuf" ))); private final Map<String, String> simpleClassNameTo...
class from external dependency. You should not use it as a return or method argument type."; private static final Set<String> VALID_DEPENDENCY_SET = Collections.unmodifiableSet(new HashSet<>(Arrays.asList( "java", "com.azure", "reactor", "io.netty.buffer.ByteBuf" ))); private final Map<String, String> simpleClassNameTo...
nit: is this still relevant? It's feeling more and more like we're not going to take on auto-splitting for GA.
private Mono<Void> sendInternal(Flux<EventData> events, SendOptions options) { final String partitionKey = options.partitionKey(); verifyPartitionKey(partitionKey); return sendLinkMono.flatMap(link -> { return link.getLinkSize() .flatMap(size -> { final int batchSize = size > 0 ? size : MAX_MESSAGE_LENGTH_BYTES; final ...
private Mono<Void> sendInternal(Flux<EventData> events, SendOptions options) { final String partitionKey = options.partitionKey(); verifyPartitionKey(partitionKey); return sendLinkMono.flatMap(link -> { return link.getLinkSize() .flatMap(size -> { final int batchSize = size > 0 ? size : MAX_MESSAGE_LENGTH_BYTES; final ...
class EventHubProducer implements Closeable { private static final int MAX_PARTITION_KEY_LENGTH = 128; /** * The default maximum allowable size, in bytes, for a batch to be sent. */ public static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024; private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions(); ...
class EventHubProducer implements Closeable { private static final int MAX_PARTITION_KEY_LENGTH = 128; /** * The default maximum allowable size, in bytes, for a batch to be sent. */ public static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024; private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOptions(); ...
Just a formatting thing: I think it would be more readable to have both lambda statements on new lines.
public PagedFlux<KeyBase> listKeys() { return new PagedFlux<>(() -> listKeysFirstPage(), continuationToken -> listKeysNextPage(continuationToken)); }
continuationToken -> listKeysNextPage(continuationToken));
public PagedFlux<KeyBase> listKeys() { return new PagedFlux<>(() -> listKeysFirstPage(), continuationToken -> listKeysNextPage(continuationToken)); }
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...