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 |
|---|---|---|---|---|---|
What will 'throw' achieve here ? | public Mono<AccessToken> getToken(TokenRequestContext request) {
StringBuilder message = new StringBuilder();
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException")) {
throw logger.logExcept... | throw logger.logExceptionAsError(new CredentialUnavailableException( | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException"))... | class ChainedTokenCredential implements TokenCredential {
private final ClientLogger logger = new ClientLogger(ChainedTokenCredential.class);
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an insta... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... |
This logic is not correct, we only want to catch CredentialUnavailableException here. | public Mono<AccessToken> getToken(TokenRequestContext request) {
StringBuilder message = new StringBuilder();
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException")) {
throw logger.logExcept... | .flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> { | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException"))... | class ChainedTokenCredential implements TokenCredential {
private final ClientLogger logger = new ClientLogger(ChainedTokenCredential.class);
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an insta... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... |
We seem to be double logging the exception here. | public Mono<AccessToken> getToken(TokenRequestContext request) {
StringBuilder message = new StringBuilder();
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException")) {
throw logger.logExcept... | throw logger.logExceptionAsError(new CredentialUnavailableException( | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException"))... | class ChainedTokenCredential implements TokenCredential {
private final ClientLogger logger = new ClientLogger(ChainedTokenCredential.class);
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an insta... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... |
A single large message will be unfriendly to read. Are we doing this across all languages ? Better to keep the individual exceptions and their stack trace separate | public Mono<AccessToken> getToken(TokenRequestContext request) {
StringBuilder message = new StringBuilder();
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException")) {
throw logger.logExcept... | message.append(t.getMessage()).append(" "); | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException"))... | class ChainedTokenCredential implements TokenCredential {
private final ClientLogger logger = new ClientLogger(ChainedTokenCredential.class);
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an insta... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... |
In this pr, I change java error message to java(new), and other languages' error message is now as follow, Do java need change it to java(new)? If you think java need change and the java(new) error message is not good enough, please change it in the under table , and I will implement. Scenario | Python/C# | Java(Cur... | public Mono<AccessToken> getToken(TokenRequestContext request) {
StringBuilder message = new StringBuilder();
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException")) {
throw logger.logExcept... | message.append(t.getMessage()).append(" "); | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException"))... | class ChainedTokenCredential implements TokenCredential {
private final ClientLogger logger = new ClientLogger(ChainedTokenCredential.class);
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an insta... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... |
In the reactive spec, this should return normally rather than throwing (ie. `return Mono.error(logger.logExceptionAsError)`). https://github.com/reactive-streams/reactive-streams-jvm#2.13 | public Mono<AccessToken> getToken(TokenRequestContext request) {
StringBuilder message = new StringBuilder();
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException")) {
throw logger.logExcept... | throw logger.logExceptionAsError(new CredentialUnavailableException( | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException"))... | class ChainedTokenCredential implements TokenCredential {
private final ClientLogger logger = new ClientLogger(ChainedTokenCredential.class);
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an insta... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... |
This if statement logic is redundant now. can be removed. | public Mono<AccessToken> getToken(TokenRequestContext request) {
StringBuilder message = new StringBuilder();
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(CredentialUnavailableException.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException")) {
r... | if (!t.getClass().getSimpleName().equals("CredentialUnavailableException")) { | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException"))... | class ChainedTokenCredential implements TokenCredential {
private final ClientLogger logger = new ClientLogger(ChainedTokenCredential.class);
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an insta... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... |
We need to retain the stack traces from individual exception and chain them. Java devs use the stack trace to analyze / debug issues. | public Mono<AccessToken> getToken(TokenRequestContext request) {
StringBuilder message = new StringBuilder();
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException")) {
throw logger.logExcept... | message.append(t.getMessage()).append(" "); | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException"))... | class ChainedTokenCredential implements TokenCredential {
private final ClientLogger logger = new ClientLogger(ChainedTokenCredential.class);
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an insta... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... |
In .net python and js, if authenticate unavaliable, continuing to run follow credential. If authenticate failed, stop running and print the failed credential and its failed reason. | public Mono<AccessToken> getToken(TokenRequestContext request) {
StringBuilder message = new StringBuilder();
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(CredentialUnavailableException.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException")) {
r... | if (!t.getClass().getSimpleName().equals("CredentialUnavailableException")) { | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException"))... | class ChainedTokenCredential implements TokenCredential {
private final ClientLogger logger = new ClientLogger(ChainedTokenCredential.class);
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an insta... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... |
Yeah, the onErrorResume will only get invoked if CredentialUnavailabeException is thrown. A non CredentialUnavailabeException will never reach this block and will automatically break the chain. So, this check in the if statement for a non CredentialUnavailabeException is not needed as a non CredentialUnavailabeExceptio... | public Mono<AccessToken> getToken(TokenRequestContext request) {
StringBuilder message = new StringBuilder();
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(CredentialUnavailableException.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException")) {
r... | if (!t.getClass().getSimpleName().equals("CredentialUnavailableException")) { | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException"))... | class ChainedTokenCredential implements TokenCredential {
private final ClientLogger logger = new ClientLogger(ChainedTokenCredential.class);
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an insta... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... |
WHat does the error message with stack trace look like now ? Can you post the sample output here ? | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(CredentialUnavailableException.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUn... | return Mono.error(last); | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException"))... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... |
Exception in thread "main" java.lang.RuntimeException: Max retries 3 times exceeded. Error Details: EnvironmentCredential authentication unavailable. Environment variables are not fully configured. ManagedIdentityCredential authentication unavailable. Connection to IMDS endpoint cannot be established, Network is unreac... | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(CredentialUnavailableException.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUn... | return Mono.error(last); | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException"))... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... |
if failed: Exception in thread "main" java.lang.RuntimeException: Max retries 3 times exceeded. Error Details: DefaultAzureCredential authentication failed. ---> EnvironmentCredential authentication failed. Error Details:AADSTS90002: Tenant '72f988bf-86f1-41af-91ab-2d7cd011db46' not found. This may happen if there are ... | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(CredentialUnavailableException.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUn... | return Mono.error(last); | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException"))... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... |
Why are we wrapping a non Credential Unavailable Exception into a Credential Unavailable Exception ? It should be thrown as it is, to indicate a genuine exception even though credential is available to be used. The distinction will help to debug customer issues too in future. | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException"))... | return Mono.error(new CredentialUnavailableException( | public Mono<AccessToken> getToken(TokenRequestContext request) {
List<CredentialUnavailableException> exceptions = new ArrayList<>(4);
return Flux.fromIterable(credentials)
.flatMap(p -> p.getToken(request).onErrorResume(Exception.class, t -> {
if (!t.getClass().getSimpleName().equals("CredentialUnavailableException"))... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... | class ChainedTokenCredential implements TokenCredential {
private final Deque<TokenCredential> credentials;
private final String unavailableError = this.getClass().getSimpleName() + " authentication failed. ---> ";
/**
* Create an instance of chained token credential that aggregates a list of token
* credentials.
*/
Ch... |
.map is sufficient since this is not an asynchronous operation. Also replace usage of System.out with logger | public Mono<Long> scheduleMessage(ServiceBusMessage message, Instant scheduledEnqueueTime) {
Objects.requireNonNull(message, "'message' cannot be null.");
Objects.requireNonNull(scheduledEnqueueTime, "'scheduledEnqueueTime' cannot be null.");
return connectionProcessor
.flatMap(connection -> connection.getManagementNod... | .flatMap(scheduleSequenceNumber -> { | public Mono<Long> scheduleMessage(ServiceBusMessage message, Instant scheduledEnqueueTime) {
Objects.requireNonNull(message, "'message' cannot be null.");
Objects.requireNonNull(scheduledEnqueueTime, "'scheduledEnqueueTime' cannot be null.");
return getSendLink()
.flatMap(link -> link.getLinkSize().flatMap(size -> {
in... | class ServiceBusSenderAsyncClient implements Closeable {
private final ClientLogger logger = new ClientLogger(ServiceBusSenderAsyncClient.class);
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final TracerProvider tracerProvider;
private final MessageSerializer messageSerializer;
private final Am... | class ServiceBusSenderAsyncClient implements AutoCloseable {
/**
* The default maximum allowable size, in bytes, for a batch to be sent.
*/
static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
private static final CreateBatchOptions DEFAULT_BATCH_OPTIONS = new CreateBatchOptions();
private final ClientLogger logger... |
Its more specific you to create a mock of the message and then if the managementNode gets a schedule call with that instance to return the number. any() should be used in the case when the parameter can be variable things or its not specific to the test case you are checking. | void scheduleMessage() {
long sequenceNumberReturned =10;
when(managementNode.schedule(any(ServiceBusMessage.class), any(Instant.class)))
.thenReturn(just(sequenceNumberReturned));
StepVerifier.create(sender.scheduleMessage(mock(ServiceBusMessage.class), mock(Instant.class)))
.expectNext(sequenceNumberReturned)
.verify... | StepVerifier.create(sender.scheduleMessage(mock(ServiceBusMessage.class), mock(Instant.class))) | void scheduleMessage() {
long sequenceNumberReturned = 10;
Instant instant = mock(Instant.class);
when(connection.createSendLink(eq(ENTITY_NAME), eq(ENTITY_NAME), any(AmqpRetryOptions.class)))
.thenReturn(Mono.just(sendLink));
when(sendLink.getLinkSize()).thenReturn(Mono.just(MAX_MESSAGE_LENGTH_BYTES));
when(management... | class ServiceBusSenderAsyncClientTest {
private static final String NAMESPACE = "my-namespace";
private static final String ENTITY_NAME = "my-servicebus-entity";
@Mock
private AmqpSendLink sendLink;
@Mock
private ServiceBusAmqpConnection connection;
@Mock
private TokenCredential tokenCredential;
@Mock
private ErrorCont... | class ServiceBusSenderAsyncClientTest {
private static final String NAMESPACE = "my-namespace";
private static final String ENTITY_NAME = "my-servicebus-entity";
@Mock
private AmqpSendLink sendLink;
@Mock
private ServiceBusAmqpConnection connection;
@Mock
private TokenCredential tokenCredential;
@Mock
private ErrorCont... |
I should have noticed it before, put the private `renewMessageLock` method into the public one. It is only used in one place. It saves another stack call. | private Message createManagementMessage(String operation, String linkName) {
final Duration serverTimeout = MessageUtils.adjustServerTimeout(operationTimeout);
final Map<String, Object> applicationProperties = new HashMap<>();
applicationProperties.put(MANAGEMENT_OPERATION_KEY, operation);
applicationProperties.put(SER... | return message; | private Message createManagementMessage(String operation, String linkName) {
final Duration serverTimeout = MessageUtils.adjustServerTimeout(operationTimeout);
final Map<String, Object> applicationProperties = new HashMap<>();
applicationProperties.put(MANAGEMENT_OPERATION_KEY, operation);
applicationProperties.put(SER... | class ManagementChannel implements ServiceBusManagementNode {
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String fullyQualifiedNamespace;
private final... | class ManagementChannel implements ServiceBusManagementNode {
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String fullyQualifiedNamespace;
private final... |
is this what they do in track 1? update the actual parameter object itself? Since we want to make ServicebusReceivedMessage immutable, id expect a clone to be created. | public Mono<Instant> renewMessageLock(ServiceBusReceivedMessage receivedMessage) {
return connectionProcessor
.flatMap(connection -> connection.getManagementNode(entityPath, entityType))
.flatMap(serviceBusManagementNode -> serviceBusManagementNode
.renewMessageLock(receivedMessage.getLockToken())
.map(instant -> {
rec... | receivedMessage.setLockedUntil(instant); | public Mono<Instant> renewMessageLock(ServiceBusReceivedMessage receivedMessage) {
return connectionProcessor
.flatMap(connection -> connection.getManagementNode(entityPath, entityType))
.flatMap(serviceBusManagementNode -> serviceBusManagementNode
.renewMessageLock(receivedMessage.getLockToken())
.map(instant -> {
rec... | class ServiceBusReceiverAsyncClient implements Closeable {
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private final ConcurrentHashMap<UUID, Instant> lockTokenExpirationMap = new ConcurrentHashMap<>();
private f... | class ServiceBusReceiverAsyncClient implements Closeable {
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private final ConcurrentHashMap<UUID, Instant> lockTokenExpirationMap = new ConcurrentHashMap<>();
private f... |
I was thinking of when we have to renew multiple lock Token in one go and need to expose that API, this would be helpful. But for now I have changed this like you said. | private Message createManagementMessage(String operation, String linkName) {
final Duration serverTimeout = MessageUtils.adjustServerTimeout(operationTimeout);
final Map<String, Object> applicationProperties = new HashMap<>();
applicationProperties.put(MANAGEMENT_OPERATION_KEY, operation);
applicationProperties.put(SER... | return message; | private Message createManagementMessage(String operation, String linkName) {
final Duration serverTimeout = MessageUtils.adjustServerTimeout(operationTimeout);
final Map<String, Object> applicationProperties = new HashMap<>();
applicationProperties.put(MANAGEMENT_OPERATION_KEY, operation);
applicationProperties.put(SER... | class ManagementChannel implements ServiceBusManagementNode {
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String fullyQualifiedNamespace;
private final... | class ManagementChannel implements ServiceBusManagementNode {
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String fullyQualifiedNamespace;
private final... |
Nothing is this code is async, you can use .map. | public Mono<Instant> renewMessageLock(UUID lockToken) {
return isAuthorized(PEEK_OPERATION).then(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagementMessage(RENEW_LOCK_OPERATION,
channel.getReceiveLinkName());
requestMessage.setBody(new AmqpValue(Collections.singletonMap(LOCK_TOKENS_KEY... | }).flatMap(responseMessage -> { | public Mono<Instant> renewMessageLock(UUID lockToken) {
return isAuthorized(PEEK_OPERATION).then(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagementMessage(RENEW_LOCK_OPERATION,
channel.getReceiveLinkName());
requestMessage.setBody(new AmqpValue(Collections.singletonMap(LOCK_TOKENS_KEY... | class ManagementChannel implements ServiceBusManagementNode {
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String fullyQualifiedNamespace;
private final... | class ManagementChannel implements ServiceBusManagementNode {
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String fullyQualifiedNamespace;
private final... |
Similar to my first comment above. This can be .map rather than .flatMap. | public Mono<Long> schedule(ServiceBusMessage messageToSchedule, Instant scheduledEnqueueTime, int maxSendLinkSize) {
messageToSchedule.setScheduledEnqueueTime(scheduledEnqueueTime);
return isAuthorized(SCHEDULE_MESSAGE_OPERATION).then(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagement... | }).flatMap(responseMessage -> { | public Mono<Long> schedule(ServiceBusMessage messageToSchedule, Instant scheduledEnqueueTime, int maxSendLinkSize) {
messageToSchedule.setScheduledEnqueueTime(scheduledEnqueueTime);
return isAuthorized(SCHEDULE_MESSAGE_OPERATION).then(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagement... | class ManagementChannel implements ServiceBusManagementNode {
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String fullyQualifiedNamespace;
private final... | class ManagementChannel implements ServiceBusManagementNode {
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String fullyQualifiedNamespace;
private final... |
nit: remove System.out | void receiveMessageAutoComplete() {
final String messageId = UUID.randomUUID().toString();
final String contents = "Some-contents";
final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, messageId, 0);
StepVerifier.create(sender.send(message).thenMany(receiver.receive().take(1)))
.assertNext(receive... | System.out.println("Completed."); | void receiveMessageAutoComplete() {
final String messageId = UUID.randomUUID().toString();
final String contents = "Some-contents";
final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, messageId, 0);
StepVerifier.create(sender.send(message).thenMany(receiver.receive().take(1)))
.assertNext(receive... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
ServiceBusReceiverAsyncClientIntegrationTest() {
super(new ClientLogger(ServiceBusReceiverAsyn... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
ServiceBusReceiverAsyncClientIntegrationTest() {
super(new ClientLogger(ServiceBusReceiverAsyn... |
Do you have test when user do not want autoComplete and want to call him self ? | public Mono<Void> complete(ServiceBusReceivedMessage message) {
Objects.requireNonNull(message, "'message' cannot be null.");
if (receiveMode != ReceiveMode.PEEK_LOCK && isAutoComplete) {
return Mono.error(logger.logExceptionAsError(new UnsupportedOperationException(
"Complete is not supported on a receiver opened in R... | if (receiveMode != ReceiveMode.PEEK_LOCK && isAutoComplete) { | public Mono<Void> complete(ServiceBusReceivedMessage message) {
return updateDisposition(message, DispositionStatus.COMPLETED, null, null, null);
} | class ServiceBusReceiverAsyncClient implements Closeable {
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private final ConcurrentHashMap<UUID, Instant> lockTokenExpirationMap = new ConcurrentHashMap<>();
private f... | class ServiceBusReceiverAsyncClient implements Closeable {
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private final ConcurrentHashMap<UUID, Instant> lockTokenExpirationMap = new ConcurrentHashMap<>();
private f... |
I'll add that. | public Mono<Void> complete(ServiceBusReceivedMessage message) {
Objects.requireNonNull(message, "'message' cannot be null.");
if (receiveMode != ReceiveMode.PEEK_LOCK && isAutoComplete) {
return Mono.error(logger.logExceptionAsError(new UnsupportedOperationException(
"Complete is not supported on a receiver opened in R... | if (receiveMode != ReceiveMode.PEEK_LOCK && isAutoComplete) { | public Mono<Void> complete(ServiceBusReceivedMessage message) {
return updateDisposition(message, DispositionStatus.COMPLETED, null, null, null);
} | class ServiceBusReceiverAsyncClient implements Closeable {
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private final ConcurrentHashMap<UUID, Instant> lockTokenExpirationMap = new ConcurrentHashMap<>();
private f... | class ServiceBusReceiverAsyncClient implements Closeable {
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private final ConcurrentHashMap<UUID, Instant> lockTokenExpirationMap = new ConcurrentHashMap<>();
private f... |
Any reason this is called Mono when it is a Flux? | private ServiceBusAsyncConsumer getOrCreateConsumer(String linkName) {
return openConsumers.computeIfAbsent(linkName, name -> {
logger.info("{}: Creating consumer for link '{}'", entityPath, linkName);
final Flux<AmqpReceiveLink> receiveLinkMono =
connectionProcessor.flatMap(connection -> connection.createReceiveLink(l... | final Flux<AmqpReceiveLink> receiveLinkMono = | private ServiceBusAsyncConsumer getOrCreateConsumer(String linkName) {
return openConsumers.computeIfAbsent(linkName, name -> {
logger.info("{}: Creating consumer for link '{}'", entityPath, linkName);
final Flux<AmqpReceiveLink> receiveLink =
connectionProcessor.flatMap(connection -> connection.createReceiveLink(linkN... | class ServiceBusReceiverAsyncClient implements Closeable {
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private final ConcurrentHashMap<UUID, Instant> lockTokenExpirationMap = new ConcurrentHashMap<>();
private f... | class ServiceBusReceiverAsyncClient implements Closeable {
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private final ConcurrentHashMap<UUID, Instant> lockTokenExpirationMap = new ConcurrentHashMap<>();
private f... |
Try Mono.when(sender.send(message), sender.send(message)) | void peekBatchMessagesFromSequence() {
final String messageId = UUID.randomUUID().toString();
final String contents = "Some-contents";
final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, messageId, 0);
int maxMessages = 2;
int fromSequenceNumber = 1;
StepVerifier.create(sender.send(message)
.then... | StepVerifier.create(sender.send(message) | void peekBatchMessagesFromSequence() {
final String messageId = UUID.randomUUID().toString();
final String contents = "Some-contents";
final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, messageId, 0);
int maxMessages = 2;
int fromSequenceNumber = 1;
StepVerifier.create(Mono.when(sender.send(mess... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
ServiceBusReceiverAsyncClientIntegrationTest() {
super(new ClientLogger(ServiceBusReceiverAsyn... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
ServiceBusReceiverAsyncClientIntegrationTest() {
super(new ClientLogger(ServiceBusReceiverAsyn... |
Instead of asserting the number of events, I would try to assert that the messages I expect came back. (ie. message 1 and message 2) | void peekBatchWithSequenceNumberMessages() {
final int numberOfEvents = 2;
final int fromSequenceNumber = 10;
when(managementNode.peekBatch(numberOfEvents, fromSequenceNumber))
.thenReturn(Flux.fromArray(new ServiceBusReceivedMessage[]{message1, message2}));
StepVerifier.create(consumer.peekBatch(numberOfEvents, fromSe... | StepVerifier.create(consumer.peekBatch(numberOfEvents, fromSequenceNumber)) | void peekBatchWithSequenceNumberMessages() {
final int numberOfEvents = 2;
final int fromSequenceNumber = 10;
when(managementNode.peekBatch(numberOfEvents, fromSequenceNumber))
.thenReturn(Flux.fromArray(new ServiceBusReceivedMessage[]{receivedMessage, receivedMessage2}));
StepVerifier.create(consumer.peekBatch(numberO... | class ServiceBusReceiverAsyncClientTest {
private static final String PAYLOAD = "hello";
private static final byte[] PAYLOAD_BYTES = PAYLOAD.getBytes(UTF_8);
private static final int PREFETCH = 5;
private static final String NAMESPACE = "my-namespace-foo";
private static final String ENTITY_NAME = "queue-name";
private... | class ServiceBusReceiverAsyncClientTest {
private static final String PAYLOAD = "hello";
private static final byte[] PAYLOAD_BYTES = PAYLOAD.getBytes(UTF_8);
private static final int PREFETCH = 5;
private static final String NAMESPACE = "my-namespace-foo";
private static final String ENTITY_PATH = "queue-name";
private... |
replace with: Mono.when() | void peekBatchMessages() {
final String messageId = UUID.randomUUID().toString();
final String contents = "Some-contents";
final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, messageId, 0);
int maxMessages = 2;
StepVerifier.create(sender.send(message)
.then(sender.send(message))
.thenMany(receive... | StepVerifier.create(sender.send(message) | void peekBatchMessages() {
final String messageId = UUID.randomUUID().toString();
final String contents = "Some-contents";
final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, messageId, 0);
int maxMessages = 2;
StepVerifier.create(Mono.when(sender.send(message), sender.send(message))
.thenMany(re... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
ServiceBusReceiverAsyncClientIntegrationTest() {
super(new ClientLogger(ServiceBusReceiverAsyn... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
ServiceBusReceiverAsyncClientIntegrationTest() {
super(new ClientLogger(ServiceBusReceiverAsyn... |
This should be removed form API | public String getContentType() {
return contentType;
} | } | public String getContentType() {
return contentType;
} | class ServiceBusMessage {
private final Map<String, Object> properties;
private final byte[] body;
private Context context;
private String contentType;
private String correlationId;
private String label;
private String messageId;
private String partitionKey;
private String replyTo;
private String replyToSessionId;
priv... | class ServiceBusMessage {
private final Map<String, Object> properties;
private final byte[] body;
private Context context;
private String contentType;
private String correlationId;
private String label;
private String messageId;
private String partitionKey;
private String replyTo;
private String replyToSessionId;
priv... |
detectLanguageWithCountryHint() uses `String input` | public void detectLanguage() {
String document = "Bonjour tout le monde";
textAnalyticsAsyncClient.detectLanguage(document).subscribe(detectedLanguage ->
System.out.printf("Detected language name: %s, ISO 6391 Name: %s, score: %f.%n",
detectedLanguage.getName(), detectedLanguage.getIso6391Name(), detectedLanguage.getSc... | public void detectLanguage() {
String document = "Bonjour tout le monde";
textAnalyticsAsyncClient.detectLanguage(document).subscribe(detectedLanguage ->
System.out.printf("Detected language name: %s, ISO 6391 Name: %s, score: %f.%n",
detectedLanguage.getName(), detectedLanguage.getIso6391Name(), detectedLanguage.getSc... | class TextAnalyticsAsyncClientJavaDocCodeSnippets {
TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient();
/**
* Code snippet for creating a {@link TextAnalyticsAsyncClient}
*
* @return The TextAnalyticsAsyncClient object
*/
public TextAnalyticsAsyncClient createTextAnalyticsAsyncClient()... | class TextAnalyticsAsyncClientJavaDocCodeSnippets {
TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient();
/**
* Code snippet for creating a {@link TextAnalyticsAsyncClient}
*
* @return The TextAnalyticsAsyncClient object
*/
public TextAnalyticsAsyncClient createTextAnalyticsAsyncClient()... | |
updated | public void detectLanguage() {
String document = "Bonjour tout le monde";
textAnalyticsAsyncClient.detectLanguage(document).subscribe(detectedLanguage ->
System.out.printf("Detected language name: %s, ISO 6391 Name: %s, score: %f.%n",
detectedLanguage.getName(), detectedLanguage.getIso6391Name(), detectedLanguage.getSc... | public void detectLanguage() {
String document = "Bonjour tout le monde";
textAnalyticsAsyncClient.detectLanguage(document).subscribe(detectedLanguage ->
System.out.printf("Detected language name: %s, ISO 6391 Name: %s, score: %f.%n",
detectedLanguage.getName(), detectedLanguage.getIso6391Name(), detectedLanguage.getSc... | class TextAnalyticsAsyncClientJavaDocCodeSnippets {
TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient();
/**
* Code snippet for creating a {@link TextAnalyticsAsyncClient}
*
* @return The TextAnalyticsAsyncClient object
*/
public TextAnalyticsAsyncClient createTextAnalyticsAsyncClient()... | class TextAnalyticsAsyncClientJavaDocCodeSnippets {
TextAnalyticsAsyncClient textAnalyticsAsyncClient = createTextAnalyticsAsyncClient();
/**
* Code snippet for creating a {@link TextAnalyticsAsyncClient}
*
* @return The TextAnalyticsAsyncClient object
*/
public TextAnalyticsAsyncClient createTextAnalyticsAsyncClient()... | |
PagedIterable/PagedFlux is already doing what need to be done on paged response. This class is only a wrapper to provide interface compatible with v1. | protected void loadNextPage() {
this.items.addAll(pagedResponseIterator.next().getValue());
} | this.items.addAll(pagedResponseIterator.next().getValue()); | protected void loadNextPage() {
this.items.addAll(pagedResponseIterator.next().getValue());
} | class PagedList<E> implements List<E> {
/** The items retrieved. */
private final List<E> items;
/** The paged response iterator for not retrieved items. */
private Iterator<PagedResponse<E>> pagedResponseIterator;
/**
* Creates an instance of PagedList.
*/
public PagedList() {
items = new ArrayList<>();
pagedResponseI... | class PagedList<E> implements List<E> {
/** The items retrieved. */
private final List<E> items;
/** The paged response iterator for not retrieved items. */
private Iterator<PagedResponse<E>> pagedResponseIterator;
/**
* Creates an instance of PagedList.
*/
public PagedList() {
items = new ArrayList<>();
pagedResponseI... |
Any reason `/path` is required? | public static boolean determineAuthorityIsIpStyle(String authority) throws MalformedURLException {
return new URL("http:
} | return new URL("http: | public static boolean determineAuthorityIsIpStyle(String authority) throws MalformedURLException {
return new URL("http:
} | class ModelHelper {
/**
* Determines whether or not the passed authority is IP style, that is it is of the format
* "<host>:<port>".
*
* @param authority The authority of a URL.
* @throws MalformedURLException If the authority is malformed.
* @return Whether the authority is IP style.
*/
/**
* Fills in defa... | class ModelHelper {
/**
* Determines whether or not the passed authority is IP style, that is, it is of the format {@code <host>:<port>}.
*
* @param authority The authority of a URL.
* @throws MalformedURLException If the authority is malformed.
* @return Whether the authority is IP style.
*/
/**
* Fills in default val... |
Does this issue affect Queues as well? I know it also supports IP-style URLs in Azurite. | public BlobUrlParts setHost(String host) {
this.host = host;
try {
this.isIpUrl = ModelHelper.determineAuthorityIsIpStyle(host);
} catch (MalformedURLException e) {
throw logger.logExceptionAsError(new IllegalStateException("Authority is malformed. Host: "
+ host));
}
return this;
} | } | public BlobUrlParts setHost(String host) {
this.host = host;
try {
this.isIpUrl = ModelHelper.determineAuthorityIsIpStyle(host);
} catch (MalformedURLException e) {
throw logger.logExceptionAsError(new IllegalStateException("Authority is malformed. Host: "
+ host));
}
return this;
} | class BlobUrlParts {
private final ClientLogger logger = new ClientLogger(BlobUrlParts.class);
private String scheme;
private String host;
private String containerName;
private String blobName;
private String snapshot;
private String accountName;
private boolean isIpUrl;
private CommonSasQueryParameters commonSasQueryP... | class BlobUrlParts {
private final ClientLogger logger = new ClientLogger(BlobUrlParts.class);
private String scheme;
private String host;
private String containerName;
private String blobName;
private String snapshot;
private String accountName;
private boolean isIpUrl;
private CommonSasQueryParameters commonSasQueryP... |
It was a required parameter for an overload of URL constructor that I was initially trying to use, but I can try this without it and see if it still works | public static boolean determineAuthorityIsIpStyle(String authority) throws MalformedURLException {
return new URL("http:
} | return new URL("http: | public static boolean determineAuthorityIsIpStyle(String authority) throws MalformedURLException {
return new URL("http:
} | class ModelHelper {
/**
* Determines whether or not the passed authority is IP style, that is it is of the format
* "<host>:<port>".
*
* @param authority The authority of a URL.
* @throws MalformedURLException If the authority is malformed.
* @return Whether the authority is IP style.
*/
/**
* Fills in defa... | class ModelHelper {
/**
* Determines whether or not the passed authority is IP style, that is, it is of the format {@code <host>:<port>}.
*
* @param authority The authority of a URL.
* @throws MalformedURLException If the authority is malformed.
* @return Whether the authority is IP style.
*/
/**
* Fills in default val... |
Yea I should probably bring it over there as well. Thanks for thinking of that. | public BlobUrlParts setHost(String host) {
this.host = host;
try {
this.isIpUrl = ModelHelper.determineAuthorityIsIpStyle(host);
} catch (MalformedURLException e) {
throw logger.logExceptionAsError(new IllegalStateException("Authority is malformed. Host: "
+ host));
}
return this;
} | } | public BlobUrlParts setHost(String host) {
this.host = host;
try {
this.isIpUrl = ModelHelper.determineAuthorityIsIpStyle(host);
} catch (MalformedURLException e) {
throw logger.logExceptionAsError(new IllegalStateException("Authority is malformed. Host: "
+ host));
}
return this;
} | class BlobUrlParts {
private final ClientLogger logger = new ClientLogger(BlobUrlParts.class);
private String scheme;
private String host;
private String containerName;
private String blobName;
private String snapshot;
private String accountName;
private boolean isIpUrl;
private CommonSasQueryParameters commonSasQueryP... | class BlobUrlParts {
private final ClientLogger logger = new ClientLogger(BlobUrlParts.class);
private String scheme;
private String host;
private String containerName;
private String blobName;
private String snapshot;
private String accountName;
private boolean isIpUrl;
private CommonSasQueryParameters commonSasQueryP... |
Track 1: They update same object in this way. | public Mono<Instant> renewMessageLock(ServiceBusReceivedMessage receivedMessage) {
return connectionProcessor
.flatMap(connection -> connection.getManagementNode(entityPath, entityType))
.flatMap(serviceBusManagementNode -> serviceBusManagementNode
.renewMessageLock(receivedMessage.getLockToken())
.map(instant -> {
rec... | receivedMessage.setLockedUntil(instant); | public Mono<Instant> renewMessageLock(ServiceBusReceivedMessage receivedMessage) {
return connectionProcessor
.flatMap(connection -> connection.getManagementNode(entityPath, entityType))
.flatMap(serviceBusManagementNode -> serviceBusManagementNode
.renewMessageLock(receivedMessage.getLockToken())
.map(instant -> {
rec... | class ServiceBusReceiverAsyncClient implements Closeable {
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private final ConcurrentHashMap<UUID, Instant> lockTokenExpirationMap = new ConcurrentHashMap<>();
private f... | class ServiceBusReceiverAsyncClient implements Closeable {
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private final ConcurrentHashMap<UUID, Instant> lockTokenExpirationMap = new ConcurrentHashMap<>();
private f... |
With this, user now have 2 choice when migrate. 1. Use PagedIterable, and refactor any code that handling it. 2. Use PagedList, use it to wrap PagedIterable. Find time later to do all refactor needed in 1. | protected void loadNextPage() {
this.items.addAll(pagedResponseIterator.next().getValue());
} | this.items.addAll(pagedResponseIterator.next().getValue()); | protected void loadNextPage() {
this.items.addAll(pagedResponseIterator.next().getValue());
} | class PagedList<E> implements List<E> {
/** The items retrieved. */
private final List<E> items;
/** The paged response iterator for not retrieved items. */
private Iterator<PagedResponse<E>> pagedResponseIterator;
/**
* Creates an instance of PagedList.
*/
public PagedList() {
items = new ArrayList<>();
pagedResponseI... | class PagedList<E> implements List<E> {
/** The items retrieved. */
private final List<E> items;
/** The paged response iterator for not retrieved items. */
private Iterator<PagedResponse<E>> pagedResponseIterator;
/**
* Creates an instance of PagedList.
*/
public PagedList() {
items = new ArrayList<>();
pagedResponseI... |
I don't know if this is the correct operator, what if there are multiple instants? `.single()` would throw an exception if there were more than one element. | public Mono<Instant> renewMessageLock(UUID lockToken) {
return renewMessageLock(new UUID[]{lockToken})
.last()
.publishOn(scheduler);
} | .last() | public Mono<Instant> renewMessageLock(UUID lockToken) {
return renewMessageLock(new UUID[]{lockToken})
.next()
.publishOn(scheduler);
} | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... |
Is there a reason you're creating another array with the same content? | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
UUID[] lockTokens = Arrays.stream(renewLockList)
.toArray(UUID[]::new);
Message requestMessage = createManagementMessage(REQUEST_RESPONSE_RENEWLOCK_OPERATION,
cha... | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagementMessage(RENEW_LOCK_OPERATION,
channel.getReceiveLinkName());
requestMessage.setBody(new AmqpValue(Collections.singletonMa... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | |
REQUEST_RESPONSE_RENEWLOCK_OPERATION -> REQUEST_RESPONSE_RENEW_LOCK_OPERATION | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
UUID[] lockTokens = Arrays.stream(renewLockList)
.toArray(UUID[]::new);
Message requestMessage = createManagementMessage(REQUEST_RESPONSE_RENEWLOCK_OPERATION,
cha... | Message requestMessage = createManagementMessage(REQUEST_RESPONSE_RENEWLOCK_OPERATION, | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagementMessage(RENEW_LOCK_OPERATION,
channel.getReceiveLinkName());
requestMessage.setBody(new AmqpValue(Collections.singletonMa... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... |
What if the status isn't OK? We should return an error. | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
UUID[] lockTokens = Arrays.stream(renewLockList)
.toArray(UUID[]::new);
Message requestMessage = createManagementMessage(REQUEST_RESPONSE_RENEWLOCK_OPERATION,
cha... | if (statusCode == REQUEST_RESPONSE_OK_STATUS_CODE) { | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagementMessage(RENEW_LOCK_OPERATION,
channel.getReceiveLinkName());
requestMessage.setBody(new AmqpValue(Collections.singletonMa... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... |
You need to run Alt+Shift+L to reformat the code. There is incorrect spacing on a few lines. | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
UUID[] lockTokens = Arrays.stream(renewLockList)
.toArray(UUID[]::new);
Message requestMessage = createManagementMessage(REQUEST_RESPONSE_RENEWLOCK_OPERATION,
cha... | if (statusCode == REQUEST_RESPONSE_OK_STATUS_CODE) { | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagementMessage(RENEW_LOCK_OPERATION,
channel.getReceiveLinkName());
requestMessage.setBody(new AmqpValue(Collections.singletonMa... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... |
All this logic can be moved to MessageSerializer. | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
UUID[] lockTokens = Arrays.stream(renewLockList)
.toArray(UUID[]::new);
Message requestMessage = createManagementMessage(REQUEST_RESPONSE_RENEWLOCK_OPERATION,
cha... | int statusCode = RequestResponseUtils.getResponseStatusCode(responseMessage); | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagementMessage(RENEW_LOCK_OPERATION,
channel.getReceiveLinkName());
requestMessage.setBody(new AmqpValue(Collections.singletonMa... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... |
thanks for clarification. Then in our sample or migration guide, pls use PagedIterable as right and long term way for paging operation. | protected void loadNextPage() {
this.items.addAll(pagedResponseIterator.next().getValue());
} | this.items.addAll(pagedResponseIterator.next().getValue()); | protected void loadNextPage() {
this.items.addAll(pagedResponseIterator.next().getValue());
} | class PagedList<E> implements List<E> {
/** The items retrieved. */
private final List<E> items;
/** The paged response iterator for not retrieved items. */
private Iterator<PagedResponse<E>> pagedResponseIterator;
/**
* Creates an instance of PagedList.
*/
public PagedList() {
items = new ArrayList<>();
pagedResponseI... | class PagedList<E> implements List<E> {
/** The items retrieved. */
private final List<E> items;
/** The paged response iterator for not retrieved items. */
private Iterator<PagedResponse<E>> pagedResponseIterator;
/**
* Creates an instance of PagedList.
*/
public PagedList() {
items = new ArrayList<>();
pagedResponseI... |
This unchecked cast makes me nervous. I would be more defensive about casting (ie. checking instanceof). | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
UUID[] lockTokens = Arrays.stream(renewLockList)
.toArray(UUID[]::new);
Message requestMessage = createManagementMessage(REQUEST_RESPONSE_RENEWLOCK_OPERATION,
cha... | Map<String, Object> responseBody = (Map<String, Object>) ((AmqpValue) responseMessage | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagementMessage(RENEW_LOCK_OPERATION,
channel.getReceiveLinkName());
requestMessage.setBody(new AmqpValue(Collections.singletonMa... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... |
This variable creation isn't necessary if you're going to pass it immediately to the next line. | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
UUID[] lockTokens = Arrays.stream(renewLockList)
.toArray(UUID[]::new);
Message requestMessage = createManagementMessage(REQUEST_RESPONSE_RENEWLOCK_OPERATION,
cha... | Date[] expirations = (Date[]) expirationListObj; | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagementMessage(RENEW_LOCK_OPERATION,
channel.getReceiveLinkName());
requestMessage.setBody(new AmqpValue(Collections.singletonMa... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... |
Instead of returning Flux.fromIterable, you could have kept it as a stream instead of collecting it twice and using fromStream | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
UUID[] lockTokens = Arrays.stream(renewLockList)
.toArray(UUID[]::new);
Message requestMessage = createManagementMessage(REQUEST_RESPONSE_RENEWLOCK_OPERATION,
cha... | return Flux.fromIterable(expirationsForLocks); | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagementMessage(RENEW_LOCK_OPERATION,
channel.getReceiveLinkName());
requestMessage.setBody(new AmqpValue(Collections.singletonMa... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... |
removing it. | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
UUID[] lockTokens = Arrays.stream(renewLockList)
.toArray(UUID[]::new);
Message requestMessage = createManagementMessage(REQUEST_RESPONSE_RENEWLOCK_OPERATION,
cha... | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagementMessage(RENEW_LOCK_OPERATION,
channel.getReceiveLinkName());
requestMessage.setBody(new AmqpValue(Collections.singletonMa... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | |
Normally service would return one because we are sending one lock token . But in track1 also , they are using same logic since AMQP message comes as array in case of one lock token. | public Mono<Instant> renewMessageLock(UUID lockToken) {
return renewMessageLock(new UUID[]{lockToken})
.last()
.publishOn(scheduler);
} | .last() | public Mono<Instant> renewMessageLock(UUID lockToken) {
return renewMessageLock(new UUID[]{lockToken})
.next()
.publishOn(scheduler);
} | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... |
moved to serializer. | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
UUID[] lockTokens = Arrays.stream(renewLockList)
.toArray(UUID[]::new);
Message requestMessage = createManagementMessage(REQUEST_RESPONSE_RENEWLOCK_OPERATION,
cha... | int statusCode = RequestResponseUtils.getResponseStatusCode(responseMessage); | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagementMessage(RENEW_LOCK_OPERATION,
channel.getReceiveLinkName());
requestMessage.setBody(new AmqpValue(Collections.singletonMa... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... |
```suggestion if (expirationListObj instanceof Date[]) { ``` | private List<Instant> deserializeListOfInstant(Message amqpMessage) {
List<Instant> listInstant = new ArrayList<>();
if (amqpMessage.getBody() instanceof AmqpValue) {
AmqpValue amqpValue = ((AmqpValue) amqpMessage.getBody());
if (amqpValue.getValue() instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object>... | if (expirationListObj instanceof Date[]) { | private List<Instant> deserializeListOfInstant(Message amqpMessage) {
if (amqpMessage.getBody() instanceof AmqpValue) {
AmqpValue amqpValue = ((AmqpValue) amqpMessage.getBody());
if (amqpValue.getValue() instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object> responseBody = (Map<String, Object>) amqpValue... | class ServiceBusMessageSerializer implements MessageSerializer {
private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
private static final String ENQUEUED_TIME_UTC_NAME = "x-opt-enqueued-time";
private static final String SCHEDULED_ENQUEUE_TIME_NAME = "x-opt-scheduled-enqueue-time";
private static final String S... | class ServiceBusMessageSerializer implements MessageSerializer {
private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
private static final String ENQUEUED_TIME_UTC_NAME = "x-opt-enqueued-time";
private static final String SCHEDULED_ENQUEUE_TIME_NAME = "x-opt-scheduled-enqueue-time";
private static final String S... |
You don't need this variable because you reassign it later anyways. Return a collections.emptylist in the other cases. | private List<Instant> deserializeListOfInstant(Message amqpMessage) {
List<Instant> listInstant = new ArrayList<>();
if (amqpMessage.getBody() instanceof AmqpValue) {
AmqpValue amqpValue = ((AmqpValue) amqpMessage.getBody());
if (amqpValue.getValue() instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object>... | List<Instant> listInstant = new ArrayList<>(); | private List<Instant> deserializeListOfInstant(Message amqpMessage) {
if (amqpMessage.getBody() instanceof AmqpValue) {
AmqpValue amqpValue = ((AmqpValue) amqpMessage.getBody());
if (amqpValue.getValue() instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object> responseBody = (Map<String, Object>) amqpValue... | class ServiceBusMessageSerializer implements MessageSerializer {
private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
private static final String ENQUEUED_TIME_UTC_NAME = "x-opt-enqueued-time";
private static final String SCHEDULED_ENQUEUE_TIME_NAME = "x-opt-scheduled-enqueue-time";
private static final String S... | class ServiceBusMessageSerializer implements MessageSerializer {
private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
private static final String ENQUEUED_TIME_UTC_NAME = "x-opt-enqueued-time";
private static final String SCHEDULED_ENQUEUE_TIME_NAME = "x-opt-scheduled-enqueue-time";
private static final String S... |
Yes, and using .single() would force it to throw if there was more than one element in the flux. why not use `.next()` rather than `.last()` then? If the stream had 10000 elements, this would not complete until 9999 elements had been emitted. | public Mono<Instant> renewMessageLock(UUID lockToken) {
return renewMessageLock(new UUID[]{lockToken})
.last()
.publishOn(scheduler);
} | .last() | public Mono<Instant> renewMessageLock(UUID lockToken) {
return renewMessageLock(new UUID[]{lockToken})
.next()
.publishOn(scheduler);
} | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... |
Empty message? RE: "" | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagementMessage(RENEW_LOCK_OPERATION,
channel.getReceiveLinkName());
requestMessage.setBody(new AmqpValue(Collections.singletonMa... | return Mono.error(ExceptionUtil.amqpResponseCodeToException(statusCode, "", getErrorContext())); | private Flux<Instant> renewMessageLock(UUID[] renewLockList) {
return isAuthorized(PEEK_OPERATION_VALUE).thenMany(createRequestResponse.flatMap(channel -> {
Message requestMessage = createManagementMessage(RENEW_LOCK_OPERATION,
channel.getReceiveLinkName());
requestMessage.setBody(new AmqpValue(Collections.singletonMa... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... |
This is never disposed of in `@After` | protected void beforeTest() {
sender = createBuilder().buildAsyncSenderClient();
receiver = createBuilder()
.receiveMessageOptions(receiveMessageOptions)
.buildAsyncReceiverClient();
receiverManual = createBuilder()
.receiveMessageOptions(receiveMessageOptionsManual)
.buildAsyncReceiverClient();
} | receiverManual = createBuilder() | protected void beforeTest() {
sender = createBuilder().buildAsyncSenderClient();
receiver = createBuilder()
.receiveMessageOptions(receiveMessageOptions)
.buildAsyncReceiverClient();
receiverManual = createBuilder()
.receiveMessageOptions(receiveMessageOptionsManual)
.buildAsyncReceiverClient();
} | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusReceiverAsyncClient receiverManual;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
private ReceiveMessageOptions receiveMes... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusReceiverAsyncClient receiverManual;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
private ReceiveMessageOptions receiveMes... |
Like I said, according to the spec this will never be null. | void renewMessageLock() {
Duration renewAfterSeconds = Duration.ofSeconds(1);
long takeTimeToProcessMessageMillis = 10000;
final String contents = "Some-contents";
final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, "id-1", 0);
AtomicReference<Integer> renewMessageLockCounter = new AtomicReferenc... | .assertNext(Assertions::assertNotNull) | void renewMessageLock() {
Duration renewAfterSeconds = Duration.ofSeconds(1);
long takeTimeToProcessMessageMillis = 10000;
final String contents = "Some-contents";
final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, "id-1", 0);
AtomicReference<Integer> renewMessageLockCounter = new AtomicReferenc... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusReceiverAsyncClient receiverManual;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
private ReceiveMessageOptions receiveMes... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusReceiverAsyncClient receiverManual;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
private ReceiveMessageOptions receiveMes... |
I know you added comments and it doesn't make it reactive nor does it use StepVerifier correctly. * You've only hooked up the `doOnNext`, which is used for side effects like logging, but you use it for validation. the first overload of `subscribe` is a better fit. * What if the renewal fails? There is no handling of an... | void renewMessageLock() {
Duration renewAfterSeconds = Duration.ofSeconds(1);
long takeTimeToProcessMessageMillis = 10000;
final String contents = "Some-contents";
final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, "id-1", 0);
AtomicReference<Integer> renewMessageLockCounter = new AtomicReferenc... | Disposable disposable = receiverManual.renewMessageLock(receivedMessage.getLockToken()) | void renewMessageLock() {
Duration renewAfterSeconds = Duration.ofSeconds(1);
long takeTimeToProcessMessageMillis = 10000;
final String contents = "Some-contents";
final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, "id-1", 0);
AtomicReference<Integer> renewMessageLockCounter = new AtomicReferenc... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusReceiverAsyncClient receiverManual;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
private ReceiveMessageOptions receiveMes... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusReceiverAsyncClient receiverManual;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
private ReceiveMessageOptions receiveMes... |
You could have used. repeat() here. | void renewMessageLock() {
Duration renewAfterSeconds = Duration.ofSeconds(1);
long takeTimeToProcessMessageMillis = 10000;
final String contents = "Some-contents";
final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, "id-1", 0);
AtomicReference<Integer> renewMessageLockCounter = new AtomicReferenc... | .repeat(() -> true) | void renewMessageLock() {
Duration renewAfterSeconds = Duration.ofSeconds(1);
long takeTimeToProcessMessageMillis = 10000;
final String contents = "Some-contents";
final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, "id-1", 0);
AtomicReference<Integer> renewMessageLockCounter = new AtomicReferenc... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusReceiverAsyncClient receiverManual;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
private ReceiveMessageOptions receiveMes... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusReceiverAsyncClient receiverManual;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
private ReceiveMessageOptions receiveMes... |
that should be fine I guess. | public Mono<Instant> renewMessageLock(UUID lockToken) {
return renewMessageLock(new UUID[]{lockToken})
.last()
.publishOn(scheduler);
} | .last() | public Mono<Instant> renewMessageLock(UUID lockToken) {
return renewMessageLock(new UUID[]{lockToken})
.next()
.publishOn(scheduler);
} | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... | class ManagementChannel implements ServiceBusManagementNode {
private final Scheduler scheduler;
private final MessageSerializer messageSerializer;
private final TokenManager tokenManager;
private final Duration operationTimeout;
private final Mono<RequestResponseChannel> createRequestResponse;
private final String ful... |
https://github.com/Azure/azure-sdk-for-java/issues/9193 | void renewMessageLock() {
Duration renewAfterSeconds = Duration.ofSeconds(1);
long takeTimeToProcessMessageMillis = 10000;
final String contents = "Some-contents";
final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, "id-1", 0);
AtomicReference<Integer> renewMessageLockCounter = new AtomicReferenc... | Disposable disposable = receiverManual.renewMessageLock(receivedMessage.getLockToken()) | void renewMessageLock() {
Duration renewAfterSeconds = Duration.ofSeconds(1);
long takeTimeToProcessMessageMillis = 10000;
final String contents = "Some-contents";
final ServiceBusMessage message = TestUtils.getServiceBusMessage(contents, "id-1", 0);
AtomicReference<Integer> renewMessageLockCounter = new AtomicReferenc... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusReceiverAsyncClient receiverManual;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
private ReceiveMessageOptions receiveMes... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusReceiverAsyncClient receiverManual;
private ServiceBusSenderAsyncClient sender;
private ReceiveMessageOptions receiveMessageOptions;
private ReceiveMessageOptions receiveMes... |
`headerSubstituations` is instantiated to an empty `List` and will only be added to, will never be null. | public Iterable<HttpHeader> setHeaders(Object[] swaggerMethodArguments) {
final HttpHeaders result = new HttpHeaders(headers);
for (Substitution headerSubstitution : headerSubstitutions) {
final int parameterIndex = headerSubstitution.getMethodParameterIndex();
if (0 <= parameterIndex && parameterIndex < swaggerMethodA... | } else { | public Iterable<HttpHeader> setHeaders(Object[] swaggerMethodArguments) {
final HttpHeaders result = new HttpHeaders(headers);
for (Substitution headerSubstitution : headerSubstitutions) {
final int parameterIndex = headerSubstitution.getMethodParameterIndex();
if (0 <= parameterIndex && parameterIndex < swaggerMethodA... | class SwaggerMethodParser implements HttpResponseDecodeData {
private final SerializerAdapter serializer;
private final String rawHost;
private final String fullyQualifiedMethodName;
private final HttpMethod httpMethod;
private final String relativePath;
private final List<Substitution> hostSubstitutions = new ArrayLis... | class SwaggerMethodParser implements HttpResponseDecodeData {
private final SerializerAdapter serializer;
private final String rawHost;
private final String fullyQualifiedMethodName;
private final HttpMethod httpMethod;
private final String relativePath;
private final List<Substitution> hostSubstitutions = new ArrayLis... |
Is this using the same exception message as credentials in AAD use? It would be nice to turn it into a proper sentence here and file an issue for the other locations. | public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) {
if ("http".equals(context.getHttpRequest().getUrl().getProtocol())) {
return Mono.error(new RuntimeException("token credentials require a URL using the HTTPS protocol scheme"));
}
context.getHttpRequest().setHeader(API_KEY... | return Mono.error(new RuntimeException("token credentials require a URL using the HTTPS protocol scheme")); | public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) {
if ("http".equals(context.getHttpRequest().getUrl().getProtocol())) {
return Mono.error(new RuntimeException("Search api-key credentials require a URL using the HTTPS protocol "
+ "scheme."));
}
context.getHttpRequest().se... | class SearchApiKeyPipelinePolicy implements HttpPipelinePolicy {
private static final String API_KEY = "api-key";
private final SearchApiKeyCredential apiKey;
/**
* Constructor
*
* @param apiKey Azure Cognitive Search service api admin or query key
* @throws IllegalArgumentException when the api key is an empty string
... | class SearchApiKeyPipelinePolicy implements HttpPipelinePolicy {
private static final String API_KEY = "api-key";
private final SearchApiKeyCredential apiKey;
/**
* Constructor
*
* @param apiKey Azure Cognitive Search service api admin or query key
* @throws IllegalArgumentException when the api key is an empty string
... |
Thanks for catching this. | public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) {
if ("http".equals(context.getHttpRequest().getUrl().getProtocol())) {
return Mono.error(new RuntimeException("token credentials require a URL using the HTTPS protocol scheme"));
}
context.getHttpRequest().setHeader(API_KEY... | return Mono.error(new RuntimeException("token credentials require a URL using the HTTPS protocol scheme")); | public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) {
if ("http".equals(context.getHttpRequest().getUrl().getProtocol())) {
return Mono.error(new RuntimeException("Search api-key credentials require a URL using the HTTPS protocol "
+ "scheme."));
}
context.getHttpRequest().se... | class SearchApiKeyPipelinePolicy implements HttpPipelinePolicy {
private static final String API_KEY = "api-key";
private final SearchApiKeyCredential apiKey;
/**
* Constructor
*
* @param apiKey Azure Cognitive Search service api admin or query key
* @throws IllegalArgumentException when the api key is an empty string
... | class SearchApiKeyPipelinePolicy implements HttpPipelinePolicy {
private static final String API_KEY = "api-key";
private final SearchApiKeyCredential apiKey;
/**
* Constructor
*
* @param apiKey Azure Cognitive Search service api admin or query key
* @throws IllegalArgumentException when the api key is an empty string
... |
Is this exception message meant to be the same as the one above? | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
return null;
} else {
String authorityUrl = options.getAuthorityHost().replaceAll("/+$", "") + "/organizations/" + tenant... | "Shared token cache is unavailable in this environment.", null, t)); | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be provided for user ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
The defer isn't needed here. | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
SilentParameters parameters;
SilentParameters forceParameters;
if (account != null) {
parameters = SilentParameters.builder(new HashSet<>(request.getScopes()), account).build();
forceParameters = SilentParameters.builder... | .switchIfEmpty(Mono.defer(() -> Mono.fromFuture(() -> { | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
return Mono.defer(() -> Mono.fromFuture(() -> {
SilentParameters.SilentParametersBuilder parametersBuilder = SilentParameters.builder(
new HashSet<>(request.getScopes()));
if (account != null) {
parametersBuilder = param... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Should this use a future supplier as below? | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
SilentParameters parameters;
SilentParameters forceParameters;
if (account != null) {
parameters = SilentParameters.builder(new HashSet<>(request.getScopes()), account).build();
forceParameters = SilentParameters.builder... | return Mono.fromFuture(getPublicClientApplication(false).acquireTokenSilently(parameters)) | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
return Mono.defer(() -> Mono.fromFuture(() -> {
SilentParameters.SilentParametersBuilder parametersBuilder = SilentParameters.builder(
new HashSet<>(request.getScopes()));
if (account != null) {
parametersBuilder = param... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Does account here have to be non-null? If it can be null, could the if/else block be merged to always pass `account`? | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
SilentParameters parameters;
SilentParameters forceParameters;
if (account != null) {
parameters = SilentParameters.builder(new HashSet<>(request.getScopes()), account).build();
forceParameters = SilentParameters.builder... | parameters = SilentParameters.builder(new HashSet<>(request.getScopes()), account).build(); | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
return Mono.defer(() -> Mono.fromFuture(() -> {
SilentParameters.SilentParametersBuilder parametersBuilder = SilentParameters.builder(
new HashSet<>(request.getScopes()));
if (account != null) {
parametersBuilder = param... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Need to use `Exceptions.propagate` here. | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
SilentParameters parameters;
SilentParameters forceParameters;
if (account != null) {
parameters = SilentParameters.builder(new HashSet<>(request.getScopes()), account).build();
forceParameters = SilentParameters.builder... | throw logger.logExceptionAsWarning(new RuntimeException(e)); | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
return Mono.defer(() -> Mono.fromFuture(() -> {
SilentParameters.SilentParametersBuilder parametersBuilder = SilentParameters.builder(
new HashSet<>(request.getScopes()));
if (account != null) {
parametersBuilder = param... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Removed. | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
SilentParameters parameters;
SilentParameters forceParameters;
if (account != null) {
parameters = SilentParameters.builder(new HashSet<>(request.getScopes()), account).build();
forceParameters = SilentParameters.builder... | .switchIfEmpty(Mono.defer(() -> Mono.fromFuture(() -> { | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
return Mono.defer(() -> Mono.fromFuture(() -> {
SilentParameters.SilentParametersBuilder parametersBuilder = SilentParameters.builder(
new HashSet<>(request.getScopes()));
if (account != null) {
parametersBuilder = param... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Yeah we should | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
SilentParameters parameters;
SilentParameters forceParameters;
if (account != null) {
parameters = SilentParameters.builder(new HashSet<>(request.getScopes()), account).build();
forceParameters = SilentParameters.builder... | return Mono.fromFuture(getPublicClientApplication(false).acquireTokenSilently(parameters)) | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
return Mono.defer(() -> Mono.fromFuture(() -> {
SilentParameters.SilentParametersBuilder parametersBuilder = SilentParameters.builder(
new HashSet<>(request.getScopes()));
if (account != null) {
parametersBuilder = param... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Unfortunately in the first builder overload the account is required to be non-null. | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
SilentParameters parameters;
SilentParameters forceParameters;
if (account != null) {
parameters = SilentParameters.builder(new HashSet<>(request.getScopes()), account).build();
forceParameters = SilentParameters.builder... | parameters = SilentParameters.builder(new HashSet<>(request.getScopes()), account).build(); | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
return Mono.defer(() -> Mono.fromFuture(() -> {
SilentParameters.SilentParametersBuilder parametersBuilder = SilentParameters.builder(
new HashSet<>(request.getScopes()));
if (account != null) {
parametersBuilder = param... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
But it does seem like I can add account afterwards | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
SilentParameters parameters;
SilentParameters forceParameters;
if (account != null) {
parameters = SilentParameters.builder(new HashSet<>(request.getScopes()), account).build();
forceParameters = SilentParameters.builder... | parameters = SilentParameters.builder(new HashSet<>(request.getScopes()), account).build(); | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
return Mono.defer(() -> Mono.fromFuture(() -> {
SilentParameters.SilentParametersBuilder parametersBuilder = SilentParameters.builder(
new HashSet<>(request.getScopes()));
if (account != null) {
parametersBuilder = param... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Reorganized a little bit to avoid creating 2 parameters upfront | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
SilentParameters parameters;
SilentParameters forceParameters;
if (account != null) {
parameters = SilentParameters.builder(new HashSet<>(request.getScopes()), account).build();
forceParameters = SilentParameters.builder... | parameters = SilentParameters.builder(new HashSet<>(request.getScopes()), account).build(); | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
return Mono.defer(() -> Mono.fromFuture(() -> {
SilentParameters.SilentParametersBuilder parametersBuilder = SilentParameters.builder(
new HashSet<>(request.getScopes()));
if (account != null) {
parametersBuilder = param... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
They are indeed the same - just wrapping in different exceptions to be handled differently downstream. | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
return null;
} else {
String authorityUrl = options.getAuthorityHost().replaceAll("/+$", "") + "/organizations/" + tenant... | "Shared token cache is unavailable in this environment.", null, t)); | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be provided for user ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Since you're using futures, it may be easier to follow using: ```java var completableFuture = new CompletableFuture<MsalToken>(); completableFuture.completeExceptionally(logger.logExceptionAsError(Exceptions.propagate(e)); return completableFuture; ``` | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
return Mono.defer(() -> Mono.fromFuture(() -> {
SilentParameters.SilentParametersBuilder parametersBuilder = SilentParameters.builder(
new HashSet<>(request.getScopes()));
if (account != null) {
parametersBuilder = param... | throw logger.logExceptionAsError(Exceptions.propagate(e)); | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
return Mono.defer(() -> Mono.fromFuture(() -> {
SilentParameters.SilentParametersBuilder parametersBuilder = SilentParameters.builder(
new HashSet<>(request.getScopes()));
if (account != null) {
parametersBuilder = param... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
providedfor -> provided for | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be providedfor user a... | "A non-null value for client ID must be providedfor user authentication.")); | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be provided for user ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Thanks Connie for the tip but in this code the exception is thrown from creating the future, not from executing it. | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
return Mono.defer(() -> Mono.fromFuture(() -> {
SilentParameters.SilentParametersBuilder parametersBuilder = SilentParameters.builder(
new HashSet<>(request.getScopes()));
if (account != null) {
parametersBuilder = param... | throw logger.logExceptionAsError(Exceptions.propagate(e)); | public Mono<MsalToken> authenticateWithMsalAccount(TokenRequestContext request, IAccount account) {
return Mono.defer(() -> Mono.fromFuture(() -> {
SilentParameters.SilentParametersBuilder parametersBuilder = SilentParameters.builder(
new HashSet<>(request.getScopes()));
if (account != null) {
parametersBuilder = param... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
This method is called from numerous methods on the IdentityClient some which pass `sharedTokenCacheCredential` as `true` and some as `false`. Whichever calls this method first will cache the publicClientApplication and then all subsequent calls will effectively ignore the `sharedTokenCacheCredential` parameter. I'm gue... | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be provided for user ... | return publicClientApplication; | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be provided for user ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
This is not thread safe. If two clients using the same credential call get token at the same time it's possible that multiple threads attempt to initialize `publicClientApplication` at the same time. In this case they might each get different instances and any tokens cached on any instances other than the final one wil... | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be provided for user ... | this.publicClientApplication = publicClientApplicationBuilder.build(); | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be provided for user ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Opened an issue #10675 | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be provided for user ... | this.publicClientApplication = publicClientApplicationBuilder.build(); | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be provided for user ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Opened an issue #10675 | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be provided for user ... | return publicClientApplication; | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be provided for user ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
Resolving as separate issues opened | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be provided for user ... | this.publicClientApplication = publicClientApplicationBuilder.build(); | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be provided for user ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
This method is only called once per IdentityClient and there's exactly one IdentityClient instance per credential. Yes it can have nicer designs, as something we can do for #10675 | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be provided for user ... | return publicClientApplication; | private PublicClientApplication getPublicClientApplication(boolean sharedTokenCacheCredential) {
if (publicClientApplication != null) {
return publicClientApplication;
} else if (clientId == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"A non-null value for client ID must be provided for user ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... | class IdentityClient {
private static final SerializerAdapter SERIALIZER_ADAPTER = JacksonAdapter.createDefaultSerializerAdapter();
private static final Random RANDOM = new Random();
private static final String WINDOWS_STARTER = "cmd.exe";
private static final String LINUX_MAC_STARTER = "/bin/sh";
private static final ... |
I assume this is better for perf since we don't allocate a new array every time? | public Mono<Void> runAsync() {
return blobAsyncClient.download()
.map(b -> {
for (int i = 0; i < b.remaining(); i++) {
b.get();
}
return 1;
}).then();
} | for (int i = 0; i < b.remaining(); i++) { | public Mono<Void> runAsync() {
return blobAsyncClient.download()
.map(b -> {
for (int i = 0; i < b.remaining(); i++) {
b.get();
}
return 1;
}).then();
} | class NullOutputStream extends OutputStream {
@Override
public void write(int b) throws IOException {
}
} | class NullOutputStream extends OutputStream {
@Override
public void write(int b) throws IOException {
}
} |
Should be better for perf since we don't create new flux every iteration. | public Mono<Void> runAsync() {
return blobAsyncClient.upload(randomByteBufferFlux, null, true).then();
} | return blobAsyncClient.upload(randomByteBufferFlux, null, true).then(); | public Mono<Void> runAsync() {
return blobAsyncClient.upload(randomByteBufferFlux, null, true).then();
} | class UploadBlobTest extends BlobTestBase<PerfStressOptions> {
private final Flux<ByteBuffer> randomByteBufferFlux;
public UploadBlobTest(PerfStressOptions options) {
super(options);
this.randomByteBufferFlux = createRandomByteBufferFlux(options.getSize());
}
@Override
public void run() {
throw new UnsupportedOperation... | class UploadBlobTest extends BlobTestBase<PerfStressOptions> {
private final Flux<ByteBuffer> randomByteBufferFlux;
public UploadBlobTest(PerfStressOptions options) {
super(options);
this.randomByteBufferFlux = createRandomByteBufferFlux(options.getSize());
}
@Override
public void run() {
throw new UnsupportedOperation... |
Though is it safe to reuse the same flux for each iteration? Or is the flux "used up" after the first upload so we would need to create a new one every time? | public Mono<Void> runAsync() {
return blobAsyncClient.upload(randomByteBufferFlux, null, true).then();
} | return blobAsyncClient.upload(randomByteBufferFlux, null, true).then(); | public Mono<Void> runAsync() {
return blobAsyncClient.upload(randomByteBufferFlux, null, true).then();
} | class UploadBlobTest extends BlobTestBase<PerfStressOptions> {
private final Flux<ByteBuffer> randomByteBufferFlux;
public UploadBlobTest(PerfStressOptions options) {
super(options);
this.randomByteBufferFlux = createRandomByteBufferFlux(options.getSize());
}
@Override
public void run() {
throw new UnsupportedOperation... | class UploadBlobTest extends BlobTestBase<PerfStressOptions> {
private final Flux<ByteBuffer> randomByteBufferFlux;
public UploadBlobTest(PerfStressOptions options) {
super(options);
this.randomByteBufferFlux = createRandomByteBufferFlux(options.getSize());
}
@Override
public void run() {
throw new UnsupportedOperation... |
yep, memory pressure is reduced. | public Mono<Void> runAsync() {
return blobAsyncClient.download()
.map(b -> {
for (int i = 0; i < b.remaining(); i++) {
b.get();
}
return 1;
}).then();
} | for (int i = 0; i < b.remaining(); i++) { | public Mono<Void> runAsync() {
return blobAsyncClient.download()
.map(b -> {
for (int i = 0; i < b.remaining(); i++) {
b.get();
}
return 1;
}).then();
} | class NullOutputStream extends OutputStream {
@Override
public void write(int b) throws IOException {
}
} | class NullOutputStream extends OutputStream {
@Override
public void write(int b) throws IOException {
}
} |
Yes, this reduces memory pressure as we don't really need to copy the data, just reading is sufficient. | public Mono<Void> runAsync() {
return blobAsyncClient.download()
.map(b -> {
for (int i = 0; i < b.remaining(); i++) {
b.get();
}
return 1;
}).then();
} | for (int i = 0; i < b.remaining(); i++) { | public Mono<Void> runAsync() {
return blobAsyncClient.download()
.map(b -> {
for (int i = 0; i < b.remaining(); i++) {
b.get();
}
return 1;
}).then();
} | class NullOutputStream extends OutputStream {
@Override
public void write(int b) throws IOException {
}
} | class NullOutputStream extends OutputStream {
@Override
public void write(int b) throws IOException {
}
} |
Yeah, tested it by using the same flux to read multiple times. Same data was returned each time. | public Mono<Void> runAsync() {
return blobAsyncClient.upload(randomByteBufferFlux, null, true).then();
} | return blobAsyncClient.upload(randomByteBufferFlux, null, true).then(); | public Mono<Void> runAsync() {
return blobAsyncClient.upload(randomByteBufferFlux, null, true).then();
} | class UploadBlobTest extends BlobTestBase<PerfStressOptions> {
private final Flux<ByteBuffer> randomByteBufferFlux;
public UploadBlobTest(PerfStressOptions options) {
super(options);
this.randomByteBufferFlux = createRandomByteBufferFlux(options.getSize());
}
@Override
public void run() {
throw new UnsupportedOperation... | class UploadBlobTest extends BlobTestBase<PerfStressOptions> {
private final Flux<ByteBuffer> randomByteBufferFlux;
public UploadBlobTest(PerfStressOptions options) {
super(options);
this.randomByteBufferFlux = createRandomByteBufferFlux(options.getSize());
}
@Override
public void run() {
throw new UnsupportedOperation... |
Would it also work with a static flux, if multiple instances were reading in parallel? Or does it need to be an instance flux, so it can be reused across iterations, but each instance needs its own copy? Shouldn't matter much for perf either way, but I like to scope variables correctly to increase understanding of th... | public Mono<Void> runAsync() {
return blobAsyncClient.upload(randomByteBufferFlux, null, true).then();
} | return blobAsyncClient.upload(randomByteBufferFlux, null, true).then(); | public Mono<Void> runAsync() {
return blobAsyncClient.upload(randomByteBufferFlux, null, true).then();
} | class UploadBlobTest extends BlobTestBase<PerfStressOptions> {
private final Flux<ByteBuffer> randomByteBufferFlux;
public UploadBlobTest(PerfStressOptions options) {
super(options);
this.randomByteBufferFlux = createRandomByteBufferFlux(options.getSize());
}
@Override
public void run() {
throw new UnsupportedOperation... | class UploadBlobTest extends BlobTestBase<PerfStressOptions> {
private final Flux<ByteBuffer> randomByteBufferFlux;
public UploadBlobTest(PerfStressOptions options) {
super(options);
this.randomByteBufferFlux = createRandomByteBufferFlux(options.getSize());
}
@Override
public void run() {
throw new UnsupportedOperation... |
It could have been static if the since of the buffer was fixed. Since the size is determined by the options provided in the constructor, I have made this an instance flux. However, as we discussed, we could make this static and initialize in `globalSetup()` as the options are not going to change for a run and all insta... | public Mono<Void> runAsync() {
return blobAsyncClient.upload(randomByteBufferFlux, null, true).then();
} | return blobAsyncClient.upload(randomByteBufferFlux, null, true).then(); | public Mono<Void> runAsync() {
return blobAsyncClient.upload(randomByteBufferFlux, null, true).then();
} | class UploadBlobTest extends BlobTestBase<PerfStressOptions> {
private final Flux<ByteBuffer> randomByteBufferFlux;
public UploadBlobTest(PerfStressOptions options) {
super(options);
this.randomByteBufferFlux = createRandomByteBufferFlux(options.getSize());
}
@Override
public void run() {
throw new UnsupportedOperation... | class UploadBlobTest extends BlobTestBase<PerfStressOptions> {
private final Flux<ByteBuffer> randomByteBufferFlux;
public UploadBlobTest(PerfStressOptions options) {
super(options);
this.randomByteBufferFlux = createRandomByteBufferFlux(options.getSize());
}
@Override
public void run() {
throw new UnsupportedOperation... |
Could we use `!field.getValue().isNull()`? | public PatternAnalyzer deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.readTree(p);
Iterator<Map.Entry<String, JsonNode>> fields = root.fields();
PatternAnalyzer analyzer = new PatternAnalyzer();
while (fields.has... | } else if ("flags".equals(field.getKey()) && !"null".equals(field.getValue().asText())) { | public PatternAnalyzer deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.readTree(p);
Iterator<Map.Entry<String, JsonNode>> fields = root.fields();
PatternAnalyzer analyzer = new PatternAnalyzer();
while (fields.has... | class CustomPatternAnalyzerDeserializer extends JsonDeserializer<PatternAnalyzer> {
private static final String DELIMITER = "\\|";
/**
* {@inheritDoc}
*/
@Override
} | class CustomPatternAnalyzerDeserializer extends JsonDeserializer<PatternAnalyzer> {
private static final String DELIMITER = "\\|";
/**
* {@inheritDoc}
*/
@Override
} |
Do we have concern that `asInt` will return `int`'s default of 0 if the JSON value is `null`? | public PatternTokenizer deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.readTree(p);
Iterator<Map.Entry<String, JsonNode>> fields = root.fields();
PatternTokenizer tokenizer = new PatternTokenizer();
while (fields... | tokenizer.setGroup(field.getValue().asInt()); | public PatternTokenizer deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.readTree(p);
Iterator<Map.Entry<String, JsonNode>> fields = root.fields();
PatternTokenizer tokenizer = new PatternTokenizer();
while (fields... | class CustomPatternTokenizerDeserializer extends JsonDeserializer<PatternTokenizer> {
private static final String DELIMITER = "\\|";
/**
* {@inheritDoc}
*/
@Override
} | class CustomPatternTokenizerDeserializer extends JsonDeserializer<PatternTokenizer> {
private static final String DELIMITER = "\\|";
/**
* {@inheritDoc}
*/
@Override
} |
`!field.getValue().isNull()` | public PatternTokenizer deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.readTree(p);
Iterator<Map.Entry<String, JsonNode>> fields = root.fields();
PatternTokenizer tokenizer = new PatternTokenizer();
while (fields... | } else if ("flags".equals(field.getKey()) && !"null".equals(field.getValue().asText())) { | public PatternTokenizer deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.readTree(p);
Iterator<Map.Entry<String, JsonNode>> fields = root.fields();
PatternTokenizer tokenizer = new PatternTokenizer();
while (fields... | class CustomPatternTokenizerDeserializer extends JsonDeserializer<PatternTokenizer> {
private static final String DELIMITER = "\\|";
/**
* {@inheritDoc}
*/
@Override
} | class CustomPatternTokenizerDeserializer extends JsonDeserializer<PatternTokenizer> {
private static final String DELIMITER = "\\|";
/**
* {@inheritDoc}
*/
@Override
} |
Don't know if the service would return this. | public PatternTokenizer deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.readTree(p);
Iterator<Map.Entry<String, JsonNode>> fields = root.fields();
PatternTokenizer tokenizer = new PatternTokenizer();
while (fields... | tokenizer.setGroup(field.getValue().asInt()); | public PatternTokenizer deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.readTree(p);
Iterator<Map.Entry<String, JsonNode>> fields = root.fields();
PatternTokenizer tokenizer = new PatternTokenizer();
while (fields... | class CustomPatternTokenizerDeserializer extends JsonDeserializer<PatternTokenizer> {
private static final String DELIMITER = "\\|";
/**
* {@inheritDoc}
*/
@Override
} | class CustomPatternTokenizerDeserializer extends JsonDeserializer<PatternTokenizer> {
private static final String DELIMITER = "\\|";
/**
* {@inheritDoc}
*/
@Override
} |
"null" is a string type in json | public PatternAnalyzer deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.readTree(p);
Iterator<Map.Entry<String, JsonNode>> fields = root.fields();
PatternAnalyzer analyzer = new PatternAnalyzer();
while (fields.has... | } else if ("flags".equals(field.getKey()) && !"null".equals(field.getValue().asText())) { | public PatternAnalyzer deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.readTree(p);
Iterator<Map.Entry<String, JsonNode>> fields = root.fields();
PatternAnalyzer analyzer = new PatternAnalyzer();
while (fields.has... | class CustomPatternAnalyzerDeserializer extends JsonDeserializer<PatternAnalyzer> {
private static final String DELIMITER = "\\|";
/**
* {@inheritDoc}
*/
@Override
} | class CustomPatternAnalyzerDeserializer extends JsonDeserializer<PatternAnalyzer> {
private static final String DELIMITER = "\\|";
/**
* {@inheritDoc}
*/
@Override
} |
It is a string type in json: `{"flags": "null"} ` what `field.getValue()`parse out here is "null". That's why I check it like this. | public PatternTokenizer deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.readTree(p);
Iterator<Map.Entry<String, JsonNode>> fields = root.fields();
PatternTokenizer tokenizer = new PatternTokenizer();
while (fields... | } else if ("flags".equals(field.getKey()) && !"null".equals(field.getValue().asText())) { | public PatternTokenizer deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.readTree(p);
Iterator<Map.Entry<String, JsonNode>> fields = root.fields();
PatternTokenizer tokenizer = new PatternTokenizer();
while (fields... | class CustomPatternTokenizerDeserializer extends JsonDeserializer<PatternTokenizer> {
private static final String DELIMITER = "\\|";
/**
* {@inheritDoc}
*/
@Override
} | class CustomPatternTokenizerDeserializer extends JsonDeserializer<PatternTokenizer> {
private static final String DELIMITER = "\\|";
/**
* {@inheritDoc}
*/
@Override
} |
Based on the test of null group, service does not return group back if it is null. | public PatternTokenizer deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.readTree(p);
Iterator<Map.Entry<String, JsonNode>> fields = root.fields();
PatternTokenizer tokenizer = new PatternTokenizer();
while (fields... | tokenizer.setGroup(field.getValue().asInt()); | public PatternTokenizer deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.readTree(p);
Iterator<Map.Entry<String, JsonNode>> fields = root.fields();
PatternTokenizer tokenizer = new PatternTokenizer();
while (fields... | class CustomPatternTokenizerDeserializer extends JsonDeserializer<PatternTokenizer> {
private static final String DELIMITER = "\\|";
/**
* {@inheritDoc}
*/
@Override
} | class CustomPatternTokenizerDeserializer extends JsonDeserializer<PatternTokenizer> {
private static final String DELIMITER = "\\|";
/**
* {@inheritDoc}
*/
@Override
} |
Update : The service team intends to have additional keys added in between service updates. So to ensure this remains consistent the additional keys would be grouped into the `Map<String, FieldValue> extractedFields` [here]() and with proceeding client upgrades would be converted to strongly typed fields. | static IterableStream<ExtractedReceipt> toReceipt(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResult = analyzeResult.getDocumentResults();
List<ExtractedReceipt> extractedReceiptList = new ArrayList<>();
for (int ... | break; | static IterableStream<ExtractedReceipt> toReceipt(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResult = analyzeResult.getDocumentResults();
List<ExtractedReceipt> extractedReceiptList = new ArrayList<>();
for (int ... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern COMPILE = Pattern.compile("[^0-9]+");
private Transforms() {
}
private static FieldValue<?> setFieldValue(com.azure.ai.formrecognizer.implementation.models.FieldValue fieldValue,
List<ReadResul... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern COMPILE = Pattern.compile("[^0-9]+");
private Transforms() {
}
/**
* Helper method to convert the {@link com.azure.ai.formrecognizer.implementation.models.AnalyzeOperationResult}
* service leve... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.