comment stringlengths 1 45k | method_body stringlengths 23 281k | target_code stringlengths 0 5.16k | method_body_after stringlengths 12 281k | context_before stringlengths 8 543k | context_after stringlengths 8 543k |
|---|---|---|---|---|---|
same as [this](https://github.com/Azure/azure-sdk-for-java/pull/5061#discussion_r317320920) doOnEach should help wait till an item is emitted with success or error signal. | private void receiveEvents(PartitionOwnership partitionOwnership) {
EventHubConsumerOptions consumerOptions = new EventHubConsumerOptions();
consumerOptions.ownerLevel(0L);
EventPosition startFromEventPosition = partitionOwnership.sequenceNumber() == null ? this.initialEventPosition
: EventPosition.fromSequenceNumber(p... | partitionProcessor.processEvent(eventData).subscribe(unused -> { | private void receiveEvents(PartitionOwnership partitionOwnership) {
EventHubConsumerOptions consumerOptions = new EventHubConsumerOptions();
consumerOptions.ownerLevel(0L);
EventPosition startFromEventPosition = partitionOwnership.sequenceNumber() == null ? this.initialEventPosition
: EventPosition.fromSequenceNumber(p... | class EventProcessor {
private static final long INTERVAL_IN_SECONDS = 10;
private static final long INITIAL_DELAY = 0;
private static final long OWNERSHIP_EXPIRATION_TIME_IN_MILLIS = TimeUnit.SECONDS.toMillis(30);
private final ClientLogger logger = new ClientLogger(EventProcessor.class);
private final EventHubAsyncCl... | class EventProcessor {
private static final long INTERVAL_IN_SECONDS = 10;
private static final long INITIAL_DELAY = 0;
private static final long OWNERSHIP_EXPIRATION_TIME_IN_MILLIS = TimeUnit.SECONDS.toMillis(30);
private final ClientLogger logger = new ClientLogger(EventProcessor.class);
private final EventHubAsyncCl... |
I don't think there is a case where tracerProvider will ever be null because EventHubClientBuilder always returns a new instance of TracerProvider. You should just add a method in TracerProvider.isEnabled(). And see if there are any tracers that are passed in. | private Mono<Void> sendInternal(Flux<EventData> events, SendOptions options) {
final String partitionKey = options.partitionKey();
verifyPartitionKey(partitionKey);
if (tracerProvider != null) {
return sendInternalTracingEnabled(events, partitionKey);
} else {
return sendInternalTracingDisabled(events, partitionKey);
}... | if (tracerProvider != null) { | private Mono<Void> sendInternal(Flux<EventData> events, SendOptions options) {
final String partitionKey = options.partitionKey();
verifyPartitionKey(partitionKey);
if (tracerProvider.isEnabled()) {
return sendInternalTracingEnabled(events, partitionKey);
} else {
return sendInternalTracingDisabled(events, partitionKey... | class EventHubAsyncProducer implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
/**
* The default maximum allowable size, in bytes, for a batch to be sent.
*/
public static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOption... | class EventHubAsyncProducer implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
/**
* The default maximum allowable size, in bytes, for a batch to be sent.
*/
public static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOption... |
```suggestion this.tracers = Objects.requireNotNull(tracers, "'tracers' cannot be null."); ``` | public TracerProvider(Iterable<Tracer> tracers) {
this.tracers = tracers;
} | this.tracers = tracers; | public TracerProvider(Iterable<Tracer> tracers) {
Objects.requireNonNull(tracers, "'tracers' cannot be null.");
tracers.forEach(e -> this.tracers.add(e));
} | class TracerProvider {
private final Iterable<Tracer> tracers;
/**
* For each tracer plugged into the SDK a new tracing span is created.
*
* The {@code context} will be checked for containing information about a parent span. If a parent span is found the
* new span will be added as a child, otherwise the span will be c... | class TracerProvider {
private final ClientLogger logger = new ClientLogger(TracerProvider.class);
private final List<Tracer> tracers = new ArrayList<>();
public boolean isEnabled() {
return tracers.size() > 0;
}
/**
* For each tracer plugged into the SDK a new tracing span is created.
*
* The {@code context} will be c... |
I'd add null checks Objects.requireNotNull in these public methods. If someone a null context is passed in, we'll get a nice error message rather than an NPE when the method tries to invoke a method on it. Similar to the public methods below. | public Context startSpan(Context context, ProcessKind processKind) {
Context local = context;
String spanName = "Azure.eventhubs." + processKind.getProcessKind();
for (Tracer tracer : tracers) {
local = tracer.start(spanName, local, processKind);
}
return local;
} | Context local = context; | public Context startSpan(Context context, ProcessKind processKind) {
Context local = Objects.requireNonNull(context, "'context' cannot be null");
Objects.requireNonNull(processKind, "'processKind' cannot be null");
String spanName = getSpanName(processKind);
for (Tracer tracer : tracers) {
local = tracer.start(spanName... | class TracerProvider {
private final Iterable<Tracer> tracers;
public TracerProvider(Iterable<Tracer> tracers) {
this.tracers = tracers;
}
/**
* For each tracer plugged into the SDK a new tracing span is created.
*
* The {@code context} will be checked for containing information about a parent span. If a parent span is... | class TracerProvider {
private final ClientLogger logger = new ClientLogger(TracerProvider.class);
private final List<Tracer> tracers = new ArrayList<>();
public TracerProvider(Iterable<Tracer> tracers) {
Objects.requireNonNull(tracers, "'tracers' cannot be null.");
tracers.forEach(e -> this.tracers.add(e));
}
public b... |
I'd move this declaration to line 60. This variable doesn't need to be allocated until after those checks are completed. | public void endSpan(Context context, Signal<Void> signal) {
String errorCondition = "";
if (!context.getData(OPENTELEMETRY_SPAN_KEY).isPresent()) {
return;
}
if (signal == null) {
end("success", null, context);
}
Throwable throwable = null;
if (signal != null && signal.hasError()) {
throwable = signal.getThrowable();
i... | String errorCondition = ""; | public void endSpan(Context context, Signal<Void> signal) {
Objects.requireNonNull(context, "'context' cannot be null");
Objects.requireNonNull(signal, "'signal' cannot be null");
if (!context.getData(OPENTELEMETRY_SPAN_KEY).isPresent()) {
return;
}
switch (signal.getType()) {
case ON_COMPLETE:
end("success", null, con... | class TracerProvider {
private final Iterable<Tracer> tracers;
public TracerProvider(Iterable<Tracer> tracers) {
this.tracers = tracers;
}
/**
* For each tracer plugged into the SDK a new tracing span is created.
*
* The {@code context} will be checked for containing information about a parent span. If a parent span is... | class TracerProvider {
private final ClientLogger logger = new ClientLogger(TracerProvider.class);
private final List<Tracer> tracers = new ArrayList<>();
public TracerProvider(Iterable<Tracer> tracers) {
Objects.requireNonNull(tracers, "'tracers' cannot be null.");
tracers.forEach(e -> this.tracers.add(e));
}
public b... |
I don't know if Srikanta's comment was resolved. Isn't the context only resolved for the last tracer? | public Context extractContext(String diagnosticId, Context context) {
Context local = context;
for (Tracer tracer : tracers) {
local = tracer.extractContext(diagnosticId, context);
}
return local;
} | local = tracer.extractContext(diagnosticId, context); | public Context extractContext(String diagnosticId, Context context) {
Context local = Objects.requireNonNull(context, "'context' cannot be null");
Objects.requireNonNull(diagnosticId, "'diagnosticId' cannot be null");
for (Tracer tracer : tracers) {
local = tracer.extractContext(diagnosticId, local);
}
return local;
} | class TracerProvider {
private final Iterable<Tracer> tracers;
public TracerProvider(Iterable<Tracer> tracers) {
this.tracers = tracers;
}
/**
* For each tracer plugged into the SDK a new tracing span is created.
*
* The {@code context} will be checked for containing information about a parent span. If a parent span is... | class TracerProvider {
private final ClientLogger logger = new ClientLogger(TracerProvider.class);
private final List<Tracer> tracers = new ArrayList<>();
public TracerProvider(Iterable<Tracer> tracers) {
Objects.requireNonNull(tracers, "'tracers' cannot be null.");
tracers.forEach(e -> this.tracers.add(e));
}
public b... |
You don't need to specify `this.` | public EventHubAsyncProducer createProducer(EventHubProducerOptions options) {
Objects.requireNonNull(options);
final EventHubProducerOptions clonedOptions = options.clone();
if (clonedOptions.retry() == null) {
clonedOptions.retry(connectionOptions.retry());
}
final String entityPath;
final String linkName;
if (ImplUt... | return new EventHubAsyncProducer(amqpLinkMono, clonedOptions, this.tracerProvider); | public EventHubAsyncProducer createProducer(EventHubProducerOptions options) {
Objects.requireNonNull(options, "'options' cannot be null.");
final EventHubProducerOptions clonedOptions = options.clone();
if (clonedOptions.retry() == null) {
clonedOptions.retry(connectionOptions.retry());
}
final String entityPath;
fina... | class EventHubAsyncClient implements Closeable {
/**
* The name of the default consumer group in the Event Hubs service.
*/
public static final String DEFAULT_CONSUMER_GROUP_NAME = "$Default";
private static final String RECEIVER_ENTITY_PATH_FORMAT = "%s/ConsumerGroups/%s/Partitions/%s";
private static final String SEN... | class EventHubAsyncClient implements Closeable {
/**
* The name of the default consumer group in the Event Hubs service.
*/
public static final String DEFAULT_CONSUMER_GROUP_NAME = "$Default";
private static final String RECEIVER_ENTITY_PATH_FORMAT = "%s/ConsumerGroups/%s/Partitions/%s";
private static final String SEN... |
I try not to specify `this.` unless I'm in a constructor or there is a variable name collision in a method. Otherwise, it is verbose without adding additional information, imho (we don't have any spec around this). | public EventHubAsyncProducer createProducer(EventHubProducerOptions options) {
Objects.requireNonNull(options);
final EventHubProducerOptions clonedOptions = options.clone();
if (clonedOptions.retry() == null) {
clonedOptions.retry(connectionOptions.retry());
}
final String entityPath;
final String linkName;
if (ImplUt... | return new EventHubAsyncProducer(amqpLinkMono, clonedOptions, this.tracerProvider); | public EventHubAsyncProducer createProducer(EventHubProducerOptions options) {
Objects.requireNonNull(options, "'options' cannot be null.");
final EventHubProducerOptions clonedOptions = options.clone();
if (clonedOptions.retry() == null) {
clonedOptions.retry(connectionOptions.retry());
}
final String entityPath;
fina... | class EventHubAsyncClient implements Closeable {
/**
* The name of the default consumer group in the Event Hubs service.
*/
public static final String DEFAULT_CONSUMER_GROUP_NAME = "$Default";
private static final String RECEIVER_ENTITY_PATH_FORMAT = "%s/ConsumerGroups/%s/Partitions/%s";
private static final String SEN... | class EventHubAsyncClient implements Closeable {
/**
* The name of the default consumer group in the Event Hubs service.
*/
public static final String DEFAULT_CONSUMER_GROUP_NAME = "$Default";
private static final String RECEIVER_ENTITY_PATH_FORMAT = "%s/ConsumerGroups/%s/Partitions/%s";
private static final String SEN... |
for every single event you are setting the `sendSpanContext` AtomicReference? Isn't it just the 1st event you want to do this for? | private Mono<Void> sendInternal(Flux<EventData> events, SendOptions options) {
final String partitionKey = options.partitionKey();
verifyPartitionKey(partitionKey);
return sendLinkMono.flatMap(link -> {
final AtomicReference<Context> sendSpanContext = new AtomicReference<>(Context.NONE);
return link.getLinkSize()
.flat... | sendSpanContext.set(tracerProvider.startSpan(entityContext.addData(HOST_NAME, link.getHostname()), ProcessKind.SEND)); | private Mono<Void> sendInternal(Flux<EventData> events, SendOptions options) {
final String partitionKey = options.partitionKey();
verifyPartitionKey(partitionKey);
if (tracerProvider.isEnabled()) {
return sendInternalTracingEnabled(events, partitionKey);
} else {
return sendInternalTracingDisabled(events, partitionKey... | class EventHubAsyncProducer implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
/**
* The default maximum allowable size, in bytes, for a batch to be sent.
*/
public static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOption... | class EventHubAsyncProducer implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
/**
* The default maximum allowable size, in bytes, for a batch to be sent.
*/
public static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOption... |
TODOs show up in IDE when you use the format: ```java // TODO (samvaity): not supported in Opencensus yet // builder.addLink((Context)eventContextData.get()); ``` | private EventData setSpanContext(EventData event, Context parentContext) {
Optional<Object> eventContextData = event.context().getData(SPAN_CONTEXT);
if (eventContextData.isPresent()) {
tracerProvider.addSpanLinks((Context) eventContextData.get());
return event;
} else {
Context eventSpanContext = tracerProvider.startS... | private EventData setSpanContext(EventData event, Context parentContext) {
Optional<Object> eventContextData = event.context().getData(SPAN_CONTEXT);
if (eventContextData.isPresent()) {
Object spanContextObject = eventContextData.get();
if (spanContextObject instanceof Context) {
tracerProvider.addSpanLinks((Context) e... | class EventHubAsyncProducer implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
/**
* The default maximum allowable size, in bytes, for a batch to be sent.
*/
public static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOption... | class EventHubAsyncProducer implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
/**
* The default maximum allowable size, in bytes, for a batch to be sent.
*/
public static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOption... | |
I'd add a check that `eventContextData.get()` is also `instanceof Context` to be defensive. Having an invalid cast exception that crashes the program isn't fun. But logger/error handling would surface errors gracefully. | private EventData setSpanContext(EventData event, Context parentContext) {
Optional<Object> eventContextData = event.context().getData(SPAN_CONTEXT);
if (eventContextData.isPresent()) {
tracerProvider.addSpanLinks((Context) eventContextData.get());
return event;
} else {
Context eventSpanContext = tracerProvider.startS... | tracerProvider.addSpanLinks((Context) eventContextData.get()); | private EventData setSpanContext(EventData event, Context parentContext) {
Optional<Object> eventContextData = event.context().getData(SPAN_CONTEXT);
if (eventContextData.isPresent()) {
Object spanContextObject = eventContextData.get();
if (spanContextObject instanceof Context) {
tracerProvider.addSpanLinks((Context) e... | class EventHubAsyncProducer implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
/**
* The default maximum allowable size, in bytes, for a batch to be sent.
*/
public static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOption... | class EventHubAsyncProducer implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
/**
* The default maximum allowable size, in bytes, for a batch to be sent.
*/
public static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOption... |
Since this value `eventSpanContext.getData(DIAGNOSTIC_ID_KEY)` is used multiple times, create a local variable for it. It helps with readability and in some magical case that the value gets updated between reads. | private EventData setSpanContext(EventData event, Context parentContext) {
Optional<Object> eventContextData = event.context().getData(SPAN_CONTEXT);
if (eventContextData.isPresent()) {
tracerProvider.addSpanLinks((Context) eventContextData.get());
return event;
} else {
Context eventSpanContext = tracerProvider.startS... | if (eventSpanContext != null && eventSpanContext.getData(DIAGNOSTIC_ID_KEY).isPresent()) { | private EventData setSpanContext(EventData event, Context parentContext) {
Optional<Object> eventContextData = event.context().getData(SPAN_CONTEXT);
if (eventContextData.isPresent()) {
Object spanContextObject = eventContextData.get();
if (spanContextObject instanceof Context) {
tracerProvider.addSpanLinks((Context) e... | class EventHubAsyncProducer implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
/**
* The default maximum allowable size, in bytes, for a batch to be sent.
*/
public static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOption... | class EventHubAsyncProducer implements Closeable {
private static final int MAX_PARTITION_KEY_LENGTH = 128;
/**
* The default maximum allowable size, in bytes, for a batch to be sent.
*/
public static final int MAX_MESSAGE_LENGTH_BYTES = 256 * 1024;
private static final SendOptions DEFAULT_SEND_OPTIONS = new SendOption... |
Move this before line 83. Then you don't need those return statements in your cases and replace with break instead. You can have default: with a break statement. | public void endSpan(Context context, Signal<Void> signal) {
Objects.requireNonNull(context, "'context' cannot be null");
Objects.requireNonNull(signal, "'signal' cannot be null");
if (!context.getData(OPENTELEMETRY_SPAN_KEY).isPresent()) {
return;
}
String errorCondition;
Throwable throwable;
switch (signal.getType()) ... | end(errorCondition, throwable, context); | public void endSpan(Context context, Signal<Void> signal) {
Objects.requireNonNull(context, "'context' cannot be null");
Objects.requireNonNull(signal, "'signal' cannot be null");
if (!context.getData(OPENTELEMETRY_SPAN_KEY).isPresent()) {
return;
}
switch (signal.getType()) {
case ON_COMPLETE:
end("success", null, con... | class TracerProvider {
private final List<Tracer> tracers;
public TracerProvider(List<Tracer> tracers) {
this.tracers = Objects.requireNonNull(tracers);
}
public boolean isEnabled() {
return tracers.size() > 0;
}
/**
* For each tracer plugged into the SDK a new tracing span is created.
*
* The {@code context} will be c... | class TracerProvider {
private final ClientLogger logger = new ClientLogger(TracerProvider.class);
private final List<Tracer> tracers = new ArrayList<>();
public TracerProvider(Iterable<Tracer> tracers) {
Objects.requireNonNull(tracers, "'tracers' cannot be null.");
tracers.forEach(e -> this.tracers.add(e));
}
public b... |
In your verify, you explicitly type out "ampq:not-found". if we decide to change this amqp error condition string in the future, it'll break this test. It's better to do something like: ```java final ErrorCondition condition = ErrorCondition.NOT_FOUND; final Exception exception = new AmqpException(true, condition, "",... | public void endSpanAmqpException() {
final Tracer tracer1 = mock(Tracer.class);
List<Tracer> tracers = Arrays.asList(tracer1);
final TracerProvider tracerProvider = new TracerProvider(tracers);
final Exception exception = new AmqpException(true, ErrorCondition.NOT_FOUND, "", null);
Context sendContext = new Context(OPE... | final Exception exception = new AmqpException(true, ErrorCondition.NOT_FOUND, "", null); | public void endSpanAmqpException() {
final ErrorCondition errorCondition = ErrorCondition.NOT_FOUND;
final Exception exception = new AmqpException(true, errorCondition, "", null);
Context sendContext = new Context(OPENTELEMETRY_SPAN_KEY, "value");
tracerProvider.endSpan(sendContext, Signal.error(exception));
for (Trace... | class TracerProviderTest {
@Test
public void startSpan() {
final Tracer tracer1 = mock(Tracer.class);
List<Tracer> tracers = Arrays.asList(tracer1);
final TracerProvider tracerProvider = new TracerProvider(tracers);
Context updatedContext = tracerProvider.startSpan(Context.NONE, ProcessKind.SEND);
verify(tracer1, times... | class TracerProviderTest {
private static final String METHOD_NAME = "Azure.eventhubs.send";
@Mock
private Tracer tracer;
@Mock
private Tracer tracer2;
private List<Tracer> tracers;
private TracerProvider tracerProvider;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
tracers = Arrays.asList(tracer, t... |
These variables don't need to be created here. They are only used in the ON_ERROR case. | public void endSpan(Context context, Signal<Void> signal) {
Objects.requireNonNull(context, "'context' cannot be null");
Objects.requireNonNull(signal, "'signal' cannot be null");
if (!context.getData(OPENTELEMETRY_SPAN_KEY).isPresent()) {
return;
}
String errorCondition;
Throwable throwable;
switch (signal.getType()) ... | String errorCondition; | public void endSpan(Context context, Signal<Void> signal) {
Objects.requireNonNull(context, "'context' cannot be null");
Objects.requireNonNull(signal, "'signal' cannot be null");
if (!context.getData(OPENTELEMETRY_SPAN_KEY).isPresent()) {
return;
}
switch (signal.getType()) {
case ON_COMPLETE:
end("success", null, con... | class TracerProvider {
private final List<Tracer> tracers = new ArrayList<>();
public TracerProvider(Iterable<Tracer> tracers) {
Objects.requireNonNull(tracers, "'tracers' cannot be null.");
tracers.forEach(e -> this.tracers.add(e));
}
public boolean isEnabled() {
return tracers.size() > 0;
}
/**
* For each tracer plug... | class TracerProvider {
private final ClientLogger logger = new ClientLogger(TracerProvider.class);
private final List<Tracer> tracers = new ArrayList<>();
public TracerProvider(Iterable<Tracer> tracers) {
Objects.requireNonNull(tracers, "'tracers' cannot be null.");
tracers.forEach(e -> this.tracers.add(e));
}
public b... |
we should consider making these as defined constants. | private String getPartitionLeasePrefix() {
return this.settings.getContainerNamePrefix() + "..";
} | return this.settings.getContainerNamePrefix() + ".."; | private String getPartitionLeasePrefix() {
return this.settings.getContainerNamePrefix() + LEASE_STORE_MANAGER_LEASE_SUFFIX;
} | class LeaseStoreManagerImpl implements LeaseStoreManager, LeaseStoreManager.LeaseStoreManagerBuilderDefinition {
private final Logger logger = LoggerFactory.getLogger(LeaseStoreManagerImpl.class);
private LeaseStoreManagerSettings settings;
private ChangeFeedContextClient leaseDocumentClient;
private RequestOptionsFact... | class LeaseStoreManagerImpl implements LeaseStoreManager, LeaseStoreManager.LeaseStoreManagerBuilderDefinition {
private final String LEASE_STORE_MANAGER_LEASE_SUFFIX = "..";
private final Logger logger = LoggerFactory.getLogger(LeaseStoreManagerImpl.class);
private LeaseStoreManagerSettings settings;
private ChangeFee... |
changed to a constant | private String getPartitionLeasePrefix() {
return this.settings.getContainerNamePrefix() + "..";
} | return this.settings.getContainerNamePrefix() + ".."; | private String getPartitionLeasePrefix() {
return this.settings.getContainerNamePrefix() + LEASE_STORE_MANAGER_LEASE_SUFFIX;
} | class LeaseStoreManagerImpl implements LeaseStoreManager, LeaseStoreManager.LeaseStoreManagerBuilderDefinition {
private final Logger logger = LoggerFactory.getLogger(LeaseStoreManagerImpl.class);
private LeaseStoreManagerSettings settings;
private ChangeFeedContextClient leaseDocumentClient;
private RequestOptionsFact... | class LeaseStoreManagerImpl implements LeaseStoreManager, LeaseStoreManager.LeaseStoreManagerBuilderDefinition {
private final String LEASE_STORE_MANAGER_LEASE_SUFFIX = "..";
private final Logger logger = LoggerFactory.getLogger(LeaseStoreManagerImpl.class);
private LeaseStoreManagerSettings settings;
private ChangeFee... |
We should use logger.error here, and everywhere else in the tests. | public void staledLeaseAcquiring() {
final String ownerFirst = "Owner_First";
final String ownerSecond = "Owner_Second";
final String leasePrefix = "TEST";
ChangeFeedProcessor changeFeedProcessorFirst = ChangeFeedProcessor.Builder()
.hostName(ownerFirst)
.handleChanges(docs -> {
ChangeFeedProcessorTest.log.info("START ... | e.printStackTrace(); | public void staledLeaseAcquiring() {
final String ownerFirst = "Owner_First";
final String ownerSecond = "Owner_Second";
final String leasePrefix = "TEST";
ChangeFeedProcessor changeFeedProcessorFirst = ChangeFeedProcessor.Builder()
.hostName(ownerFirst)
.handleChanges(docs -> {
ChangeFeedProcessorTest.log.info("START ... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private CosmosDatabase createdDatabase;
private CosmosContainer createdFeedCollection;
private CosmosContainer createdLeaseCollection;
private List<CosmosItemProperties> create... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private CosmosDatabase createdDatabase;
private CosmosContainer createdFeedCollection;
private CosmosContainer createdLeaseCollection;
private List<CosmosItemProperties> create... |
fixed | public void staledLeaseAcquiring() {
final String ownerFirst = "Owner_First";
final String ownerSecond = "Owner_Second";
final String leasePrefix = "TEST";
ChangeFeedProcessor changeFeedProcessorFirst = ChangeFeedProcessor.Builder()
.hostName(ownerFirst)
.handleChanges(docs -> {
ChangeFeedProcessorTest.log.info("START ... | e.printStackTrace(); | public void staledLeaseAcquiring() {
final String ownerFirst = "Owner_First";
final String ownerSecond = "Owner_Second";
final String leasePrefix = "TEST";
ChangeFeedProcessor changeFeedProcessorFirst = ChangeFeedProcessor.Builder()
.hostName(ownerFirst)
.handleChanges(docs -> {
ChangeFeedProcessorTest.log.info("START ... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private CosmosDatabase createdDatabase;
private CosmosContainer createdFeedCollection;
private CosmosContainer createdLeaseCollection;
private List<CosmosItemProperties> create... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private CosmosDatabase createdDatabase;
private CosmosContainer createdFeedCollection;
private CosmosContainer createdLeaseCollection;
private List<CosmosItemProperties> create... |
What's the reason change to C folder? | public static void main(String[] args) {
String shareName = generateRandomName();
ShareClient shareClient = new ShareClientBuilder().endpoint(ENDPOINT).shareName(shareName).buildClient();
shareClient.create();
String parentDirName = generateRandomName();
shareClient.createDirectory(parentDirName);
String srcFileName = ... | String filePath = "C:/filePath/"; | public static void main(String[] args) {
String shareName = generateRandomName();
ShareClient shareClient = new ShareClientBuilder().endpoint(ENDPOINT).shareName(shareName).buildClient();
shareClient.create();
String parentDirName = generateRandomName();
shareClient.createDirectory(parentDirName);
String srcFileName = ... | class FileSample {
private static final String ENDPOINT = ConfigurationManager.getConfiguration().get("AZURE_STORAGE_FILE_ENDPOINT");
private static String generateRandomName() {
return UUID.randomUUID().toString().substring(0, 8);
}
/**
* The main method shows how to do the base operation using file sync client.
* @pa... | class FileSample {
private static final String ENDPOINT = ConfigurationManager.getConfiguration().get("AZURE_STORAGE_FILE_ENDPOINT");
private static String generateRandomName() {
return UUID.randomUUID().toString().substring(0, 8);
}
/**
* The main method shows how to do the base operation using file sync client.
* @pa... |
Using the class loader get resource could lead to a NPE, given this is a sample not tying to anything real I just made it simpler. | public static void main(String[] args) {
String shareName = generateRandomName();
ShareClient shareClient = new ShareClientBuilder().endpoint(ENDPOINT).shareName(shareName).buildClient();
shareClient.create();
String parentDirName = generateRandomName();
shareClient.createDirectory(parentDirName);
String srcFileName = ... | String filePath = "C:/filePath/"; | public static void main(String[] args) {
String shareName = generateRandomName();
ShareClient shareClient = new ShareClientBuilder().endpoint(ENDPOINT).shareName(shareName).buildClient();
shareClient.create();
String parentDirName = generateRandomName();
shareClient.createDirectory(parentDirName);
String srcFileName = ... | class FileSample {
private static final String ENDPOINT = ConfigurationManager.getConfiguration().get("AZURE_STORAGE_FILE_ENDPOINT");
private static String generateRandomName() {
return UUID.randomUUID().toString().substring(0, 8);
}
/**
* The main method shows how to do the base operation using file sync client.
* @pa... | class FileSample {
private static final String ENDPOINT = ConfigurationManager.getConfiguration().get("AZURE_STORAGE_FILE_ENDPOINT");
private static String generateRandomName() {
return UUID.randomUUID().toString().substring(0, 8);
}
/**
* The main method shows how to do the base operation using file sync client.
* @pa... |
Nice 👍 | public EventData(String body) {
this(body.getBytes(UTF_8));
} | } | public EventData(String body) {
this(body.getBytes(UTF_8));
} | class EventData implements Comparable<EventData> {
/*
* These are properties owned by the service and set when a message is received.
*/
public static final Set<String> RESERVED_SYSTEM_PROPERTIES;
private final ClientLogger logger = new ClientLogger(EventData.class);
private final Map<String, Object> properties;
privat... | class EventData implements Comparable<EventData> {
/*
* These are properties owned by the service and set when a message is received.
*/
public static final Set<String> RESERVED_SYSTEM_PROPERTIES;
private final ClientLogger logger = new ClientLogger(EventData.class);
private final Map<String, Object> properties;
privat... |
Does this get rendered properly? iirc the underlying slf4j .warn method does not take a varargs and then a throwable. | public void processError(PartitionContext partitionContext, Throwable throwable) {
logger.warning("Error occurred in partition processor for partition {} ", partitionContext.partitionId(),
throwable);
} | logger.warning("Error occurred in partition processor for partition {} ", partitionContext.partitionId(), | public void processError(PartitionContext partitionContext, Throwable throwable) {
logger.warning("Error occurred in partition processor for partition {}", partitionContext.partitionId(),
throwable);
} | class PartitionProcessor {
private final ClientLogger logger = new ClientLogger(PartitionProcessor.class);
/**
* This method is called when this {@link EventProcessor} takes ownership of a new partition and before any events
* from this partition are received.
*
* @param partitionContext The partition information for i... | class PartitionProcessor {
private final ClientLogger logger = new ClientLogger(PartitionProcessor.class);
/**
* This method is called when this {@link EventProcessor} takes ownership of a new partition and before any events
* from this partition are received.
*
* @param partitionContext The partition information for i... |
This is not slf4j issue. Adding exception as the last param in slf4j `warn` method works as expected. But our `ClientLogger` removes the exception for any log level other than `verbose`. I am not sure why we do that but I prefer to have the users of `ClientLogger` pass in the exception which can contain useful informat... | public void processError(PartitionContext partitionContext, Throwable throwable) {
logger.warning("Error occurred in partition processor for partition {} ", partitionContext.partitionId(),
throwable);
} | logger.warning("Error occurred in partition processor for partition {} ", partitionContext.partitionId(), | public void processError(PartitionContext partitionContext, Throwable throwable) {
logger.warning("Error occurred in partition processor for partition {}", partitionContext.partitionId(),
throwable);
} | class PartitionProcessor {
private final ClientLogger logger = new ClientLogger(PartitionProcessor.class);
/**
* This method is called when this {@link EventProcessor} takes ownership of a new partition and before any events
* from this partition are received.
*
* @param partitionContext The partition information for i... | class PartitionProcessor {
private final ClientLogger logger = new ClientLogger(PartitionProcessor.class);
/**
* This method is called when this {@link EventProcessor} takes ownership of a new partition and before any events
* from this partition are received.
*
* @param partitionContext The partition information for i... |
@alzimmermsft Can you please validate that this is sane when the user does not specify a port, and therefore the port value is zero. Thanks! | public NettyAsyncHttpClient build() {
HttpClient nettyHttpClient = HttpClient.create()
.port(port)
.wiretap(enableWiretap)
.tcpConfiguration(tcpConfig -> {
if (nioEventLoopGroup != null) {
tcpConfig = tcpConfig.runOn(nioEventLoopGroup);
}
if (proxyOptions == null) {
return tcpConfig;
}
ProxyOptions options = proxyOptio... | .port(port) | public NettyAsyncHttpClient build() {
HttpClient nettyHttpClient = HttpClient.create()
.port(port)
.wiretap(enableWiretap)
.tcpConfiguration(tcpConfig -> {
if (nioEventLoopGroup != null) {
tcpConfig = tcpConfig.runOn(nioEventLoopGroup);
}
if (proxyOptions != null) {
ProxyProvider.Proxy nettyProxy;
switch (proxyOptions.... | class NettyAsyncHttpClientBuilder {
private final ClientLogger logger = new ClientLogger(NettyAsyncHttpClientBuilder.class);
private Supplier<ProxyOptions> proxyOptions;
private boolean enableWiretap;
private int port;
private NioEventLoopGroup nioEventLoopGroup;
/**
*
*/
public NettyAsyncHttpClientBuilder() { }
/**... | class NettyAsyncHttpClientBuilder {
private final ClientLogger logger = new ClientLogger(NettyAsyncHttpClientBuilder.class);
private ProxyOptions proxyOptions;
private boolean enableWiretap;
private int port = 80;
private NioEventLoopGroup nioEventLoopGroup;
/**
* Creates a new builder instance, where a builder is capa... |
To avoid a future bug, we should move the configuration of the proxy into the if block above by inverting the null check. | public NettyAsyncHttpClient build() {
HttpClient nettyHttpClient = HttpClient.create()
.port(port)
.wiretap(enableWiretap)
.tcpConfiguration(tcpConfig -> {
if (nioEventLoopGroup != null) {
tcpConfig = tcpConfig.runOn(nioEventLoopGroup);
}
if (proxyOptions == null) {
return tcpConfig;
}
ProxyProvider.Proxy nettyProxy;
s... | return tcpConfig.proxy(ts -> ts.type(nettyProxy).address(proxyOptions.address())); | public NettyAsyncHttpClient build() {
HttpClient nettyHttpClient = HttpClient.create()
.port(port)
.wiretap(enableWiretap)
.tcpConfiguration(tcpConfig -> {
if (nioEventLoopGroup != null) {
tcpConfig = tcpConfig.runOn(nioEventLoopGroup);
}
if (proxyOptions != null) {
ProxyProvider.Proxy nettyProxy;
switch (proxyOptions.... | class NettyAsyncHttpClientBuilder {
private final ClientLogger logger = new ClientLogger(NettyAsyncHttpClientBuilder.class);
private ProxyOptions proxyOptions;
private boolean enableWiretap;
private int port = 80;
private NioEventLoopGroup nioEventLoopGroup;
/**
*
*/
public NettyAsyncHttpClientBuilder() {
}
/**
*
* @re... | class NettyAsyncHttpClientBuilder {
private final ClientLogger logger = new ClientLogger(NettyAsyncHttpClientBuilder.class);
private ProxyOptions proxyOptions;
private boolean enableWiretap;
private int port = 80;
private NioEventLoopGroup nioEventLoopGroup;
/**
* Creates a new builder instance, where a builder is capa... |
Did you make this change? | public NettyAsyncHttpClient build() {
HttpClient nettyHttpClient = HttpClient.create()
.port(port)
.wiretap(enableWiretap)
.tcpConfiguration(tcpConfig -> {
if (nioEventLoopGroup != null) {
tcpConfig = tcpConfig.runOn(nioEventLoopGroup);
}
if (proxyOptions == null) {
return tcpConfig;
}
ProxyProvider.Proxy nettyProxy;
s... | return tcpConfig.proxy(ts -> ts.type(nettyProxy).address(proxyOptions.address())); | public NettyAsyncHttpClient build() {
HttpClient nettyHttpClient = HttpClient.create()
.port(port)
.wiretap(enableWiretap)
.tcpConfiguration(tcpConfig -> {
if (nioEventLoopGroup != null) {
tcpConfig = tcpConfig.runOn(nioEventLoopGroup);
}
if (proxyOptions != null) {
ProxyProvider.Proxy nettyProxy;
switch (proxyOptions.... | class NettyAsyncHttpClientBuilder {
private final ClientLogger logger = new ClientLogger(NettyAsyncHttpClientBuilder.class);
private ProxyOptions proxyOptions;
private boolean enableWiretap;
private int port = 80;
private NioEventLoopGroup nioEventLoopGroup;
/**
*
*/
public NettyAsyncHttpClientBuilder() {
}
/**
*
* @re... | class NettyAsyncHttpClientBuilder {
private final ClientLogger logger = new ClientLogger(NettyAsyncHttpClientBuilder.class);
private ProxyOptions proxyOptions;
private boolean enableWiretap;
private int port = 80;
private NioEventLoopGroup nioEventLoopGroup;
/**
* Creates a new builder instance, where a builder is capa... |
Let's revert this, the line of code is meant to mutate the object. | public Object invoke(Object proxy, final Method method, Object[] args) {
try {
final SwaggerMethodParser methodParser;
final HttpRequest request;
if (method.isAnnotationPresent(ResumeOperation.class)) {
OperationDescription opDesc = ImplUtils.findFirstOfType(args, OperationDescription.class);
Method resumeMethod = dete... | final Context context1 = startTracingSpan(method, context); | public Object invoke(Object proxy, final Method method, Object[] args) {
try {
final SwaggerMethodParser methodParser;
final HttpRequest request;
if (method.isAnnotationPresent(ResumeOperation.class)) {
OperationDescription opDesc = ImplUtils.findFirstOfType(args, OperationDescription.class);
Method resumeMethod = dete... | class RestProxy implements InvocationHandler {
private final ClientLogger logger = new ClientLogger(RestProxy.class);
private final HttpPipeline httpPipeline;
private final SerializerAdapter serializer;
private final SwaggerInterfaceParser interfaceParser;
private final HttpResponseDecoder decoder;
/**
* Create a RestP... | class RestProxy implements InvocationHandler {
private final ClientLogger logger = new ClientLogger(RestProxy.class);
private final HttpPipeline httpPipeline;
private final SerializerAdapter serializer;
private final SwaggerInterfaceParser interfaceParser;
private final HttpResponseDecoder decoder;
/**
* Create a RestP... |
Is this happening because the `UnexpectedLengthException` is reading the `ByteBuffer`? If so, is there any way the check could be implemented to not read the ByteBuffer and need it to be reset? | public Mono<HttpResponse> send(HttpRequest request, Context contextData) {
if(request.body() != null){
request.body().map(ByteBuffer::reset);
}
return httpPipeline.send(request, contextData);
} | request.body().map(ByteBuffer::reset); | public Mono<HttpResponse> send(HttpRequest request, Context contextData) {
return httpPipeline.send(request, contextData);
} | class RestProxy implements InvocationHandler {
private final ClientLogger logger = new ClientLogger(RestProxy.class);
private final HttpPipeline httpPipeline;
private final SerializerAdapter serializer;
private final SwaggerInterfaceParser interfaceParser;
private final HttpResponseDecoder decoder;
/**
* Create a RestP... | class RestProxy implements InvocationHandler {
private final ClientLogger logger = new ClientLogger(RestProxy.class);
private final HttpPipeline httpPipeline;
private final SerializerAdapter serializer;
private final SwaggerInterfaceParser interfaceParser;
private final HttpResponseDecoder decoder;
/**
* Create a RestP... |
Extra set of parentheses here. | private HttpRequest configRequest(HttpRequest request, SwaggerMethodParser methodParser, Object[] args) throws IOException {
final Object bodyContentObject = methodParser.body(args);
if (bodyContentObject == null) {
request.headers().put("Content-Length", "0");
} else {
String contentType = methodParser.bodyContentType... | request.body(Flux.just(((ByteBuffer) bodyContentObject))); | private HttpRequest configRequest(HttpRequest request, SwaggerMethodParser methodParser, Object[] args) throws IOException {
final Object bodyContentObject = methodParser.body(args);
if (bodyContentObject == null) {
request.headers().put("Content-Length", "0");
} else {
String contentType = methodParser.bodyContentType... | class RestProxy implements InvocationHandler {
private final ClientLogger logger = new ClientLogger(RestProxy.class);
private final HttpPipeline httpPipeline;
private final SerializerAdapter serializer;
private final SwaggerInterfaceParser interfaceParser;
private final HttpResponseDecoder decoder;
/**
* Create a RestP... | class RestProxy implements InvocationHandler {
private final ClientLogger logger = new ClientLogger(RestProxy.class);
private final HttpPipeline httpPipeline;
private final SerializerAdapter serializer;
private final SwaggerInterfaceParser interfaceParser;
private final HttpResponseDecoder decoder;
/**
* Create a RestP... |
Done in the [PR](https://github.com/Azure/azure-sdk-for-java/pull/5222), added similar message for all null checks. | public OkHttpAsyncHttpClientBuilder(okhttp3.OkHttpClient okHttpClient) {
this.okHttpClient = Objects.requireNonNull(okHttpClient, "okHttpClient == null");
} | this.okHttpClient = Objects.requireNonNull(okHttpClient, "okHttpClient == null"); | public OkHttpAsyncHttpClientBuilder(okhttp3.OkHttpClient okHttpClient) {
this.okHttpClient = Objects.requireNonNull(okHttpClient, "okHttpClient == null");
} | class OkHttpAsyncHttpClientBuilder {
private final ClientLogger logger = new ClientLogger(OkHttpAsyncHttpClientBuilder.class);
private final okhttp3.OkHttpClient okHttpClient;
private final static Duration DEFAULT_READ_TIMEOUT = Duration.ofSeconds(120);
private final static Duration DEFAULT_CONNECT_TIMEOUT = Duration.o... | class OkHttpAsyncHttpClientBuilder {
private final ClientLogger logger = new ClientLogger(OkHttpAsyncHttpClientBuilder.class);
private final okhttp3.OkHttpClient okHttpClient;
private final static Duration DEFAULT_READ_TIMEOUT = Duration.ofSeconds(120);
private final static Duration DEFAULT_CONNECT_TIMEOUT = Duration.o... |
Good question @srnagar :) Q1: – *if there's a difference between a null responseBody ..*: `okhttp3.Response::body()` getter will not return null for server returned responses. It can be null only if we build response manually with null body (e.g. for mocking) or for the cases described here [ref](https://square.git... | public Mono<byte[]> bodyAsByteArray() {
if (this.responseBody() == null) {
return Mono.empty();
} else {
return Mono.using(() -> this.responseBody(),
rb -> {
try {
byte[] content = rb.bytes();
return content.length == 0 ? Mono.empty() : Mono.just(content);
} catch (IOException ioe) {
throw Exceptions.propagate(ioe);
}
... | return content.length == 0 ? Mono.empty() : Mono.just(content); | public Mono<byte[]> bodyAsByteArray() {
if (this.responseBody() == null) {
return Mono.empty();
} else {
return Mono.using(() -> this.responseBody(),
rb -> {
try {
byte[] content = rb.bytes();
return content.length == 0 ? Mono.empty() : Mono.just(content);
} catch (IOException ioe) {
throw Exceptions.propagate(ioe);
}
... | class OkHttpResponse extends HttpResponse {
private final okhttp3.Response inner;
private final HttpHeaders headers;
private final static int BYTE_BUFFER_CHUNK_SIZE = 1024;
public OkHttpResponse(okhttp3.Response inner, HttpRequest request) {
this.inner = inner;
this.headers = fromOkHttpHeaders(this.inner.headers());
su... | class OkHttpResponse extends HttpResponse {
private final okhttp3.Response inner;
private final HttpHeaders headers;
private final static int BYTE_BUFFER_CHUNK_SIZE = 1024;
public OkHttpResponse(okhttp3.Response inner, HttpRequest request) {
this.inner = inner;
this.headers = fromOkHttpHeaders(this.inner.headers());
su... |
see below comment | public Mono<String> bodyAsString() {
if (this.responseBody() == null) {
return Mono.empty();
} else {
return Mono.using(() -> this.responseBody(),
rb -> {
try {
String content = rb.string();
return content.length() == 0 ? Mono.empty() : Mono.just(content);
} catch (IOException ioe) {
throw Exceptions.propagate(ioe);
}
... | return content.length() == 0 ? Mono.empty() : Mono.just(content); | public Mono<String> bodyAsString() {
if (this.responseBody() == null) {
return Mono.empty();
} else {
return Mono.using(() -> this.responseBody(),
rb -> {
try {
String content = rb.string();
return content.length() == 0 ? Mono.empty() : Mono.just(content);
} catch (IOException ioe) {
throw Exceptions.propagate(ioe);
}
... | class OkHttpResponse extends HttpResponse {
private final okhttp3.Response inner;
private final HttpHeaders headers;
private final static int BYTE_BUFFER_CHUNK_SIZE = 1024;
public OkHttpResponse(okhttp3.Response inner, HttpRequest request) {
this.inner = inner;
this.headers = fromOkHttpHeaders(this.inner.headers());
su... | class OkHttpResponse extends HttpResponse {
private final okhttp3.Response inner;
private final HttpHeaders headers;
private final static int BYTE_BUFFER_CHUNK_SIZE = 1024;
public OkHttpResponse(okhttp3.Response inner, HttpRequest request) {
this.inner = inner;
this.headers = fromOkHttpHeaders(this.inner.headers());
su... |
no need to change, but, probably a good idea to start keeping in mind the 120 max length | public Mono<Void> uploadFromFile(String uploadFilePath) {
AsynchronousFileChannel channel = channelSetup(uploadFilePath);
return Flux.fromIterable(sliceFile(uploadFilePath))
.flatMap(chunk -> upload(FluxUtil.readFile(channel, chunk.start(), chunk.end() - chunk.start() + 1), chunk.end() - chunk.start() + 1, chunk.start(... | .flatMap(chunk -> upload(FluxUtil.readFile(channel, chunk.start(), chunk.end() - chunk.start() + 1), chunk.end() - chunk.start() + 1, chunk.start()) | public Mono<Void> uploadFromFile(String uploadFilePath) {
return Mono.using(() -> channelSetup(uploadFilePath, StandardOpenOption.READ),
channel -> Flux.fromIterable(sliceFile(uploadFilePath)).flatMap(chunk -> upload(FluxUtil.readFile(channel,
chunk.start(), chunk.end() - chunk.start() + 1), chunk.end() - chunk.start()... | class FileAsyncClient {
private final ClientLogger logger = new ClientLogger(FileAsyncClient.class);
private static final long FILE_DEFAULT_BLOCK_SIZE = 4 * 1024 * 1024L;
private static final long DOWNLOAD_UPLOAD_CHUNK_TIMEOUT = 300;
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareN... | class FileAsyncClient {
private final ClientLogger logger = new ClientLogger(FileAsyncClient.class);
private static final long FILE_DEFAULT_BLOCK_SIZE = 4 * 1024 * 1024L;
private static final long DOWNLOAD_UPLOAD_CHUNK_TIMEOUT = 300;
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareN... |
we should consider to make 30 *100 a constant. | private void configureChannelPipelineHandlers() {
this.httpClient = this.httpClient.tcpConfiguration(tcpClient -> {
if (this.httpClientConfig.getProxy() != null) {
tcpClient =
tcpClient.proxy(typeSpec -> typeSpec.type(ProxyProvider.Proxy.HTTP).address(this.httpClientConfig.getProxy()));
}
tcpClient =
tcpClient.secure(s... | tcpClient = tcpClient.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 30 * 1000); | private void configureChannelPipelineHandlers() {
this.httpClient = this.httpClient.tcpConfiguration(tcpClient -> {
if (this.httpClientConfig.getProxy() != null) {
tcpClient =
tcpClient.proxy(typeSpec -> typeSpec.type(ProxyProvider.Proxy.HTTP).address(this.httpClientConfig.getProxy()));
}
tcpClient =
tcpClient.secure(s... | class ReactorNettyClient implements HttpClient {
private static final Logger logger = LoggerFactory.getLogger(ReactorNettyClient.class.getSimpleName());
private HttpClientConfig httpClientConfig;
private reactor.netty.http.client.HttpClient httpClient;
private ConnectionProvider connectionProvider;
private ReactorNetty... | class ReactorNettyClient implements HttpClient {
private static final Logger logger = LoggerFactory.getLogger(ReactorNettyClient.class.getSimpleName());
private HttpClientConfig httpClientConfig;
private reactor.netty.http.client.HttpClient httpClient;
private ConnectionProvider connectionProvider;
private ReactorNetty... |
Why are we adding this sort? This is already a segment of a paged response, what's the point of spending cycles sorting every 1000 file subset of a larger list? | private List<FileRef> convertResponseAndGetNumOfResults(DirectorysListFilesAndDirectoriesSegmentResponse response) {
List<FileRef> fileRefs = new ArrayList<>();
if (response.value().segment() != null) {
response.value().segment().directoryItems().forEach(directoryItem -> fileRefs.add(new FileRef(directoryItem.name(), t... | fileRefs.sort(Comparator.comparing(FileRef::name)); | private List<FileRef> convertResponseAndGetNumOfResults(DirectorysListFilesAndDirectoriesSegmentResponse response) {
Set<FileRef> fileRefs = new TreeSet<>(Comparator.comparing(FileRef::name));
if (response.value().segment() != null) {
response.value().segment().directoryItems()
.forEach(directoryItem -> fileRefs.add(ne... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... |
The REST spec states that the response is lexically sorted with directories and files intermingled and I wanted to align on this. https://docs.microsoft.com/en-us/rest/api/storageservices/list-directories-and-files#remarks | private List<FileRef> convertResponseAndGetNumOfResults(DirectorysListFilesAndDirectoriesSegmentResponse response) {
List<FileRef> fileRefs = new ArrayList<>();
if (response.value().segment() != null) {
response.value().segment().directoryItems().forEach(directoryItem -> fileRefs.add(new FileRef(directoryItem.name(), t... | fileRefs.sort(Comparator.comparing(FileRef::name)); | private List<FileRef> convertResponseAndGetNumOfResults(DirectorysListFilesAndDirectoriesSegmentResponse response) {
Set<FileRef> fileRefs = new TreeSet<>(Comparator.comparing(FileRef::name));
if (response.value().segment() != null) {
response.value().segment().directoryItems()
.forEach(directoryItem -> fileRefs.add(ne... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... |
If the rest spec says it's sorted, wouldn't it already be sorted? | private List<FileRef> convertResponseAndGetNumOfResults(DirectorysListFilesAndDirectoriesSegmentResponse response) {
List<FileRef> fileRefs = new ArrayList<>();
if (response.value().segment() != null) {
response.value().segment().directoryItems().forEach(directoryItem -> fileRefs.add(new FileRef(directoryItem.name(), t... | fileRefs.sort(Comparator.comparing(FileRef::name)); | private List<FileRef> convertResponseAndGetNumOfResults(DirectorysListFilesAndDirectoriesSegmentResponse response) {
Set<FileRef> fileRefs = new TreeSet<>(Comparator.comparing(FileRef::name));
if (response.value().segment() != null) {
response.value().segment().directoryItems()
.forEach(directoryItem -> fileRefs.add(ne... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... |
They should sort in our return type in fileRef. The line here is trying to sort out based on FileRef name instead of sort separately based on dir and file. | private List<FileRef> convertResponseAndGetNumOfResults(DirectorysListFilesAndDirectoriesSegmentResponse response) {
List<FileRef> fileRefs = new ArrayList<>();
if (response.value().segment() != null) {
response.value().segment().directoryItems().forEach(directoryItem -> fileRefs.add(new FileRef(directoryItem.name(), t... | fileRefs.sort(Comparator.comparing(FileRef::name)); | private List<FileRef> convertResponseAndGetNumOfResults(DirectorysListFilesAndDirectoriesSegmentResponse response) {
Set<FileRef> fileRefs = new TreeSet<>(Comparator.comparing(FileRef::name));
if (response.value().segment() != null) {
response.value().segment().directoryItems()
.forEach(directoryItem -> fileRefs.add(ne... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... |
Typo, missing the 'c' in context | public void createWithResponse() {
DirectoryClient directoryClient = createClientWithSASToken();
Response<DirectoryInfo> response = directoryClient.createWithResponse(
Collections.singletonMap("directory", "metadata"), Duration.ofSeconds(1), new Context(key1, value1));
System.out.println("Completed creating the directo... | public void createWithResponse() {
DirectoryClient directoryClient = createClientWithSASToken();
FileSmbProperties smbProperties = new FileSmbProperties();
String filePermission = "filePermission";
Response<DirectoryInfo> response = directoryClient.createWithResponse(smbProperties, filePermission,
Collections.singleton... | class DirectoryJavaDocCodeSamples {
private String key1 = "key1";
private String value1 = "val1";
/**
* Generates code sample for {@link DirectoryClient} instantiation.
*/
public void initialization() {
DirectoryClient client = new FileClientBuilder()
.connectionString("${connectionString}")
.endpoint("${endpoint}")
.b... | class DirectoryJavaDocCodeSamples {
private String key1 = "key1";
private String value1 = "val1";
/**
* Generates code sample for {@link DirectoryClient} instantiation.
*/
public void initialization() {
DirectoryClient client = new FileClientBuilder()
.connectionString("${connectionString}")
.endpoint("${endpoint}")
.b... | |
Same as the other code snippet class around the duration. | public void createWithResponse() {
DirectoryClient directoryClient = createClientWithSASToken();
Response<DirectoryInfo> response = directoryClient.createWithResponse(
Collections.singletonMap("directory", "metadata"), Duration.ofSeconds(1), new Context(key1, value1));
System.out.println("Completed creating the directo... | Collections.singletonMap("directory", "metadata"), Duration.ofSeconds(1), new Context(key1, value1)); | public void createWithResponse() {
DirectoryClient directoryClient = createClientWithSASToken();
FileSmbProperties smbProperties = new FileSmbProperties();
String filePermission = "filePermission";
Response<DirectoryInfo> response = directoryClient.createWithResponse(smbProperties, filePermission,
Collections.singleton... | class DirectoryJavaDocCodeSamples {
private String key1 = "key1";
private String value1 = "val1";
/**
* Generates code sample for {@link DirectoryClient} instantiation.
*/
public void initialization() {
DirectoryClient client = new FileClientBuilder()
.connectionString("${connectionString}")
.endpoint("${endpoint}")
.b... | class DirectoryJavaDocCodeSamples {
private String key1 = "key1";
private String value1 = "val1";
/**
* Generates code sample for {@link DirectoryClient} instantiation.
*/
public void initialization() {
DirectoryClient client = new FileClientBuilder()
.connectionString("${connectionString}")
.endpoint("${endpoint}")
.b... |
Didn't update the code snippet name | public void uploadWithResponse() {
FileClient fileClient = createClientWithSASToken();
ByteBuffer defaultData = ByteBuffer.wrap("default".getBytes(StandardCharsets.UTF_8));
Response<FileUploadInfo> response = fileClient.uploadWithResponse(defaultData, defaultData.remaining(),
Duration.ofSeconds(1), new Context(key1, va... | public void uploadWithResponse() {
FileClient fileClient = createClientWithSASToken();
ByteBuffer defaultData = ByteBuffer.wrap("default".getBytes(StandardCharsets.UTF_8));
Response<FileUploadInfo> response = fileClient.uploadWithResponse(defaultData, defaultData.remaining(),
Duration.ofSeconds(1), new Context(key1, va... | class FileJavaDocCodeSamples {
private String key1 = "key1";
private String value1 = "val1";
/**
* Generates code sample for {@link FileClient} instantiation.
*/
public void initialization() {
FileClient client = new FileClientBuilder()
.connectionString("${connectionString}")
.endpoint("${endpoint}")
.buildFileClient(... | class FileJavaDocCodeSamples {
private String key1 = "key1";
private String value1 = "val1";
/**
* Generates code sample for {@link FileClient} instantiation.
*/
public void initialization() {
FileClient client = new FileClientBuilder()
.connectionString("${connectionString}")
.endpoint("${endpoint}")
.buildFileClient(... | |
Didn't update the code snippet name | public void uploadWithResponseMaxOverload() {
FileClient fileClient = createClientWithSASToken();
ByteBuffer defaultData = ByteBuffer.wrap("default".getBytes(StandardCharsets.UTF_8));
Response<FileUploadInfo> response = fileClient.uploadWithResponse(defaultData, defaultData.remaining(),
1024, Duration.ofSeconds(1), new... | public void uploadWithResponseMaxOverload() {
FileClient fileClient = createClientWithSASToken();
ByteBuffer defaultData = ByteBuffer.wrap("default".getBytes(StandardCharsets.UTF_8));
Response<FileUploadInfo> response = fileClient.uploadWithResponse(defaultData, defaultData.remaining(),
1024, Duration.ofSeconds(1), new... | class FileJavaDocCodeSamples {
private String key1 = "key1";
private String value1 = "val1";
/**
* Generates code sample for {@link FileClient} instantiation.
*/
public void initialization() {
FileClient client = new FileClientBuilder()
.connectionString("${connectionString}")
.endpoint("${endpoint}")
.buildFileClient(... | class FileJavaDocCodeSamples {
private String key1 = "key1";
private String value1 = "val1";
/**
* Generates code sample for {@link FileClient} instantiation.
*/
public void initialization() {
FileClient client = new FileClientBuilder()
.connectionString("${connectionString}")
.endpoint("${endpoint}")
.buildFileClient(... | |
For async APIs, you should use the Flux or Mono context instead of `Context.None` | private Consumer<Poller<CertificateOperation>> cancelOperation(String name) {
return poller -> {
service.updateCertificateOperation(endpoint, name, API_VERSION, ACCEPT_LANGUAGE,
new CertificateOperationUpdateParameter().cancellationRequested(true), CONTENT_TYPE_HEADER_VALUE, Context.NONE);
};
} | new CertificateOperationUpdateParameter().cancellationRequested(true), CONTENT_TYPE_HEADER_VALUE, Context.NONE); | new CertificateOperationUpdateParameter().cancellationRequested(true);
return service.updateCertificateOperation(endpoint, certificateName, API_VERSION, ACCEPT_LANGUAGE, parameter, CONTENT_TYPE_HEADER_VALUE, context)
.doOnRequest(ignored -> logger.info("Cancelling certificate operation - {} | class CertificateAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private String endpoint;
private final CertificateService service;
private final Clie... | class CertificateAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private final String endpoint;
private final CertificateService service;
private fina... |
Didn't update the code snippet name | public void clearRangeMaxOverload() {
FileClient fileClient = createClientWithSASToken();
Response<FileUploadInfo> response = fileClient.clearRangeWithResponse(1024, 1024,
Duration.ofSeconds(1), new Context(key1, value1));
System.out.println("Complete clearing the range with status code: " + response.statusCode());
} | public void clearRangeMaxOverload() {
FileClient fileClient = createClientWithSASToken();
Response<FileUploadInfo> response = fileClient.clearRangeWithResponse(1024, 1024,
Duration.ofSeconds(1), new Context(key1, value1));
System.out.println("Complete clearing the range with status code: " + response.statusCode());
} | class FileJavaDocCodeSamples {
private String key1 = "key1";
private String value1 = "val1";
/**
* Generates code sample for {@link FileClient} instantiation.
*/
public void initialization() {
FileClient client = new FileClientBuilder()
.connectionString("${connectionString}")
.endpoint("${endpoint}")
.buildFileClient(... | class FileJavaDocCodeSamples {
private String key1 = "key1";
private String value1 = "val1";
/**
* Generates code sample for {@link FileClient} instantiation.
*/
public void initialization() {
FileClient client = new FileClientBuilder()
.connectionString("${connectionString}")
.endpoint("${endpoint}")
.buildFileClient(... | |
(extreme) nit: Same error condition for these two exceptions, but different wording. It may be helpful, if not superfluous, to use consistent verbiage. | public IterableStream<EventData> receive(int maximumMessageCount, Duration maximumWaitTime) {
Objects.requireNonNull(maximumWaitTime, "'maximumWaitTime' cannot be null.");
if (maximumMessageCount < 1) {
throw new IllegalArgumentException("'maximumMessageCount' cannot be less than 1.");
} else if (maximumWaitTime.isNega... | throw new IllegalArgumentException("'maximumWaitTime' cannot be zero or less."); | public IterableStream<EventData> receive(int maximumMessageCount, Duration maximumWaitTime) {
Objects.requireNonNull(maximumWaitTime, "'maximumWaitTime' cannot be null.");
if (maximumMessageCount < 1) {
throw logger.logExceptionAsError(
new IllegalArgumentException("'maximumMessageCount' cannot be less than 1."));
} el... | class EventHubConsumer implements Closeable {
private static final AtomicReferenceFieldUpdater<EventHubConsumer, SynchronousEventSubscriber> SUBSCRIBER =
AtomicReferenceFieldUpdater.newUpdater(EventHubConsumer.class, SynchronousEventSubscriber.class,
"eventSubscriber");
private final ClientLogger logger = new ClientLog... | class EventHubConsumer implements Closeable {
private static final AtomicReferenceFieldUpdater<EventHubConsumer, SynchronousEventSubscriber> SUBSCRIBER =
AtomicReferenceFieldUpdater.newUpdater(EventHubConsumer.class, SynchronousEventSubscriber.class,
"eventSubscriber");
private final ClientLogger logger = new ClientLog... |
Polling every one second? | public Poller<CertificateOperation> createCertificate(String name, CertificatePolicy policy, Map<String, String> tags) {
return new Poller<CertificateOperation>(Duration.ofSeconds(1), createPollOperation(name), actvationOperation(name, policy, tags), cancelOperation(name));
} | return new Poller<CertificateOperation>(Duration.ofSeconds(1), createPollOperation(name), actvationOperation(name, policy, tags), cancelOperation(name)); | public Poller<CertificateOperation> createCertificate(String name, CertificatePolicy policy, Map<String, String> tags) {
return new Poller<CertificateOperation>(Duration.ofSeconds(1), createPollOperation(name), activationOperation(name, policy, tags), cancelOperation(name));
} | class CertificateAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private String endpoint;
private final CertificateService service;
private final Clie... | class CertificateAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private final String endpoint;
private final CertificateService service;
private fina... |
Correct - this needs to change in line with the other async client libraries where the Context is extracted from reactor and pass into the service call. | private Consumer<Poller<CertificateOperation>> cancelOperation(String name) {
return poller -> {
service.updateCertificateOperation(endpoint, name, API_VERSION, ACCEPT_LANGUAGE,
new CertificateOperationUpdateParameter().cancellationRequested(true), CONTENT_TYPE_HEADER_VALUE, Context.NONE);
};
} | new CertificateOperationUpdateParameter().cancellationRequested(true), CONTENT_TYPE_HEADER_VALUE, Context.NONE); | new CertificateOperationUpdateParameter().cancellationRequested(true);
return service.updateCertificateOperation(endpoint, certificateName, API_VERSION, ACCEPT_LANGUAGE, parameter, CONTENT_TYPE_HEADER_VALUE, context)
.doOnRequest(ignored -> logger.info("Cancelling certificate operation - {} | class CertificateAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private String endpoint;
private final CertificateService service;
private final Clie... | class CertificateAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private final String endpoint;
private final CertificateService service;
private fina... |
fixed. | private Consumer<Poller<CertificateOperation>> cancelOperation(String name) {
return poller -> {
service.updateCertificateOperation(endpoint, name, API_VERSION, ACCEPT_LANGUAGE,
new CertificateOperationUpdateParameter().cancellationRequested(true), CONTENT_TYPE_HEADER_VALUE, Context.NONE);
};
} | new CertificateOperationUpdateParameter().cancellationRequested(true), CONTENT_TYPE_HEADER_VALUE, Context.NONE); | new CertificateOperationUpdateParameter().cancellationRequested(true);
return service.updateCertificateOperation(endpoint, certificateName, API_VERSION, ACCEPT_LANGUAGE, parameter, CONTENT_TYPE_HEADER_VALUE, context)
.doOnRequest(ignored -> logger.info("Cancelling certificate operation - {} | class CertificateAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private String endpoint;
private final CertificateService service;
private final Clie... | class CertificateAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private final String endpoint;
private final CertificateService service;
private fina... |
made it 10 seconds. The trivial cases of certificate take around 5 - 15 seconds to finish. Third party issuers cases can take longer. | public Poller<CertificateOperation> createCertificate(String name, CertificatePolicy policy, Map<String, String> tags) {
return new Poller<CertificateOperation>(Duration.ofSeconds(1), createPollOperation(name), actvationOperation(name, policy, tags), cancelOperation(name));
} | return new Poller<CertificateOperation>(Duration.ofSeconds(1), createPollOperation(name), actvationOperation(name, policy, tags), cancelOperation(name)); | public Poller<CertificateOperation> createCertificate(String name, CertificatePolicy policy, Map<String, String> tags) {
return new Poller<CertificateOperation>(Duration.ofSeconds(1), createPollOperation(name), activationOperation(name, policy, tags), cancelOperation(name));
} | class CertificateAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private String endpoint;
private final CertificateService service;
private final Clie... | class CertificateAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private final String endpoint;
private final CertificateService service;
private fina... |
back to 1 second now | public Poller<CertificateOperation> createCertificate(String name, CertificatePolicy policy, Map<String, String> tags) {
return new Poller<CertificateOperation>(Duration.ofSeconds(1), createPollOperation(name), actvationOperation(name, policy, tags), cancelOperation(name));
} | return new Poller<CertificateOperation>(Duration.ofSeconds(1), createPollOperation(name), actvationOperation(name, policy, tags), cancelOperation(name)); | public Poller<CertificateOperation> createCertificate(String name, CertificatePolicy policy, Map<String, String> tags) {
return new Poller<CertificateOperation>(Duration.ofSeconds(1), createPollOperation(name), activationOperation(name, policy, tags), cancelOperation(name));
} | class CertificateAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private String endpoint;
private final CertificateService service;
private final Clie... | class CertificateAsyncClient {
static final String API_VERSION = "7.0";
static final String ACCEPT_LANGUAGE = "en-US";
static final int DEFAULT_MAX_PAGE_RESULTS = 25;
static final String CONTENT_TYPE_HEADER_VALUE = "application/json";
private final String endpoint;
private final CertificateService service;
private fina... |
Causing Javadoc generation issues since the line is over 120 characters. Also for all these existence calls can we just use `.value()` as Boolean toString will implicitly use the boolean value. | public void existsWithResponse() {
client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.value().booleanValue()));
} | client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.value().booleanValue())); | public void existsWithResponse() {
client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.value()));
} | class ContainerAsyncClientJavaDocCodeSnippets {
private ContainerAsyncClient client = JavaDocCodeSnippetsHelpers.getContainerAsyncClient();
private String blobName = "blobName";
private String snapshot = "snapshot";
private String leaseId = "leaseId";
private String proposedId = "proposedId";
private int leaseDuration ... | class ContainerAsyncClientJavaDocCodeSnippets {
private ContainerAsyncClient client = JavaDocCodeSnippetsHelpers.getContainerAsyncClient();
private String blobName = "blobName";
private String snapshot = "snapshot";
private String leaseId = "leaseId";
private String proposedId = "proposedId";
private int leaseDuration ... |
updated | public void existsWithResponse() {
client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.value().booleanValue()));
} | client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.value().booleanValue())); | public void existsWithResponse() {
client.existsWithResponse().subscribe(response -> System.out.printf("Exists? %b%n", response.value()));
} | class ContainerAsyncClientJavaDocCodeSnippets {
private ContainerAsyncClient client = JavaDocCodeSnippetsHelpers.getContainerAsyncClient();
private String blobName = "blobName";
private String snapshot = "snapshot";
private String leaseId = "leaseId";
private String proposedId = "proposedId";
private int leaseDuration ... | class ContainerAsyncClientJavaDocCodeSnippets {
private ContainerAsyncClient client = JavaDocCodeSnippetsHelpers.getContainerAsyncClient();
private String blobName = "blobName";
private String snapshot = "snapshot";
private String leaseId = "leaseId";
private String proposedId = "proposedId";
private int leaseDuration ... |
Does this fail checkstyles? I thought the `:` would be on a new line | public Mono<String> updateCheckpoint(Checkpoint checkpoint) {
if (checkpoint.sequenceNumber() == null && checkpoint.offset() == null) {
throw logger.logExceptionAsWarning(Exceptions
.propagate(new IllegalStateException(
"Both sequence number and offset cannot be null when updating a checkpoint")));
}
String partitionId... | String sequenceNumber = checkpoint.sequenceNumber() == null ? null : | public Mono<String> updateCheckpoint(Checkpoint checkpoint) {
if (checkpoint.sequenceNumber() == null && checkpoint.offset() == null) {
throw logger.logExceptionAsWarning(Exceptions
.propagate(new IllegalStateException(
"Both sequence number and offset cannot be null when updating a checkpoint")));
}
String partitionId... | class BlobPartitionManager implements PartitionManager {
private static final String SEQUENCE_NUMBER = "sequenceNumber";
private static final String OFFSET = "offset";
private static final String OWNER_ID = "ownerId";
private static final String ETAG = "eTag";
private static final String BLOB_PATH_SEPARATOR = "/";
priv... | class BlobPartitionManager implements PartitionManager {
private static final String SEQUENCE_NUMBER = "SequenceNumber";
private static final String OFFSET = "Offset";
private static final String OWNER_ID = "OwnerId";
private static final String ETAG = "eTag";
private static final String BLOB_PATH_SEPARATOR = "/";
priv... |
Just to make sure, is metadata case sensitive? @chradek was mentioning some bug about it.. and it would be nice to interop between language libraries. | private Metadata getMetadata(String owner, String sequenceNumber, String offset) {
Metadata metadata = new Metadata();
metadata.put("ownerId", owner);
metadata.put("sequenceNumber", sequenceNumber);
metadata.put("offset", offset);
return metadata;
} | Metadata metadata = new Metadata(); | private Metadata getMetadata(String owner, String sequenceNumber, String offset) {
Metadata metadata = new Metadata();
metadata.put("OwnerId", owner);
metadata.put("SequenceNumber", sequenceNumber);
metadata.put("Offset", offset);
return metadata;
} | class BlobPartitionManagerTest {
@Mock
private ContainerAsyncClient containerAsyncClient;
@Mock
private BlockBlobAsyncClient blockBlobAsyncClient;
@Mock
private BlobAsyncClient blobAsyncClient;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
@Test
public void testListOwnerShip() {
BlobPartitionManag... | class BlobPartitionManagerTest {
@Mock
private ContainerAsyncClient containerAsyncClient;
@Mock
private BlockBlobAsyncClient blockBlobAsyncClient;
@Mock
private BlobAsyncClient blobAsyncClient;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
@Test
public void testListOwnerShip() {
BlobPartitionManag... |
Yeah, I discussed this with Shivangi and we will all have the same name for interoperability. I have a comment in the source class to use the same keys in all languages. | private Metadata getMetadata(String owner, String sequenceNumber, String offset) {
Metadata metadata = new Metadata();
metadata.put("ownerId", owner);
metadata.put("sequenceNumber", sequenceNumber);
metadata.put("offset", offset);
return metadata;
} | Metadata metadata = new Metadata(); | private Metadata getMetadata(String owner, String sequenceNumber, String offset) {
Metadata metadata = new Metadata();
metadata.put("OwnerId", owner);
metadata.put("SequenceNumber", sequenceNumber);
metadata.put("Offset", offset);
return metadata;
} | class BlobPartitionManagerTest {
@Mock
private ContainerAsyncClient containerAsyncClient;
@Mock
private BlockBlobAsyncClient blockBlobAsyncClient;
@Mock
private BlobAsyncClient blobAsyncClient;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
@Test
public void testListOwnerShip() {
BlobPartitionManag... | class BlobPartitionManagerTest {
@Mock
private ContainerAsyncClient containerAsyncClient;
@Mock
private BlockBlobAsyncClient blockBlobAsyncClient;
@Mock
private BlobAsyncClient blobAsyncClient;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
@Test
public void testListOwnerShip() {
BlobPartitionManag... |
Yeah, it did. Fixed now. | public Mono<String> updateCheckpoint(Checkpoint checkpoint) {
if (checkpoint.sequenceNumber() == null && checkpoint.offset() == null) {
throw logger.logExceptionAsWarning(Exceptions
.propagate(new IllegalStateException(
"Both sequence number and offset cannot be null when updating a checkpoint")));
}
String partitionId... | String sequenceNumber = checkpoint.sequenceNumber() == null ? null : | public Mono<String> updateCheckpoint(Checkpoint checkpoint) {
if (checkpoint.sequenceNumber() == null && checkpoint.offset() == null) {
throw logger.logExceptionAsWarning(Exceptions
.propagate(new IllegalStateException(
"Both sequence number and offset cannot be null when updating a checkpoint")));
}
String partitionId... | class BlobPartitionManager implements PartitionManager {
private static final String SEQUENCE_NUMBER = "sequenceNumber";
private static final String OFFSET = "offset";
private static final String OWNER_ID = "ownerId";
private static final String ETAG = "eTag";
private static final String BLOB_PATH_SEPARATOR = "/";
priv... | class BlobPartitionManager implements PartitionManager {
private static final String SEQUENCE_NUMBER = "SequenceNumber";
private static final String OFFSET = "Offset";
private static final String OWNER_ID = "OwnerId";
private static final String ETAG = "eTag";
private static final String BLOB_PATH_SEPARATOR = "/";
priv... |
Also, started a thread on Teams to finalize the name. | private Metadata getMetadata(String owner, String sequenceNumber, String offset) {
Metadata metadata = new Metadata();
metadata.put("ownerId", owner);
metadata.put("sequenceNumber", sequenceNumber);
metadata.put("offset", offset);
return metadata;
} | Metadata metadata = new Metadata(); | private Metadata getMetadata(String owner, String sequenceNumber, String offset) {
Metadata metadata = new Metadata();
metadata.put("OwnerId", owner);
metadata.put("SequenceNumber", sequenceNumber);
metadata.put("Offset", offset);
return metadata;
} | class BlobPartitionManagerTest {
@Mock
private ContainerAsyncClient containerAsyncClient;
@Mock
private BlockBlobAsyncClient blockBlobAsyncClient;
@Mock
private BlobAsyncClient blobAsyncClient;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
@Test
public void testListOwnerShip() {
BlobPartitionManag... | class BlobPartitionManagerTest {
@Mock
private ContainerAsyncClient containerAsyncClient;
@Mock
private BlockBlobAsyncClient blockBlobAsyncClient;
@Mock
private BlobAsyncClient blobAsyncClient;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
@Test
public void testListOwnerShip() {
BlobPartitionManag... |
Does that compile? | public static void main(String[] args) throws IllegalArgumentException {
ZipkinTraceExporter.createAndRegister("http:
TraceConfig traceConfig = Tracing.getTraceConfig();
TraceParams activeTraceParams = traceConfig.getActiveTraceParams();
traceConfig.updateActiveTraceParams(activeTraceParams.toBuilder().setSampler(Sampl... | client.setSecret(, "sskdjfsdasdjsd") | public static void main(String[] args) throws IllegalArgumentException, InterruptedException {
ZipkinTraceExporter.createAndRegister("http:
TraceConfig traceConfig = Tracing.getTraceConfig();
TraceParams activeTraceParams = traceConfig.getActiveTraceParams();
traceConfig.updateActiveTraceParams(activeTraceParams.toBuil... | class ListOperationsAsync {
/**
* Authenticates with the key vault and shows how to list secrets and list versions of a specific secret in the key vault
* with trace spans exported to zipkin.
*
* Please refer to the <a href=https:
* for more documentation on using a zipkin exporter.
*
* @param args Unused. Arguments t... | class ListOperationsAsync {
/**
* Authenticates with the key vault and shows how to list secrets and list versions of a specific secret in the key
* vault with trace spans exported to Zipkin.
*
* Please refer to the <a href=https:
* using a Zipkin exporter.
*
* @param args Unused. Arguments to the program.
* @throws Il... |
I'm wary of this change. I've run across Zulu's JVM messing up during compilation and bombing out on these because it fails to interpret this method reference. I would advise to keep the changes limited to the scope of this PR. | public void testWithMultiplePartitions() throws Exception {
final CountDownLatch count = new CountDownLatch(1);
when(eventHubAsyncClient.getPartitionIds()).thenReturn(Flux.just("1", "2", "3"));
when(eventHubAsyncClient.eventHubName()).thenReturn("test-eh");
when(eventHubAsyncClient
.createConsumer(anyString(), eq("1"),... | Mono.fromRunnable(count::countDown).thenMany(Flux.just(eventData1, eventData2))); | public void testWithMultiplePartitions() throws Exception {
final CountDownLatch count = new CountDownLatch(1);
when(eventHubAsyncClient.getPartitionIds()).thenReturn(Flux.just("1", "2", "3"));
when(eventHubAsyncClient.getEventHubName()).thenReturn("test-eh");
when(eventHubAsyncClient
.createConsumer(anyString(), eq("1... | class EventProcessorTest {
@Mock
private EventHubAsyncClient eventHubAsyncClient;
@Mock
private EventHubAsyncConsumer consumer1, consumer2, consumer3;
@Mock
private EventData eventData1, eventData2, eventData3, eventData4;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
/**
* Tests all the happy cas... | class EventProcessorTest {
@Mock
private EventHubAsyncClient eventHubAsyncClient;
@Mock
private EventHubAsyncConsumer consumer1, consumer2, consumer3;
@Mock
private EventData eventData1, eventData2, eventData3, eventData4;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
@After
public void teardown()... |
Same with the one below. I'll find the bug … The one on the left was causing the thing to fail compilation. https://github.com/Azure/azure-sdk-for-java/pull/4038/commits/69577ac0aeaa0a6f2d658e57a832b493d9f6c167 https://bugs.openjdk.java.net/browse/JDK-8221420 | public void testWithMultiplePartitions() throws Exception {
final CountDownLatch count = new CountDownLatch(1);
when(eventHubAsyncClient.getPartitionIds()).thenReturn(Flux.just("1", "2", "3"));
when(eventHubAsyncClient.eventHubName()).thenReturn("test-eh");
when(eventHubAsyncClient
.createConsumer(anyString(), eq("1"),... | Mono.fromRunnable(count::countDown).thenMany(Flux.just(eventData1, eventData2))); | public void testWithMultiplePartitions() throws Exception {
final CountDownLatch count = new CountDownLatch(1);
when(eventHubAsyncClient.getPartitionIds()).thenReturn(Flux.just("1", "2", "3"));
when(eventHubAsyncClient.getEventHubName()).thenReturn("test-eh");
when(eventHubAsyncClient
.createConsumer(anyString(), eq("1... | class EventProcessorTest {
@Mock
private EventHubAsyncClient eventHubAsyncClient;
@Mock
private EventHubAsyncConsumer consumer1, consumer2, consumer3;
@Mock
private EventData eventData1, eventData2, eventData3, eventData4;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
/**
* Tests all the happy cas... | class EventProcessorTest {
@Mock
private EventHubAsyncClient eventHubAsyncClient;
@Mock
private EventHubAsyncConsumer consumer1, consumer2, consumer3;
@Mock
private EventData eventData1, eventData2, eventData3, eventData4;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
@After
public void teardown()... |
Using .block() makes this sample a synchronous one and does not showcase how to use it asynchronously. | public static void main(String[] args) throws IllegalArgumentException {
ZipkinTraceExporter.createAndRegister("http:
TraceConfig traceConfig = Tracing.getTraceConfig();
TraceParams activeTraceParams = traceConfig.getActiveTraceParams();
traceConfig.updateActiveTraceParams(activeTraceParams.toBuilder().setSampler(Sampl... | client.setSecret("BankAccountPassword", "new password") | public static void main(String[] args) throws IllegalArgumentException, InterruptedException {
ZipkinTraceExporter.createAndRegister("http:
TraceConfig traceConfig = Tracing.getTraceConfig();
TraceParams activeTraceParams = traceConfig.getActiveTraceParams();
traceConfig.updateActiveTraceParams(activeTraceParams.toBuil... | class ListOperationsAsync {
/**
* Authenticates with the key vault and shows how to list secrets and list versions of a specific secret in the key
* vault with trace spans exported to zipkin.
*
* Please refer to the <a href=https:
* using a zipkin exporter.
*
* @param args Unused. Arguments to the program.
* @throws I... | class ListOperationsAsync {
/**
* Authenticates with the key vault and shows how to list secrets and list versions of a specific secret in the key
* vault with trace spans exported to Zipkin.
*
* Please refer to the <a href=https:
* using a Zipkin exporter.
*
* @param args Unused. Arguments to the program.
* @throws Il... |
removed. | public static void main(String[] args) throws IllegalArgumentException {
ZipkinTraceExporter.createAndRegister("http:
TraceConfig traceConfig = Tracing.getTraceConfig();
TraceParams activeTraceParams = traceConfig.getActiveTraceParams();
traceConfig.updateActiveTraceParams(activeTraceParams.toBuilder().setSampler(Sampl... | client.setSecret("BankAccountPassword", "new password") | public static void main(String[] args) throws IllegalArgumentException, InterruptedException {
ZipkinTraceExporter.createAndRegister("http:
TraceConfig traceConfig = Tracing.getTraceConfig();
TraceParams activeTraceParams = traceConfig.getActiveTraceParams();
traceConfig.updateActiveTraceParams(activeTraceParams.toBuil... | class ListOperationsAsync {
/**
* Authenticates with the key vault and shows how to list secrets and list versions of a specific secret in the key
* vault with trace spans exported to zipkin.
*
* Please refer to the <a href=https:
* using a zipkin exporter.
*
* @param args Unused. Arguments to the program.
* @throws I... | class ListOperationsAsync {
/**
* Authenticates with the key vault and shows how to list secrets and list versions of a specific secret in the key
* vault with trace spans exported to Zipkin.
*
* Please refer to the <a href=https:
* using a Zipkin exporter.
*
* @param args Unused. Arguments to the program.
* @throws Il... |
Is there an issue created for this so we dont lose track of it? | public void setup() throws Exception {
org.junit.Assume.assumeTrue("Skipping these tests until we mock or record it", false);
cachePersister = new CachePersister.Builder().build();
accessAspect = new PersistentTokenCacheAccessAspect();
confApp = ConfidentialClientApplication.builder(TestConfiguration.CONFIDENTIAL_CLIEN... | org.junit.Assume.assumeTrue("Skipping these tests until we mock or record it", false); | public void setup() throws Exception {
org.junit.Assume.assumeTrue("Skipping these tests until we mock or record it", false);
cachePersister = new CachePersister.Builder().build();
accessAspect = new PersistentTokenCacheAccessAspect();
confApp = ConfidentialClientApplication.builder(TestConfiguration.CONFIDENTIAL_CLIEN... | class CrossProgramVSTest {
CachePersister cachePersister;
PersistentTokenCacheAccessAspect accessAspect;
private ConfidentialClientApplication confApp;
private ClientCredentialParameters confParameters;
private int count = 0;
@Before
@Test
public void readCacheAfterVSAzureLogin() {
byte[] currJsonBytes = cachePersister... | class CrossProgramVSTest {
CachePersister cachePersister;
PersistentTokenCacheAccessAspect accessAspect;
private ConfidentialClientApplication confApp;
private ClientCredentialParameters confParameters;
private int count = 0;
@Before
@Test
public void readCacheAfterVSAzureLogin() {
byte[] currJsonBytes = cachePersister... |
Created at https://github.com/Azure/azure-sdk-for-java/issues/5328 and added to next preview release | public void setup() throws Exception {
org.junit.Assume.assumeTrue("Skipping these tests until we mock or record it", false);
cachePersister = new CachePersister.Builder().build();
accessAspect = new PersistentTokenCacheAccessAspect();
confApp = ConfidentialClientApplication.builder(TestConfiguration.CONFIDENTIAL_CLIEN... | org.junit.Assume.assumeTrue("Skipping these tests until we mock or record it", false); | public void setup() throws Exception {
org.junit.Assume.assumeTrue("Skipping these tests until we mock or record it", false);
cachePersister = new CachePersister.Builder().build();
accessAspect = new PersistentTokenCacheAccessAspect();
confApp = ConfidentialClientApplication.builder(TestConfiguration.CONFIDENTIAL_CLIEN... | class CrossProgramVSTest {
CachePersister cachePersister;
PersistentTokenCacheAccessAspect accessAspect;
private ConfidentialClientApplication confApp;
private ClientCredentialParameters confParameters;
private int count = 0;
@Before
@Test
public void readCacheAfterVSAzureLogin() {
byte[] currJsonBytes = cachePersister... | class CrossProgramVSTest {
CachePersister cachePersister;
PersistentTokenCacheAccessAspect accessAspect;
private ConfidentialClientApplication confApp;
private ClientCredentialParameters confParameters;
private int count = 0;
@Before
@Test
public void readCacheAfterVSAzureLogin() {
byte[] currJsonBytes = cachePersister... |
Shouldn't the `key()` and `value()` method also be renamed? Same in async client too. ``` return setSetting(new ConfigurationSetting().setKey(key).setValue(value), Context.NONE).getValue(); ``` | public ConfigurationSetting setSetting(String key, String value) {
return setSetting(new ConfigurationSetting().key(key).value(value), Context.NONE).getValue();
} | return setSetting(new ConfigurationSetting().key(key).value(value), Context.NONE).getValue(); | public ConfigurationSetting setSetting(String key, String value) {
return setSettingWithResponse(new ConfigurationSetting().setKey(key).setValue(value), Context.NONE).getValue();
} | class ConfigurationClient {
private final ConfigurationAsyncClient client;
/**
* Creates a ConfigurationClient that sends requests to the configuration service at {@code serviceEndpoint}.
* Each service call goes through the {@code pipeline}.
*
* @param client The {@link ConfigurationAsyncClient} that the client routes... | class ConfigurationClient {
private final ConfigurationAsyncClient client;
/**
* Creates a ConfigurationClient that sends requests to the configuration service at {@code serviceEndpoint}. Each
* service call goes through the {@code pipeline}.
*
* @param client The {@link ConfigurationAsyncClient} that the client routes... |
same here | public ConfigurationSetting updateSetting(String key, String value) {
return updateSetting(new ConfigurationSetting().key(key).value(value), Context.NONE).getValue();
} | return updateSetting(new ConfigurationSetting().key(key).value(value), Context.NONE).getValue(); | public ConfigurationSetting updateSetting(String key, String value) {
return updateSetting(new ConfigurationSetting().setKey(key).setValue(value), Context.NONE).getValue();
} | class ConfigurationClient {
private final ConfigurationAsyncClient client;
/**
* Creates a ConfigurationClient that sends requests to the configuration service at {@code serviceEndpoint}.
* Each service call goes through the {@code pipeline}.
*
* @param client The {@link ConfigurationAsyncClient} that the client routes... | class ConfigurationClient {
private final ConfigurationAsyncClient client;
/**
* Creates a ConfigurationClient that sends requests to the configuration service at {@code serviceEndpoint}. Each
* service call goes through the {@code pipeline}.
*
* @param client The {@link ConfigurationAsyncClient} that the client routes... |
`getBody()`? | public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) {
final Flux<ByteBuffer> contents = context.getHttpRequest().body() == null
? Flux.just(getEmptyBuffer())
: context.getHttpRequest().body();
return credentials
.getAuthorizationHeadersAsync(
context.getHttpRequest().getUrl()... | : context.getHttpRequest().body(); | public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) {
final Flux<ByteBuffer> contents = context.getHttpRequest().getBody() == null
? Flux.just(getEmptyBuffer())
: context.getHttpRequest().getBody();
return credentials
.getAuthorizationHeadersAsync(
context.getHttpRequest().ge... | class ConfigurationCredentialsPolicy implements HttpPipelinePolicy {
private final ConfigurationClientCredentials credentials;
/**
* Creates an instance that is able to apply a {@link ConfigurationClientCredentials} credential to a request in the
* pipeline.
*
* @param credentials the credential information to authenti... | class ConfigurationCredentialsPolicy implements HttpPipelinePolicy {
private final ConfigurationClientCredentials credentials;
/**
* Creates an instance that is able to apply a {@link ConfigurationClientCredentials} credential to a request in the
* pipeline.
*
* @param credentials the credential information to authenti... |
`getKey()` and `getValue()` | public void setSetting() {
ConfigurationClient configurationClient = createSyncConfigurationClient();
ConfigurationSetting result = configurationClient
.setSetting("prodDBConnection", "db_connection");
System.out.printf("Key: %s, Value: %s", result.key(), result.value());
result = configurationClient.setSetting("prodDB... | System.out.printf("Key: %s, Value: %s", responseSetting.getValue().key(), responseSetting.getValue().value()); | public void setSetting() {
ConfigurationClient configurationClient = createSyncConfigurationClient();
ConfigurationSetting result = configurationClient
.setSetting("prodDBConnection", "db_connection");
System.out.printf("Key: %s, Value: %s", result.getKey(), result.getValue());
result = configurationClient.setSetting("... | class ConfigurationClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link ConfigurationClient}
* @return An instance of {@link ConfigurationClient}
* @throws IllegalStateExc... | class ConfigurationClientJavaDocCodeSnippets {
private String key1 = "key1";
private String key2 = "key2";
private String value1 = "val1";
private String value2 = "val2";
/**
* Generates code sample for creating a {@link ConfigurationClient}
*
* @return An instance of {@link ConfigurationClient}
* @throws IllegalStateE... |
`getStatusCode()` | static void assertConfigurationEquals(ConfigurationSetting expected, Response<ConfigurationSetting> response, final int expectedStatusCode) {
assertNotNull(response);
assertEquals(expectedStatusCode, response.statusCode());
assertConfigurationEquals(expected, response.getValue());
} | assertEquals(expectedStatusCode, response.statusCode()); | static void assertConfigurationEquals(ConfigurationSetting expected, Response<ConfigurationSetting> response, final int expectedStatusCode) {
assertNotNull(response);
assertEquals(expectedStatusCode, response.getStatusCode());
assertConfigurationEquals(expected, response.getValue());
} | class ConfigurationClientTestBase extends TestBase {
private static final String AZURE_APPCONFIG_CONNECTION_STRING = "AZURE_APPCONFIG_CONNECTION_STRING";
private static final String KEY_PREFIX = "key";
private static final String LABEL_PREFIX = "label";
private static final int PREFIX_LENGTH = 8;
private static final i... | class ConfigurationClientTestBase extends TestBase {
private static final String AZURE_APPCONFIG_CONNECTION_STRING = "AZURE_APPCONFIG_CONNECTION_STRING";
private static final String KEY_PREFIX = "key";
private static final String LABEL_PREFIX = "label";
private static final int PREFIX_LENGTH = 8;
private static final i... |
Yep, once app configuration is refactored. | public ConfigurationSetting setSetting(String key, String value) {
return setSetting(new ConfigurationSetting().key(key).value(value), Context.NONE).getValue();
} | return setSetting(new ConfigurationSetting().key(key).value(value), Context.NONE).getValue(); | public ConfigurationSetting setSetting(String key, String value) {
return setSettingWithResponse(new ConfigurationSetting().setKey(key).setValue(value), Context.NONE).getValue();
} | class ConfigurationClient {
private final ConfigurationAsyncClient client;
/**
* Creates a ConfigurationClient that sends requests to the configuration service at {@code serviceEndpoint}.
* Each service call goes through the {@code pipeline}.
*
* @param client The {@link ConfigurationAsyncClient} that the client routes... | class ConfigurationClient {
private final ConfigurationAsyncClient client;
/**
* Creates a ConfigurationClient that sends requests to the configuration service at {@code serviceEndpoint}. Each
* service call goes through the {@code pipeline}.
*
* @param client The {@link ConfigurationAsyncClient} that the client routes... |
@srnagar `String eventHubName()` is not renamed. | private static String getExpression(EventPosition eventPosition) {
final String isInclusiveFlag = eventPosition.isInclusive() ? "=" : "";
if (eventPosition.getOffset() != null) {
return String.format(
AmqpConstants.AMQP_ANNOTATION_FORMAT, OFFSET_ANNOTATION_NAME.getValue(),
isInclusiveFlag,
eventPosition.getOffset());
}... | ms = Long.toString(Long.MAX_VALUE); | private static String getExpression(EventPosition eventPosition) {
final String isInclusiveFlag = eventPosition.isInclusive() ? "=" : "";
if (eventPosition.getOffset() != null) {
return String.format(
AmqpConstants.AMQP_ANNOTATION_FORMAT, OFFSET_ANNOTATION_NAME.getValue(),
isInclusiveFlag,
eventPosition.getOffset());
}... | class EventHubAsyncClient implements Closeable {
/**
* The name of the default consumer group in the Event Hubs service.
*/
public static final String DEFAULT_CONSUMER_GROUP_NAME = "$Default";
private static final String RECEIVER_ENTITY_PATH_FORMAT = "%s/ConsumerGroups/%s/Partitions/%s";
private static final String SEN... | class EventHubAsyncClient implements Closeable {
/**
* The name of the default consumer group in the Event Hubs service.
*/
public static final String DEFAULT_CONSUMER_GROUP_NAME = "$Default";
private static final String RECEIVER_ENTITY_PATH_FORMAT = "%s/ConsumerGroups/%s/Partitions/%s";
private static final String SEN... |
Updated | private static String getExpression(EventPosition eventPosition) {
final String isInclusiveFlag = eventPosition.isInclusive() ? "=" : "";
if (eventPosition.getOffset() != null) {
return String.format(
AmqpConstants.AMQP_ANNOTATION_FORMAT, OFFSET_ANNOTATION_NAME.getValue(),
isInclusiveFlag,
eventPosition.getOffset());
}... | ms = Long.toString(Long.MAX_VALUE); | private static String getExpression(EventPosition eventPosition) {
final String isInclusiveFlag = eventPosition.isInclusive() ? "=" : "";
if (eventPosition.getOffset() != null) {
return String.format(
AmqpConstants.AMQP_ANNOTATION_FORMAT, OFFSET_ANNOTATION_NAME.getValue(),
isInclusiveFlag,
eventPosition.getOffset());
}... | class EventHubAsyncClient implements Closeable {
/**
* The name of the default consumer group in the Event Hubs service.
*/
public static final String DEFAULT_CONSUMER_GROUP_NAME = "$Default";
private static final String RECEIVER_ENTITY_PATH_FORMAT = "%s/ConsumerGroups/%s/Partitions/%s";
private static final String SEN... | class EventHubAsyncClient implements Closeable {
/**
* The name of the default consumer group in the Event Hubs service.
*/
public static final String DEFAULT_CONSUMER_GROUP_NAME = "$Default";
private static final String RECEIVER_ENTITY_PATH_FORMAT = "%s/ConsumerGroups/%s/Partitions/%s";
private static final String SEN... |
cpk stands for customer provided key, and it belongs to a feature of the same name. | public BlobAsyncClient buildBlobAsyncClient() {
Objects.requireNonNull(containerName);
Objects.requireNonNull(blobName);
HttpPipeline pipeline = super.getPipeline();
if (pipeline == null) {
pipeline = super.buildPipeline();
}
return new BlobAsyncClient(new AzureBlobStorageBuilder()
.url(String.format("%s/%s/%s", endpoi... | .build(), snapshot, cpk); | public BlobAsyncClient buildBlobAsyncClient() {
Objects.requireNonNull(containerName, "'containerName' cannot be null.");
Objects.requireNonNull(blobName, "'blobName' cannot be null.");
HttpPipeline pipeline = super.getPipeline();
if (pipeline == null) {
pipeline = super.buildPipeline();
}
return new BlobAsyncClient(ne... | class BlobClientBuilder extends BaseBlobClientBuilder<BlobClientBuilder> {
private final ClientLogger logger = new ClientLogger(BlobClientBuilder.class);
private String containerName;
private String blobName;
private String snapshot;
/**
* Creates a builder instance that is able to configure and construct {@link BlobCl... | class BlobClientBuilder extends BaseBlobClientBuilder<BlobClientBuilder> {
private final ClientLogger logger = new ClientLogger(BlobClientBuilder.class);
private String containerName;
private String blobName;
private String snapshot;
/**
* Creates a builder instance that is able to configure and construct {@link BlobCl... |
We should use logger here and at other places in this class. It is available from TestSuiteBase, which gets it from DocumentClientTest | public void beforeClass() throws Exception {
System.out.println("OrderbyDocumentQueryTest.beforeClass");
client = clientBuilder().build();
createdDatabase = getSharedCosmosDatabase(client);
createdCollection = getSharedMultiPartitionCosmosContainer(client);
System.out.println("bef: truncate collection");
truncateCollec... | System.out.println("OrderbyDocumentQueryTest.beforeClass"); | public void beforeClass() throws Exception {
client = clientBuilder().build();
createdDatabase = getSharedCosmosDatabase(client);
createdCollection = getSharedMultiPartitionCosmosContainer(client);
truncateCollection(createdCollection);
List<Map<String, Object>> keyValuePropsList = new ArrayList<>();
Map<String, Object... | class OrderbyDocumentQueryTest extends TestSuiteBase {
private final double minQueryRequestChargePerPartition = 2.0;
private CosmosClient client;
private CosmosContainer createdCollection;
private CosmosDatabase createdDatabase;
private List<CosmosItemProperties> createdDocuments = new ArrayList<>();
private int number... | class OrderbyDocumentQueryTest extends TestSuiteBase {
private final double minQueryRequestChargePerPartition = 2.0;
private CosmosClient client;
private CosmosContainer createdCollection;
private CosmosDatabase createdDatabase;
private List<CosmosItemProperties> createdDocuments = new ArrayList<>();
private int number... |
Still under debug. I dont need these and I will remove | public void beforeClass() throws Exception {
System.out.println("OrderbyDocumentQueryTest.beforeClass");
client = clientBuilder().build();
createdDatabase = getSharedCosmosDatabase(client);
createdCollection = getSharedMultiPartitionCosmosContainer(client);
System.out.println("bef: truncate collection");
truncateCollec... | System.out.println("OrderbyDocumentQueryTest.beforeClass"); | public void beforeClass() throws Exception {
client = clientBuilder().build();
createdDatabase = getSharedCosmosDatabase(client);
createdCollection = getSharedMultiPartitionCosmosContainer(client);
truncateCollection(createdCollection);
List<Map<String, Object>> keyValuePropsList = new ArrayList<>();
Map<String, Object... | class OrderbyDocumentQueryTest extends TestSuiteBase {
private final double minQueryRequestChargePerPartition = 2.0;
private CosmosClient client;
private CosmosContainer createdCollection;
private CosmosDatabase createdDatabase;
private List<CosmosItemProperties> createdDocuments = new ArrayList<>();
private int number... | class OrderbyDocumentQueryTest extends TestSuiteBase {
private final double minQueryRequestChargePerPartition = 2.0;
private CosmosClient client;
private CosmosContainer createdCollection;
private CosmosDatabase createdDatabase;
private List<CosmosItemProperties> createdDocuments = new ArrayList<>();
private int number... |
Removed | public void beforeClass() throws Exception {
System.out.println("OrderbyDocumentQueryTest.beforeClass");
client = clientBuilder().build();
createdDatabase = getSharedCosmosDatabase(client);
createdCollection = getSharedMultiPartitionCosmosContainer(client);
System.out.println("bef: truncate collection");
truncateCollec... | System.out.println("OrderbyDocumentQueryTest.beforeClass"); | public void beforeClass() throws Exception {
client = clientBuilder().build();
createdDatabase = getSharedCosmosDatabase(client);
createdCollection = getSharedMultiPartitionCosmosContainer(client);
truncateCollection(createdCollection);
List<Map<String, Object>> keyValuePropsList = new ArrayList<>();
Map<String, Object... | class OrderbyDocumentQueryTest extends TestSuiteBase {
private final double minQueryRequestChargePerPartition = 2.0;
private CosmosClient client;
private CosmosContainer createdCollection;
private CosmosDatabase createdDatabase;
private List<CosmosItemProperties> createdDocuments = new ArrayList<>();
private int number... | class OrderbyDocumentQueryTest extends TestSuiteBase {
private final double minQueryRequestChargePerPartition = 2.0;
private CosmosClient client;
private CosmosContainer createdCollection;
private CosmosDatabase createdDatabase;
private List<CosmosItemProperties> createdDocuments = new ArrayList<>();
private int number... |
Good catch | public NettyAsyncHttpClient build() {
HttpClient nettyHttpClient = HttpClient.create()
.port(port)
.wiretap(enableWiretap)
.tcpConfiguration(tcpConfig -> {
if (nioEventLoopGroup != null) {
tcpConfig = tcpConfig.runOn(nioEventLoopGroup);
}
if (proxyOptions != null) {
ProxyProvider.Proxy nettyProxy;
switch (proxyOptions.... | throw logger.logExceptionAsWarning(new IllegalStateException( | public NettyAsyncHttpClient build() {
HttpClient nettyHttpClient = HttpClient.create()
.port(port)
.wiretap(enableWiretap)
.tcpConfiguration(tcpConfig -> {
if (nioEventLoopGroup != null) {
tcpConfig = tcpConfig.runOn(nioEventLoopGroup);
}
if (proxyOptions != null) {
ProxyProvider.Proxy nettyProxy;
switch (proxyOptions.... | class NettyAsyncHttpClientBuilder {
private final ClientLogger logger = new ClientLogger(NettyAsyncHttpClientBuilder.class);
private ProxyOptions proxyOptions;
private boolean enableWiretap;
private int port = 80;
private NioEventLoopGroup nioEventLoopGroup;
/**
* Creates a new builder instance, where a builder is capa... | class NettyAsyncHttpClientBuilder {
private final ClientLogger logger = new ClientLogger(NettyAsyncHttpClientBuilder.class);
private ProxyOptions proxyOptions;
private boolean enableWiretap;
private int port = 80;
private NioEventLoopGroup nioEventLoopGroup;
/**
* Creates a new builder instance, where a builder is capa... |
Only checking nullness should suffice, no `Interceptors` is allowed. | public OkHttpAsyncHttpClientBuilder networkInterceptors(List<Interceptor> networkInterceptors) {
this.networkInterceptors = Objects.requireNonNull(networkInterceptors, "networkInterceptors cannot be null.");
return this;
} | this.networkInterceptors = Objects.requireNonNull(networkInterceptors, "networkInterceptors cannot be null."); | public OkHttpAsyncHttpClientBuilder networkInterceptors(List<Interceptor> networkInterceptors) {
this.networkInterceptors = Objects.requireNonNull(networkInterceptors, "networkInterceptors cannot be null.");
return this;
} | class OkHttpAsyncHttpClientBuilder {
private final okhttp3.OkHttpClient okHttpClient;
private static final Duration DEFAULT_READ_TIMEOUT = Duration.ofSeconds(120);
private static final Duration DEFAULT_CONNECT_TIMEOUT = Duration.ofSeconds(60);
private List<Interceptor> networkInterceptors = new ArrayList<>();
private D... | class OkHttpAsyncHttpClientBuilder {
private final okhttp3.OkHttpClient okHttpClient;
private static final Duration DEFAULT_READ_TIMEOUT = Duration.ofSeconds(120);
private static final Duration DEFAULT_CONNECT_TIMEOUT = Duration.ofSeconds(60);
private List<Interceptor> networkInterceptors = new ArrayList<>();
private D... |
Is this going to not use Proxy or will this result in failing to create a HttpClient? If we fail to create the HttpClient, it should be logged as error. If we create a client without proxy, then warning is fine. | public NettyAsyncHttpClient build() {
HttpClient nettyHttpClient = HttpClient.create()
.port(port)
.wiretap(enableWiretap)
.tcpConfiguration(tcpConfig -> {
if (nioEventLoopGroup != null) {
tcpConfig = tcpConfig.runOn(nioEventLoopGroup);
}
if (proxyOptions != null) {
ProxyProvider.Proxy nettyProxy;
switch (proxyOptions.... | throw logger.logExceptionAsWarning(new IllegalStateException( | public NettyAsyncHttpClient build() {
HttpClient nettyHttpClient = HttpClient.create()
.port(port)
.wiretap(enableWiretap)
.tcpConfiguration(tcpConfig -> {
if (nioEventLoopGroup != null) {
tcpConfig = tcpConfig.runOn(nioEventLoopGroup);
}
if (proxyOptions != null) {
ProxyProvider.Proxy nettyProxy;
switch (proxyOptions.... | class NettyAsyncHttpClientBuilder {
private final ClientLogger logger = new ClientLogger(NettyAsyncHttpClientBuilder.class);
private ProxyOptions proxyOptions;
private boolean enableWiretap;
private int port = 80;
private NioEventLoopGroup nioEventLoopGroup;
/**
* Creates a new builder instance, where a builder is capa... | class NettyAsyncHttpClientBuilder {
private final ClientLogger logger = new ClientLogger(NettyAsyncHttpClientBuilder.class);
private ProxyOptions proxyOptions;
private boolean enableWiretap;
private int port = 80;
private NioEventLoopGroup nioEventLoopGroup;
/**
* Creates a new builder instance, where a builder is capa... |
Should this check for both null and empty? | public OkHttpAsyncHttpClientBuilder networkInterceptors(List<Interceptor> networkInterceptors) {
this.networkInterceptors = Objects.requireNonNull(networkInterceptors, "networkInterceptors cannot be null.");
return this;
} | this.networkInterceptors = Objects.requireNonNull(networkInterceptors, "networkInterceptors cannot be null."); | public OkHttpAsyncHttpClientBuilder networkInterceptors(List<Interceptor> networkInterceptors) {
this.networkInterceptors = Objects.requireNonNull(networkInterceptors, "networkInterceptors cannot be null.");
return this;
} | class OkHttpAsyncHttpClientBuilder {
private final okhttp3.OkHttpClient okHttpClient;
private static final Duration DEFAULT_READ_TIMEOUT = Duration.ofSeconds(120);
private static final Duration DEFAULT_CONNECT_TIMEOUT = Duration.ofSeconds(60);
private List<Interceptor> networkInterceptors = new ArrayList<>();
private D... | class OkHttpAsyncHttpClientBuilder {
private final okhttp3.OkHttpClient okHttpClient;
private static final Duration DEFAULT_READ_TIMEOUT = Duration.ofSeconds(120);
private static final Duration DEFAULT_CONNECT_TIMEOUT = Duration.ofSeconds(60);
private List<Interceptor> networkInterceptors = new ArrayList<>();
private D... |
In general, I'd limit formatting changes to a separate PR. I have to do a line by line comparison to see what actually changed and it makes it harder to see the functional changes you made. | public Flux<PartitionOwnership> claimOwnership(PartitionOwnership... requestedPartitionOwnerships) {
return Flux.fromArray(requestedPartitionOwnerships).flatMap(partitionOwnership -> {
String partitionId = partitionOwnership.getPartitionId();
String blobName = getBlobName(partitionOwnership.getEventHubName(),
partition... | return Flux.fromArray(requestedPartitionOwnerships).flatMap(partitionOwnership -> { | public Flux<PartitionOwnership> claimOwnership(PartitionOwnership... requestedPartitionOwnerships) {
return Flux.fromArray(requestedPartitionOwnerships).flatMap(partitionOwnership -> {
String partitionId = partitionOwnership.getPartitionId();
String blobName = getBlobName(partitionOwnership.getEventHubName(),
partition... | class BlobPartitionManager implements PartitionManager {
private static final String SEQUENCE_NUMBER = "SequenceNumber";
private static final String OFFSET = "Offset";
private static final String OWNER_ID = "OwnerId";
private static final String ETAG = "eTag";
private static final String CLAIM_ERROR = "Couldn't claim o... | class BlobPartitionManager implements PartitionManager {
private static final String SEQUENCE_NUMBER = "SequenceNumber";
private static final String OFFSET = "Offset";
private static final String OWNER_ID = "OwnerId";
private static final String ETAG = "eTag";
private static final String CLAIM_ERROR = "Couldn't claim o... |
Seeing `this` passed as an argument is iffy to me. You can find yourself having a cyclic dependency graph. I'd prefer to pass in the relevant arguments to create that specialised client (ie. connection string, proxy, transport type, etc. etc.) | public PageBlobAsyncClient asPageBlobAsyncClient() {
return new SpecializedBlobClientBuilder()
.blobAsyncClient(this)
.buildPageBlobAsyncClient();
} | .blobAsyncClient(this) | public PageBlobAsyncClient asPageBlobAsyncClient() {
return prepareBuilder().buildPageBlobAsyncClient();
} | class BlobAsyncClient extends BlobAsyncClientBase {
/**
* Package-private constructor for use by {@link BlobClientBuilder}.
*
* @param azureBlobStorage the API client for blob storage
*/
BlobAsyncClient(AzureBlobStorageImpl azureBlobStorage, String snapshot, CpkInfo cpk) {
super(azureBlobStorage, snapshot, cpk);
}
/**
... | class BlobAsyncClient extends BlobAsyncClientBase {
/**
* Package-private constructor for use by {@link BlobClientBuilder}.
*
* @param azureBlobStorage the API client for blob storage
*/
BlobAsyncClient(AzureBlobStorageImpl azureBlobStorage, String snapshot, CpkInfo cpk) {
super(azureBlobStorage, snapshot, cpk);
}
/**
... |
Yeah, I'd rather have not done these changes but Checkstyle's was complaining a lot about indenting on this file. | public Flux<PartitionOwnership> claimOwnership(PartitionOwnership... requestedPartitionOwnerships) {
return Flux.fromArray(requestedPartitionOwnerships).flatMap(partitionOwnership -> {
String partitionId = partitionOwnership.getPartitionId();
String blobName = getBlobName(partitionOwnership.getEventHubName(),
partition... | return Flux.fromArray(requestedPartitionOwnerships).flatMap(partitionOwnership -> { | public Flux<PartitionOwnership> claimOwnership(PartitionOwnership... requestedPartitionOwnerships) {
return Flux.fromArray(requestedPartitionOwnerships).flatMap(partitionOwnership -> {
String partitionId = partitionOwnership.getPartitionId();
String blobName = getBlobName(partitionOwnership.getEventHubName(),
partition... | class BlobPartitionManager implements PartitionManager {
private static final String SEQUENCE_NUMBER = "SequenceNumber";
private static final String OFFSET = "Offset";
private static final String OWNER_ID = "OwnerId";
private static final String ETAG = "eTag";
private static final String CLAIM_ERROR = "Couldn't claim o... | class BlobPartitionManager implements PartitionManager {
private static final String SEQUENCE_NUMBER = "SequenceNumber";
private static final String OFFSET = "Offset";
private static final String OWNER_ID = "OwnerId";
private static final String ETAG = "eTag";
private static final String CLAIM_ERROR = "Couldn't claim o... |
I agree passing `this` is always terrifying (especially coming from doing a lot of JS development), but the builder API allows passing of a BlobClient and this is the simplest way to go about that. | public PageBlobAsyncClient asPageBlobAsyncClient() {
return new SpecializedBlobClientBuilder()
.blobAsyncClient(this)
.buildPageBlobAsyncClient();
} | .blobAsyncClient(this) | public PageBlobAsyncClient asPageBlobAsyncClient() {
return prepareBuilder().buildPageBlobAsyncClient();
} | class BlobAsyncClient extends BlobAsyncClientBase {
/**
* Package-private constructor for use by {@link BlobClientBuilder}.
*
* @param azureBlobStorage the API client for blob storage
*/
BlobAsyncClient(AzureBlobStorageImpl azureBlobStorage, String snapshot, CpkInfo cpk) {
super(azureBlobStorage, snapshot, cpk);
}
/**
... | class BlobAsyncClient extends BlobAsyncClientBase {
/**
* Package-private constructor for use by {@link BlobClientBuilder}.
*
* @param azureBlobStorage the API client for blob storage
*/
BlobAsyncClient(AzureBlobStorageImpl azureBlobStorage, String snapshot, CpkInfo cpk) {
super(azureBlobStorage, snapshot, cpk);
}
/**
... |
Simplest may not be the best design choice even if the builder supports it because we control the builder API. | public PageBlobAsyncClient asPageBlobAsyncClient() {
return new SpecializedBlobClientBuilder()
.blobAsyncClient(this)
.buildPageBlobAsyncClient();
} | .blobAsyncClient(this) | public PageBlobAsyncClient asPageBlobAsyncClient() {
return prepareBuilder().buildPageBlobAsyncClient();
} | class BlobAsyncClient extends BlobAsyncClientBase {
/**
* Package-private constructor for use by {@link BlobClientBuilder}.
*
* @param azureBlobStorage the API client for blob storage
*/
BlobAsyncClient(AzureBlobStorageImpl azureBlobStorage, String snapshot, CpkInfo cpk) {
super(azureBlobStorage, snapshot, cpk);
}
/**
... | class BlobAsyncClient extends BlobAsyncClientBase {
/**
* Package-private constructor for use by {@link BlobClientBuilder}.
*
* @param azureBlobStorage the API client for blob storage
*/
BlobAsyncClient(AzureBlobStorageImpl azureBlobStorage, String snapshot, CpkInfo cpk) {
super(azureBlobStorage, snapshot, cpk);
}
/**
... |
Changed the builder to allow individual pieces to be passed | public PageBlobAsyncClient asPageBlobAsyncClient() {
return new SpecializedBlobClientBuilder()
.blobAsyncClient(this)
.buildPageBlobAsyncClient();
} | .blobAsyncClient(this) | public PageBlobAsyncClient asPageBlobAsyncClient() {
return prepareBuilder().buildPageBlobAsyncClient();
} | class BlobAsyncClient extends BlobAsyncClientBase {
/**
* Package-private constructor for use by {@link BlobClientBuilder}.
*
* @param azureBlobStorage the API client for blob storage
*/
BlobAsyncClient(AzureBlobStorageImpl azureBlobStorage, String snapshot, CpkInfo cpk) {
super(azureBlobStorage, snapshot, cpk);
}
/**
... | class BlobAsyncClient extends BlobAsyncClientBase {
/**
* Package-private constructor for use by {@link BlobClientBuilder}.
*
* @param azureBlobStorage the API client for blob storage
*/
BlobAsyncClient(AzureBlobStorageImpl azureBlobStorage, String snapshot, CpkInfo cpk) {
super(azureBlobStorage, snapshot, cpk);
}
/**
... |
Add a message. Without it, you just get a NullPointerException with no message. ie. "'containerName' cannot be null." Same with another usages of this. | public BlobAsyncClient buildBlobAsyncClient() {
Objects.requireNonNull(containerName);
Objects.requireNonNull(blobName);
HttpPipeline pipeline = super.getPipeline();
if (pipeline == null) {
pipeline = super.buildPipeline();
}
return new BlobAsyncClient(new AzureBlobStorageBuilder()
.url(String.format("%s/%s/%s", endpoi... | Objects.requireNonNull(containerName); | public BlobAsyncClient buildBlobAsyncClient() {
Objects.requireNonNull(containerName, "'containerName' cannot be null.");
Objects.requireNonNull(blobName, "'blobName' cannot be null.");
HttpPipeline pipeline = super.getPipeline();
if (pipeline == null) {
pipeline = super.buildPipeline();
}
return new BlobAsyncClient(ne... | class BlobClientBuilder extends BaseBlobClientBuilder<BlobClientBuilder> {
private final ClientLogger logger = new ClientLogger(BlobClientBuilder.class);
private String containerName;
private String blobName;
private String snapshot;
/**
* Creates a builder instance that is able to configure and construct {@link BlobCl... | class BlobClientBuilder extends BaseBlobClientBuilder<BlobClientBuilder> {
private final ClientLogger logger = new ClientLogger(BlobClientBuilder.class);
private String containerName;
private String blobName;
private String snapshot;
/**
* Creates a builder instance that is able to configure and construct {@link BlobCl... |
What is `cpk`? This isn't a very intuitive variable name. | public BlobAsyncClient buildBlobAsyncClient() {
Objects.requireNonNull(containerName);
Objects.requireNonNull(blobName);
HttpPipeline pipeline = super.getPipeline();
if (pipeline == null) {
pipeline = super.buildPipeline();
}
return new BlobAsyncClient(new AzureBlobStorageBuilder()
.url(String.format("%s/%s/%s", endpoi... | .build(), snapshot, cpk); | public BlobAsyncClient buildBlobAsyncClient() {
Objects.requireNonNull(containerName, "'containerName' cannot be null.");
Objects.requireNonNull(blobName, "'blobName' cannot be null.");
HttpPipeline pipeline = super.getPipeline();
if (pipeline == null) {
pipeline = super.buildPipeline();
}
return new BlobAsyncClient(ne... | class BlobClientBuilder extends BaseBlobClientBuilder<BlobClientBuilder> {
private final ClientLogger logger = new ClientLogger(BlobClientBuilder.class);
private String containerName;
private String blobName;
private String snapshot;
/**
* Creates a builder instance that is able to configure and construct {@link BlobCl... | class BlobClientBuilder extends BaseBlobClientBuilder<BlobClientBuilder> {
private final ClientLogger logger = new ClientLogger(BlobClientBuilder.class);
private String containerName;
private String blobName;
private String snapshot;
/**
* Creates a builder instance that is able to configure and construct {@link BlobCl... |
We need reference to this feature name in some sense, as we need to easily differentiate it from client side encryption, the previous feature where customers managed their encryption keys, before the service was able to do that work for the customer. | public BlobAsyncClient buildBlobAsyncClient() {
Objects.requireNonNull(containerName);
Objects.requireNonNull(blobName);
HttpPipeline pipeline = super.getPipeline();
if (pipeline == null) {
pipeline = super.buildPipeline();
}
return new BlobAsyncClient(new AzureBlobStorageBuilder()
.url(String.format("%s/%s/%s", endpoi... | .build(), snapshot, cpk); | public BlobAsyncClient buildBlobAsyncClient() {
Objects.requireNonNull(containerName, "'containerName' cannot be null.");
Objects.requireNonNull(blobName, "'blobName' cannot be null.");
HttpPipeline pipeline = super.getPipeline();
if (pipeline == null) {
pipeline = super.buildPipeline();
}
return new BlobAsyncClient(ne... | class BlobClientBuilder extends BaseBlobClientBuilder<BlobClientBuilder> {
private final ClientLogger logger = new ClientLogger(BlobClientBuilder.class);
private String containerName;
private String blobName;
private String snapshot;
/**
* Creates a builder instance that is able to configure and construct {@link BlobCl... | class BlobClientBuilder extends BaseBlobClientBuilder<BlobClientBuilder> {
private final ClientLogger logger = new ClientLogger(BlobClientBuilder.class);
private String containerName;
private String blobName;
private String snapshot;
/**
* Creates a builder instance that is able to configure and construct {@link BlobCl... |
Changed field and getter to customerProvidedKey and getCustomerProvidedKey. | public BlobAsyncClient buildBlobAsyncClient() {
Objects.requireNonNull(containerName);
Objects.requireNonNull(blobName);
HttpPipeline pipeline = super.getPipeline();
if (pipeline == null) {
pipeline = super.buildPipeline();
}
return new BlobAsyncClient(new AzureBlobStorageBuilder()
.url(String.format("%s/%s/%s", endpoi... | .build(), snapshot, cpk); | public BlobAsyncClient buildBlobAsyncClient() {
Objects.requireNonNull(containerName, "'containerName' cannot be null.");
Objects.requireNonNull(blobName, "'blobName' cannot be null.");
HttpPipeline pipeline = super.getPipeline();
if (pipeline == null) {
pipeline = super.buildPipeline();
}
return new BlobAsyncClient(ne... | class BlobClientBuilder extends BaseBlobClientBuilder<BlobClientBuilder> {
private final ClientLogger logger = new ClientLogger(BlobClientBuilder.class);
private String containerName;
private String blobName;
private String snapshot;
/**
* Creates a builder instance that is able to configure and construct {@link BlobCl... | class BlobClientBuilder extends BaseBlobClientBuilder<BlobClientBuilder> {
private final ClientLogger logger = new ClientLogger(BlobClientBuilder.class);
private String containerName;
private String blobName;
private String snapshot;
/**
* Creates a builder instance that is able to configure and construct {@link BlobCl... |
Added message | public BlobAsyncClient buildBlobAsyncClient() {
Objects.requireNonNull(containerName);
Objects.requireNonNull(blobName);
HttpPipeline pipeline = super.getPipeline();
if (pipeline == null) {
pipeline = super.buildPipeline();
}
return new BlobAsyncClient(new AzureBlobStorageBuilder()
.url(String.format("%s/%s/%s", endpoi... | Objects.requireNonNull(containerName); | public BlobAsyncClient buildBlobAsyncClient() {
Objects.requireNonNull(containerName, "'containerName' cannot be null.");
Objects.requireNonNull(blobName, "'blobName' cannot be null.");
HttpPipeline pipeline = super.getPipeline();
if (pipeline == null) {
pipeline = super.buildPipeline();
}
return new BlobAsyncClient(ne... | class BlobClientBuilder extends BaseBlobClientBuilder<BlobClientBuilder> {
private final ClientLogger logger = new ClientLogger(BlobClientBuilder.class);
private String containerName;
private String blobName;
private String snapshot;
/**
* Creates a builder instance that is able to configure and construct {@link BlobCl... | class BlobClientBuilder extends BaseBlobClientBuilder<BlobClientBuilder> {
private final ClientLogger logger = new ClientLogger(BlobClientBuilder.class);
private String containerName;
private String blobName;
private String snapshot;
/**
* Creates a builder instance that is able to configure and construct {@link BlobCl... |
These two return two different results. Original one is : 2 ^ (tryCount-1) Now: (tryCount -1) ^ 2 What if tryCount = 1, does delay expect to be negative? | long calculateDelayInMs(int tryCount) {
long delay;
switch (this.retryPolicyType) {
case EXPONENTIAL:
delay = ((tryCount - 1) * (tryCount - 1) - 1L) * this.retryDelayInMs;
break;
case FIXED:
delay = this.retryDelayInMs;
break;
default:
throw logger.logExceptionAsError(new IllegalArgumentException("Invalid retry policy ... | delay = ((tryCount - 1) * (tryCount - 1) - 1L) * this.retryDelayInMs; | long calculateDelayInMs(int tryCount) {
long delay;
switch (this.retryPolicyType) {
case EXPONENTIAL:
delay = ((tryCount - 1) * (tryCount - 1) - 1L) * this.retryDelayInMs;
break;
case FIXED:
delay = this.retryDelayInMs;
break;
default:
throw logger.logExceptionAsError(new IllegalArgumentException("Invalid retry policy ... | class RequestRetryOptions {
private final ClientLogger logger = new ClientLogger(RequestRetryOptions.class);
private final int maxTries;
private final int tryTimeout;
private final long retryDelayInMs;
private final long maxRetryDelayInMs;
private final RetryPolicyType retryPolicyType;
private final String secondaryHos... | class RequestRetryOptions {
private final ClientLogger logger = new ClientLogger(RequestRetryOptions.class);
private final int maxTries;
private final int tryTimeout;
private final long retryDelayInMs;
private final long maxRetryDelayInMs;
private final RetryPolicyType retryPolicyType;
private final String secondaryHos... |
What's the reason of the switching 500 to 1000? Same as below. Any justification on this? | private OffsetDateTime calcUpperBound(OffsetDateTime start, int primaryTryNumber, boolean tryingPrimary) {
if (tryingPrimary) {
return start.plus(calcPrimaryDelay(primaryTryNumber) * 1000 + 1000, ChronoUnit.MILLIS);
} else {
return start.plus(1500, ChronoUnit.MILLIS);
}
} | return start.plus(calcPrimaryDelay(primaryTryNumber) * 1000 + 1000, ChronoUnit.MILLIS); | private OffsetDateTime calcUpperBound(OffsetDateTime start, int primaryTryNumber, boolean tryingPrimary) {
if (tryingPrimary) {
return start.plus(calcPrimaryDelay(primaryTryNumber) * 1000 + 1000, ChronoUnit.MILLIS);
} else {
return start.plus(1500, ChronoUnit.MILLIS);
}
} | class RetryTestClient implements HttpClient {
private RequestRetryTestFactory factory;
RetryTestClient(RequestRetryTestFactory parent) {
this.factory = parent;
}
@Override
public Mono<HttpResponse> send(HttpRequest request) {
this.factory.tryNumber++;
if (this.factory.tryNumber > this.factory.options.maxTries()) {
thro... | class RetryTestClient implements HttpClient {
private RequestRetryTestFactory factory;
RetryTestClient(RequestRetryTestFactory parent) {
this.factory = parent;
}
@Override
public Mono<HttpResponse> send(HttpRequest request) {
this.factory.tryNumber++;
if (this.factory.tryNumber > this.factory.options.maxTries()) {
thro... |
Fixing in #5469 | long calculateDelayInMs(int tryCount) {
long delay;
switch (this.retryPolicyType) {
case EXPONENTIAL:
delay = ((tryCount - 1) * (tryCount - 1) - 1L) * this.retryDelayInMs;
break;
case FIXED:
delay = this.retryDelayInMs;
break;
default:
throw logger.logExceptionAsError(new IllegalArgumentException("Invalid retry policy ... | delay = ((tryCount - 1) * (tryCount - 1) - 1L) * this.retryDelayInMs; | long calculateDelayInMs(int tryCount) {
long delay;
switch (this.retryPolicyType) {
case EXPONENTIAL:
delay = ((tryCount - 1) * (tryCount - 1) - 1L) * this.retryDelayInMs;
break;
case FIXED:
delay = this.retryDelayInMs;
break;
default:
throw logger.logExceptionAsError(new IllegalArgumentException("Invalid retry policy ... | class RequestRetryOptions {
private final ClientLogger logger = new ClientLogger(RequestRetryOptions.class);
private final int maxTries;
private final int tryTimeout;
private final long retryDelayInMs;
private final long maxRetryDelayInMs;
private final RetryPolicyType retryPolicyType;
private final String secondaryHos... | class RequestRetryOptions {
private final ClientLogger logger = new ClientLogger(RequestRetryOptions.class);
private final int maxTries;
private final int tryTimeout;
private final long retryDelayInMs;
private final long maxRetryDelayInMs;
private final RetryPolicyType retryPolicyType;
private final String secondaryHos... |
Use logger instead. | public void receiveUntilTimeoutMultipleTimes() throws IOException {
this.consumer.close();
this.consumer = null;
final int numberOfEvents = 15;
final int numberOfEvents2 = 3;
final String partitionId = "1";
final List<EventData> events = getEventsAsList(numberOfEvents, TestUtils.MESSAGE_TRACKING_ID);
final List<EventDa... | System.out.println("Receiving second batch."); | public void receiveUntilTimeoutMultipleTimes() {
final int numberOfEvents = 15;
final int numberOfEvents2 = 3;
final String partitionId = "1";
final List<EventData> events = getEventsAsList(numberOfEvents);
final List<EventData> events2 = getEventsAsList(numberOfEvents2);
final EventHubConsumer consumer = client.create... | class EventHubConsumerIntegrationTest extends IntegrationTestBase {
private static final String PARTITION_ID = "0";
private static final int NUMBER_OF_EVENTS = 10;
private static final AtomicBoolean HAS_PUSHED_EVENTS = new AtomicBoolean();
private static volatile IntegrationTestEventData testData = null;
private EventH... | class EventHubConsumerIntegrationTest extends IntegrationTestBase {
private static final String PARTITION_ID = "0";
private static final int NUMBER_OF_EVENTS = 10;
private static final AtomicBoolean HAS_PUSHED_EVENTS = new AtomicBoolean();
private static volatile IntegrationTestEventData testData = null;
private EventH... |
Not sure why this is required but if you intended to close out the consumer that was created from previous tests, you can instead use this: ``` @After public void cleanUp() { this.consumer.close(); this.consumer = null; } ``` | public void receiveUntilTimeoutMultipleTimes() throws IOException {
this.consumer.close();
this.consumer = null;
final int numberOfEvents = 15;
final int numberOfEvents2 = 3;
final String partitionId = "1";
final List<EventData> events = getEventsAsList(numberOfEvents, TestUtils.MESSAGE_TRACKING_ID);
final List<EventDa... | this.consumer.close(); | public void receiveUntilTimeoutMultipleTimes() {
final int numberOfEvents = 15;
final int numberOfEvents2 = 3;
final String partitionId = "1";
final List<EventData> events = getEventsAsList(numberOfEvents);
final List<EventData> events2 = getEventsAsList(numberOfEvents2);
final EventHubConsumer consumer = client.create... | class EventHubConsumerIntegrationTest extends IntegrationTestBase {
private static final String PARTITION_ID = "0";
private static final int NUMBER_OF_EVENTS = 10;
private static final AtomicBoolean HAS_PUSHED_EVENTS = new AtomicBoolean();
private static volatile IntegrationTestEventData testData = null;
private EventH... | class EventHubConsumerIntegrationTest extends IntegrationTestBase {
private static final String PARTITION_ID = "0";
private static final int NUMBER_OF_EVENTS = 10;
private static final AtomicBoolean HAS_PUSHED_EVENTS = new AtomicBoolean();
private static volatile IntegrationTestEventData testData = null;
private EventH... |
Oh, that was because I don't use the consumer created in beforeTest() and create my own. I'll remove it. It's not necessary. | public void receiveUntilTimeoutMultipleTimes() throws IOException {
this.consumer.close();
this.consumer = null;
final int numberOfEvents = 15;
final int numberOfEvents2 = 3;
final String partitionId = "1";
final List<EventData> events = getEventsAsList(numberOfEvents, TestUtils.MESSAGE_TRACKING_ID);
final List<EventDa... | this.consumer.close(); | public void receiveUntilTimeoutMultipleTimes() {
final int numberOfEvents = 15;
final int numberOfEvents2 = 3;
final String partitionId = "1";
final List<EventData> events = getEventsAsList(numberOfEvents);
final List<EventData> events2 = getEventsAsList(numberOfEvents2);
final EventHubConsumer consumer = client.create... | class EventHubConsumerIntegrationTest extends IntegrationTestBase {
private static final String PARTITION_ID = "0";
private static final int NUMBER_OF_EVENTS = 10;
private static final AtomicBoolean HAS_PUSHED_EVENTS = new AtomicBoolean();
private static volatile IntegrationTestEventData testData = null;
private EventH... | class EventHubConsumerIntegrationTest extends IntegrationTestBase {
private static final String PARTITION_ID = "0";
private static final int NUMBER_OF_EVENTS = 10;
private static final AtomicBoolean HAS_PUSHED_EVENTS = new AtomicBoolean();
private static volatile IntegrationTestEventData testData = null;
private EventH... |
Do we split out the share and directory path in the URL? If not we don't need this `String.format`. | public URL getDirectoryUrl() {
String directoryURLString = String.format("%s/%s/%s", azureFileStorageClient.getUrl(),
shareName, directoryPath);
if (snapshot != null) {
directoryURLString = String.format("%s?snapshot=%s", directoryURLString, snapshot);
}
try {
return new URL(directoryURLString);
} catch (MalformedURLEx... | String directoryURLString = String.format("%s/%s/%s", azureFileStorageClient.getUrl(), | public URL getDirectoryUrl() {
StringBuilder directoryURLString = new StringBuilder(azureFileStorageClient.getUrl()).append("/")
.append(shareName).append("/").append(directoryPath);
if (snapshot != null) {
directoryURLString.append("?snapshot=").append(snapshot);
}
try {
return new URL(directoryURLString.toString());
... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... | class DirectoryAsyncClient {
private final ClientLogger logger = new ClientLogger(DirectoryAsyncClient.class);
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareName;
private final String directoryPath;
private final String snapshot;
/**
* Creates a DirectoryAsyncClient that sends req... |
Same question as before | public URL getFileUrl() {
String fileURLString = String.format("%s/%s/%s", azureFileStorageClient.getUrl(), shareName, filePath);
if (snapshot != null) {
fileURLString = String.format("%s?snapshot=%s", fileURLString, snapshot);
}
try {
return new URL(fileURLString);
} catch (MalformedURLException e) {
throw logger.logE... | String fileURLString = String.format("%s/%s/%s", azureFileStorageClient.getUrl(), shareName, filePath); | public URL getFileUrl() {
StringBuilder fileURLString = new StringBuilder(azureFileStorageClient.getUrl()).append("/")
.append(shareName).append("/").append(filePath);
if (snapshot != null) {
fileURLString.append("?snapshot=").append(snapshot);
}
try {
return new URL(fileURLString.toString());
} catch (MalformedURLExce... | class FileAsyncClient {
private final ClientLogger logger = new ClientLogger(FileAsyncClient.class);
private static final long FILE_DEFAULT_BLOCK_SIZE = 4 * 1024 * 1024L;
private static final long DOWNLOAD_UPLOAD_CHUNK_TIMEOUT = 300;
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareN... | class FileAsyncClient {
private final ClientLogger logger = new ClientLogger(FileAsyncClient.class);
private static final long FILE_DEFAULT_BLOCK_SIZE = 4 * 1024 * 1024L;
private static final long DOWNLOAD_UPLOAD_CHUNK_TIMEOUT = 300;
private final AzureFileStorageImpl azureFileStorageClient;
private final String shareN... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.