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 |
|---|---|---|---|---|---|
Please check current design , it is more seem less in respect to customer expectation , code will only create resource if it is not present , and only delete newly created resource and not the existing | void shutdown() {
cosmosAsyncContainer.delete().block();
logger.info("Deleted test container {}" , this.configuration.getCollectionId());
cosmosClient.close();
} | cosmosAsyncContainer.delete().block(); | void shutdown() {
if (this.databaseCreated) {
cosmosAsyncDatabase.delete().block();
logger.info("Deleted temporary database {} created for this test", this.configuration.getDatabaseId());
} else if (this.collectionCreated) {
cosmosAsyncContainer.delete().block();
logger.info("Deleted temporary collection {} created for... | class AsyncBenchmark<T> {
private final MetricRegistry metricsRegistry = new MetricRegistry();
private final ScheduledReporter reporter;
private Meter successMeter;
private Meter failureMeter;
final Logger logger;
final CosmosAsyncClient cosmosClient;
final CosmosAsyncContainer cosmosAsyncContainer;
final CosmosAsyncDa... | class AsyncBenchmark<T> {
private final MetricRegistry metricsRegistry = new MetricRegistry();
private final ScheduledReporter reporter;
private Meter successMeter;
private Meter failureMeter;
private boolean databaseCreated;
private boolean collectionCreated;
final Logger logger;
final CosmosAsyncClient cosmosClient;
... |
should these comments actually be bufferedNext? I'm assuming you just renamed the variable and forgot to change the comments | public Path next() {
if (this.bufferedNext == null) {
if (!this.hasNext()) {
throw LoggingUtility.logError(logger, new NoSuchElementException());
}
}
Path next = this.bufferedNext;
this.bufferedNext = null;
return next;
} | if (!this.hasNext()) { | public Path next() {
if (this.bufferedNext == null) {
if (!this.hasNext()) {
throw LoggingUtility.logError(logger, new NoSuchElementException());
}
}
Path next = this.bufferedNext;
this.bufferedNext = null;
return next;
} | class AzureDirectoryIterator implements Iterator<Path> {
private final ClientLogger logger = new ClientLogger(AzureDirectoryIterator.class);
private final AzureDirectoryStream parentStream;
private final DirectoryStream.Filter<? super Path> filter;
private final Iterator<BlobItem> blobIterator;
private final AzurePath ... | class AzureDirectoryIterator implements Iterator<Path> {
private final ClientLogger logger = new ClientLogger(AzureDirectoryIterator.class);
private final AzureDirectoryStream parentStream;
private final DirectoryStream.Filter<? super Path> filter;
private final Iterator<BlobItem> blobIterator;
private final AzurePath ... |
is there a reason we can't just do this +next 3 lines once in the constructor for AzureDirectoryIterator? | private Path getNextListResult(BlobItem blobItem) {
Path withoutRoot = this.path;
if (withoutRoot.isAbsolute()) {
withoutRoot = this.path.getRoot().relativize(this.path);
}
/*
Listing results return the full blob path, and we don't want to duplicate the path we listed off of, so
we relativize to remove it.
*/
String bl... | Path withoutRoot = this.path; | private Path getNextListResult(BlobItem blobItem) {
/*
Listing results return the full blob path, and we don't want to duplicate the path we listed off of, so
we relativize to remove it.
*/
String blobName = blobItem.getName();
Path relativeResult = this.withoutRoot.relativize(
this.path.getFileSystem().getPath(blobNam... | class AzureDirectoryIterator implements Iterator<Path> {
private final ClientLogger logger = new ClientLogger(AzureDirectoryIterator.class);
private final AzureDirectoryStream parentStream;
private final DirectoryStream.Filter<? super Path> filter;
private final Iterator<BlobItem> blobIterator;
private final AzurePath ... | class AzureDirectoryIterator implements Iterator<Path> {
private final ClientLogger logger = new ClientLogger(AzureDirectoryIterator.class);
private final AzureDirectoryStream parentStream;
private final DirectoryStream.Filter<? super Path> filter;
private final Iterator<BlobItem> blobIterator;
private final AzurePath ... |
nit. should this be called !isDuplicate ? or something like that | public boolean hasNext() {
if (parentStream.closed) {
return false;
}
if (this.bufferedNext != null) {
return true;
}
/*
Search for a new element that passes the filter and buffer it when found. If no such element is found,
return false.
*/
while (this.blobIterator.hasNext()) {
BlobItem nextBlob = this.blobIterator.nex... | if (this.filter.accept(nextPath) && passesDirectoryDuplicateFilter(nextPath, nextBlob)) { | public boolean hasNext() {
if (parentStream.closed) {
return false;
}
if (this.bufferedNext != null) {
return true;
}
/*
Search for a new element that passes the filter and buffer it when found. If no such element is found,
return false.
*/
while (this.blobIterator.hasNext()) {
BlobItem nextBlob = this.blobIterator.nex... | class AzureDirectoryIterator implements Iterator<Path> {
private final ClientLogger logger = new ClientLogger(AzureDirectoryIterator.class);
private final AzureDirectoryStream parentStream;
private final DirectoryStream.Filter<? super Path> filter;
private final Iterator<BlobItem> blobIterator;
private final AzurePath ... | class AzureDirectoryIterator implements Iterator<Path> {
private final ClientLogger logger = new ClientLogger(AzureDirectoryIterator.class);
private final AzureDirectoryStream parentStream;
private final DirectoryStream.Filter<? super Path> filter;
private final Iterator<BlobItem> blobIterator;
private final AzurePath ... |
Ooo probably. Save doing it every time. Good thought! | private Path getNextListResult(BlobItem blobItem) {
Path withoutRoot = this.path;
if (withoutRoot.isAbsolute()) {
withoutRoot = this.path.getRoot().relativize(this.path);
}
/*
Listing results return the full blob path, and we don't want to duplicate the path we listed off of, so
we relativize to remove it.
*/
String bl... | Path withoutRoot = this.path; | private Path getNextListResult(BlobItem blobItem) {
/*
Listing results return the full blob path, and we don't want to duplicate the path we listed off of, so
we relativize to remove it.
*/
String blobName = blobItem.getName();
Path relativeResult = this.withoutRoot.relativize(
this.path.getFileSystem().getPath(blobNam... | class AzureDirectoryIterator implements Iterator<Path> {
private final ClientLogger logger = new ClientLogger(AzureDirectoryIterator.class);
private final AzureDirectoryStream parentStream;
private final DirectoryStream.Filter<? super Path> filter;
private final Iterator<BlobItem> blobIterator;
private final AzurePath ... | class AzureDirectoryIterator implements Iterator<Path> {
private final ClientLogger logger = new ClientLogger(AzureDirectoryIterator.class);
private final AzureDirectoryStream parentStream;
private final DirectoryStream.Filter<? super Path> filter;
private final Iterator<BlobItem> blobIterator;
private final AzurePath ... |
not particularly picky about this: but since we're now throwing on finding the decryption policy, could we just throw an exception in the for loop when we encounter it? That way we dont need to loop over all the rest of the policies if the first policy was a decryption policy? | private HttpPipeline getHttpPipeline() {
if (httpPipeline != null) {
List<HttpPipelinePolicy> policies = new ArrayList<>();
boolean decryptionPolicyPresent = false;
for (int i = 0; i < httpPipeline.getPolicyCount(); i++) {
HttpPipelinePolicy currPolicy = httpPipeline.getPolicy(i);
decryptionPolicyPresent |= currPolicy ... | if (!decryptionPolicyPresent) { | private HttpPipeline getHttpPipeline() {
if (httpPipeline != null) {
List<HttpPipelinePolicy> policies = new ArrayList<>();
boolean decryptionPolicyPresent = false;
for (int i = 0; i < httpPipeline.getPolicyCount(); i++) {
HttpPipelinePolicy currPolicy = httpPipeline.getPolicy(i);
if (currPolicy instanceof BlobDecrypti... | class EncryptedBlobClientBuilder {
private final ClientLogger logger = new ClientLogger(EncryptedBlobClientBuilder.class);
private static final String SDK_NAME = "name";
private static final String SDK_VERSION = "version";
private String endpoint;
private String accountName;
private String containerName;
private String... | class EncryptedBlobClientBuilder {
private final ClientLogger logger = new ClientLogger(EncryptedBlobClientBuilder.class);
private static final String SDK_NAME = "name";
private static final String SDK_VERSION = "version";
private String endpoint;
private String accountName;
private String containerName;
private String... |
Should we use Collator.getInstance(Locale) ? Otherwise this will use local machine or JVM default which might not be what we expect. I guess en_US would be safe choice. | private String getAdditionalXmsHeaders(Map<String, String> headers) {
final List<String> xmsHeaderNameArray = headers.entrySet().stream()
.filter(entry -> entry.getKey().toLowerCase(Locale.ROOT).startsWith("x-ms-"))
.filter(entry -> entry.getValue() != null)
.map(Map.Entry::getKey)
.collect(Collectors.toList());
if (xm... | Collections.sort(xmsHeaderNameArray, Collator.getInstance()); | private String getAdditionalXmsHeaders(Map<String, String> headers) {
final List<String> xmsHeaderNameArray = headers.entrySet().stream()
.filter(entry -> entry.getKey().toLowerCase(Locale.ROOT).startsWith("x-ms-"))
.filter(entry -> entry.getValue() != null)
.map(Map.Entry::getKey)
.collect(Collectors.toList());
if (xm... | class StorageSharedKeyCredential {
private static final String AUTHORIZATION_HEADER_FORMAT = "SharedKey %s:%s";
private static final String ACCOUNT_NAME = "accountname";
private static final String ACCOUNT_KEY = "accountkey";
private final String accountName;
private final String accountKey;
/**
* Initializes a new ins... | class StorageSharedKeyCredential {
private static final String AUTHORIZATION_HEADER_FORMAT = "SharedKey %s:%s";
private static final String ACCOUNT_NAME = "accountname";
private static final String ACCOUNT_KEY = "accountkey";
private final String accountName;
private final String accountKey;
/**
* Initializes a new ins... |
good point, yeah I wasn't too sure which one to pin it to if I did. There's also Locale.ROOT, Locale.US and Locale.ENGLISH | private String getAdditionalXmsHeaders(Map<String, String> headers) {
final List<String> xmsHeaderNameArray = headers.entrySet().stream()
.filter(entry -> entry.getKey().toLowerCase(Locale.ROOT).startsWith("x-ms-"))
.filter(entry -> entry.getValue() != null)
.map(Map.Entry::getKey)
.collect(Collectors.toList());
if (xm... | Collections.sort(xmsHeaderNameArray, Collator.getInstance()); | private String getAdditionalXmsHeaders(Map<String, String> headers) {
final List<String> xmsHeaderNameArray = headers.entrySet().stream()
.filter(entry -> entry.getKey().toLowerCase(Locale.ROOT).startsWith("x-ms-"))
.filter(entry -> entry.getValue() != null)
.map(Map.Entry::getKey)
.collect(Collectors.toList());
if (xm... | class StorageSharedKeyCredential {
private static final String AUTHORIZATION_HEADER_FORMAT = "SharedKey %s:%s";
private static final String ACCOUNT_NAME = "accountname";
private static final String ACCOUNT_KEY = "accountkey";
private final String accountName;
private final String accountKey;
/**
* Initializes a new ins... | class StorageSharedKeyCredential {
private static final String AUTHORIZATION_HEADER_FORMAT = "SharedKey %s:%s";
private static final String ACCOUNT_NAME = "accountname";
private static final String ACCOUNT_KEY = "accountkey";
private final String accountName;
private final String accountKey;
/**
* Initializes a new ins... |
Javadoc of Locale.ROOT looks promising - I'd give that a try. If that doesn't work Locale.US. | private String getAdditionalXmsHeaders(Map<String, String> headers) {
final List<String> xmsHeaderNameArray = headers.entrySet().stream()
.filter(entry -> entry.getKey().toLowerCase(Locale.ROOT).startsWith("x-ms-"))
.filter(entry -> entry.getValue() != null)
.map(Map.Entry::getKey)
.collect(Collectors.toList());
if (xm... | Collections.sort(xmsHeaderNameArray, Collator.getInstance()); | private String getAdditionalXmsHeaders(Map<String, String> headers) {
final List<String> xmsHeaderNameArray = headers.entrySet().stream()
.filter(entry -> entry.getKey().toLowerCase(Locale.ROOT).startsWith("x-ms-"))
.filter(entry -> entry.getValue() != null)
.map(Map.Entry::getKey)
.collect(Collectors.toList());
if (xm... | class StorageSharedKeyCredential {
private static final String AUTHORIZATION_HEADER_FORMAT = "SharedKey %s:%s";
private static final String ACCOUNT_NAME = "accountname";
private static final String ACCOUNT_KEY = "accountkey";
private final String accountName;
private final String accountKey;
/**
* Initializes a new ins... | class StorageSharedKeyCredential {
private static final String AUTHORIZATION_HEADER_FORMAT = "SharedKey %s:%s";
private static final String ACCOUNT_NAME = "accountname";
private static final String ACCOUNT_KEY = "accountkey";
private final String accountName;
private final String accountKey;
/**
* Initializes a new ins... |
What am i supposed to do here? | void commit() {
sink.complete();
lock.lock();
while (!complete) {
try {
transferComplete.await();
} catch (InterruptedException e) {
this.lastError = new IOException(e.getMessage());
}
}
lock.unlock();
} | this.lastError = new IOException(e.getMessage()); | void commit();
/**
* Closes this output stream and releases any system resources associated with this stream. If any data remains in
* the buffer it is committed to the service.
*
* @throws IOException If an I/O error occurs.
*/
@Override
public synchronized void close() throws IOException {
try {
this.checkStreamState... | class BlobOutputStream extends StorageOutputStream {
BlobOutputStream(final int writeThreshold) {
super(writeThreshold);
}
static BlobOutputStream appendBlobOutputStream(final AppendBlobAsyncClient client,
final AppendBlobRequestConditions appendBlobRequestConditions) {
return new AppendBlobOutputStream(client, appendB... | class BlobOutputStream extends StorageOutputStream {
BlobOutputStream(final int writeThreshold) {
super(writeThreshold);
}
static BlobOutputStream appendBlobOutputStream(final AppendBlobAsyncClient client,
final AppendBlobRequestConditions appendBlobRequestConditions) {
return new AppendBlobOutputStream(client, appendB... |
If an input is `null` and is expected to be non-null, we throw `NullPointerException` as per Java guidelines. | public LocalCryptographyAsyncClient buildAsyncClient() {
if (jsonWebKey == null) {
throw logger.logExceptionAsError(new IllegalStateException(
"Json Web Key is required to create local cryptography client"));
}
return new LocalCryptographyAsyncClient(jsonWebKey);
} | } | public LocalCryptographyAsyncClient buildAsyncClient() {
if (jsonWebKey == null) {
throw logger.logExceptionAsError(new NullPointerException(
"Json Web Key is required to create local cryptography client"));
}
return new LocalCryptographyAsyncClient(jsonWebKey);
} | class LocalCryptographyClientBuilder {
private final ClientLogger logger = new ClientLogger(LocalCryptographyClientBuilder.class);
private JsonWebKey jsonWebKey;
/**
* Creates a {@link LocalCryptographyClient} based on options set in the builder.
* Every time {@code buildClient()} is called, a new instance of {@link Lo... | class LocalCryptographyClientBuilder {
private final ClientLogger logger = new ClientLogger(LocalCryptographyClientBuilder.class);
private JsonWebKey jsonWebKey;
/**
* Creates a {@link LocalCryptographyClient} based on options set in the builder.
* Every time {@code buildClient()} is called, a new instance of {@link Lo... |
Null or empty is two checks. NullPointer for when getLockToken() == null and if it is empty, illegal argument exception. | public Mono<Instant> renewMessageLock(MessageLockToken lockToken) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock")));
} else if (Objects.isNull(lockToken)) {
return monoError(logger, new NullPointerException("'receivedMe... | } else if (CoreUtils.isNullOrEmpty(lockToken.getLockToken())) { | public Mono<Instant> renewMessageLock(MessageLockToken lockToken) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock")));
} else if (Objects.isNull(lockToken)) {
return monoError(logger, new NullPointerException("'receivedMe... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private fi... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private fi... |
shouldn't we propagate the same error back? It is an illegalargument exception because it couldn't be converted to a UUID. It's not dependent on the state of this receiver. | public Mono<Instant> renewMessageLock(MessageLockToken lockToken) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock")));
} else if (Objects.isNull(lockToken)) {
return monoError(logger, new NullPointerException("'receivedMe... | return monoError(logger, new IllegalStateException( | public Mono<Instant> renewMessageLock(MessageLockToken lockToken) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock")));
} else if (Objects.isNull(lockToken)) {
return monoError(logger, new NullPointerException("'receivedMe... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private fi... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private fi... |
You'll get a warning to use logger.logErrorAsException then throw. | public Mono<Instant> renewMessageLock(MessageLockToken lockToken) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock")));
} else if (Objects.isNull(lockToken)) {
return monoError(logger, new NullPointerException("'receivedMe... | throw ex; | public Mono<Instant> renewMessageLock(MessageLockToken lockToken) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock")));
} else if (Objects.isNull(lockToken)) {
return monoError(logger, new NullPointerException("'receivedMe... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private fi... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private fi... |
lockTokenUUID -> lockTokenUuid | public Mono<Instant> renewMessageLock(MessageLockToken lockToken) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock")));
} else if (Objects.isNull(lockToken)) {
return monoError(logger, new NullPointerException("'receivedMe... | serviceBusManagementNode.renewMessageLock(lockTokenUUID)) | public Mono<Instant> renewMessageLock(MessageLockToken lockToken) {
if (isDisposed.get()) {
return monoError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "renewMessageLock")));
} else if (Objects.isNull(lockToken)) {
return monoError(logger, new NullPointerException("'receivedMe... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private fi... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private fi... |
Why set both? Will it affect line 413 when you call both regardless create or update? | public DnsZoneImpl withETagCheck() {
this.eTagState.withImplicitETagCheckOnCreate();
this.eTagState.withImplicitETagCheckOnUpdate();
return this;
} | this.eTagState.withImplicitETagCheckOnUpdate(); | public DnsZoneImpl withETagCheck() {
this.eTagState.withImplicitETagCheckOnCreateOrUpdate(this.isInCreateMode());
return this;
} | class DnsZoneImpl
extends GroupableResourceImpl<
DnsZone,
ZoneInner,
DnsZoneImpl,
DnsZoneManager>
implements
DnsZone,
DnsZone.Definition,
DnsZone.Update {
private ARecordSets aRecordSets;
private AaaaRecordSets aaaaRecordSets;
private CaaRecordSets caaRecordSets;
private CNameRecordSets cnameRecordSets;
private MXRecor... | class DnsZoneImpl
extends GroupableResourceImpl<
DnsZone,
ZoneInner,
DnsZoneImpl,
DnsZoneManager>
implements
DnsZone,
DnsZone.Definition,
DnsZone.Update {
private ARecordSets aRecordSets;
private AaaaRecordSets aaaaRecordSets;
private CaaRecordSets caaRecordSets;
private CNameRecordSets cnameRecordSets;
private MXRecor... |
`withETagCheck()` could be available both Create phase and Update phase. So it's required to set both here. In Create phase, line#413 `self.inner().etag()` is NULL so it will send `If-Match: null` and `If-None-Match:*` during creation. In Update phase, it would send `If-Match: etag` and `If-None-Match: *`. This is t... | public DnsZoneImpl withETagCheck() {
this.eTagState.withImplicitETagCheckOnCreate();
this.eTagState.withImplicitETagCheckOnUpdate();
return this;
} | this.eTagState.withImplicitETagCheckOnUpdate(); | public DnsZoneImpl withETagCheck() {
this.eTagState.withImplicitETagCheckOnCreateOrUpdate(this.isInCreateMode());
return this;
} | class DnsZoneImpl
extends GroupableResourceImpl<
DnsZone,
ZoneInner,
DnsZoneImpl,
DnsZoneManager>
implements
DnsZone,
DnsZone.Definition,
DnsZone.Update {
private ARecordSets aRecordSets;
private AaaaRecordSets aaaaRecordSets;
private CaaRecordSets caaRecordSets;
private CNameRecordSets cnameRecordSets;
private MXRecor... | class DnsZoneImpl
extends GroupableResourceImpl<
DnsZone,
ZoneInner,
DnsZoneImpl,
DnsZoneManager>
implements
DnsZone,
DnsZone.Definition,
DnsZone.Update {
private ARecordSets aRecordSets;
private AaaaRecordSets aaaaRecordSets;
private CaaRecordSets caaRecordSets;
private CNameRecordSets cnameRecordSets;
private MXRecor... |
The problem is why does `If-None-Match: *` work on UPDATE? The condition specified by it is that there being not any match, isn't it? Unless you can find spec elaborating it is acceptable, don't do it. The test pass might be just service behavior, which might not work on another service. | public DnsZoneImpl withETagCheck() {
this.eTagState.withImplicitETagCheckOnCreate();
this.eTagState.withImplicitETagCheckOnUpdate();
return this;
} | this.eTagState.withImplicitETagCheckOnUpdate(); | public DnsZoneImpl withETagCheck() {
this.eTagState.withImplicitETagCheckOnCreateOrUpdate(this.isInCreateMode());
return this;
} | class DnsZoneImpl
extends GroupableResourceImpl<
DnsZone,
ZoneInner,
DnsZoneImpl,
DnsZoneManager>
implements
DnsZone,
DnsZone.Definition,
DnsZone.Update {
private ARecordSets aRecordSets;
private AaaaRecordSets aaaaRecordSets;
private CaaRecordSets caaRecordSets;
private CNameRecordSets cnameRecordSets;
private MXRecor... | class DnsZoneImpl
extends GroupableResourceImpl<
DnsZone,
ZoneInner,
DnsZoneImpl,
DnsZoneManager>
implements
DnsZone,
DnsZone.Definition,
DnsZone.Update {
private ARecordSets aRecordSets;
private AaaaRecordSets aaaaRecordSets;
private CaaRecordSets caaRecordSets;
private CNameRecordSets cnameRecordSets;
private MXRecor... |
Agree. I just commit changes for this. Now it will only set one of them by verifying inner.id(). | public DnsZoneImpl withETagCheck() {
this.eTagState.withImplicitETagCheckOnCreate();
this.eTagState.withImplicitETagCheckOnUpdate();
return this;
} | this.eTagState.withImplicitETagCheckOnUpdate(); | public DnsZoneImpl withETagCheck() {
this.eTagState.withImplicitETagCheckOnCreateOrUpdate(this.isInCreateMode());
return this;
} | class DnsZoneImpl
extends GroupableResourceImpl<
DnsZone,
ZoneInner,
DnsZoneImpl,
DnsZoneManager>
implements
DnsZone,
DnsZone.Definition,
DnsZone.Update {
private ARecordSets aRecordSets;
private AaaaRecordSets aaaaRecordSets;
private CaaRecordSets caaRecordSets;
private CNameRecordSets cnameRecordSets;
private MXRecor... | class DnsZoneImpl
extends GroupableResourceImpl<
DnsZone,
ZoneInner,
DnsZoneImpl,
DnsZoneManager>
implements
DnsZone,
DnsZone.Definition,
DnsZone.Update {
private ARecordSets aRecordSets;
private AaaaRecordSets aaaaRecordSets;
private CaaRecordSets caaRecordSets;
private CNameRecordSets cnameRecordSets;
private MXRecor... |
I think you need to check length for each of these? Maybe `this.subscriptionId = splits.length > 1 ? splits[1] : null` | private ResourceId(final String id) {
if (id == null) {
this.subscriptionId = null;
this.resourceGroupName = null;
this.name = null;
this.providerNamespace = null;
this.resourceType = null;
this.id = null;
this.parentId = null;
return;
} else {
String[] splits = (id.startsWith("/")) ? id.substring(1).split("/") : id.sp... | if (!splits[0].equalsIgnoreCase("subscriptions")) { | private ResourceId(final String id) {
if (id == null) {
this.subscriptionId = null;
this.resourceGroupName = null;
this.name = null;
this.providerNamespace = null;
this.resourceType = null;
this.id = null;
this.parentId = null;
return;
} else {
String[] splits = (id.startsWith("/")) ? id.substring(1).split("/") : id.sp... | class ResourceId {
private final String subscriptionId;
private final String resourceGroupName;
private final String name;
private final String providerNamespace;
private final String resourceType;
private final String id;
private final String parentId;
private static String badIdErrorText(String id) {
return String.fo... | class ResourceId {
private final String subscriptionId;
private final String resourceGroupName;
private final String name;
private final String providerNamespace;
private final String resourceType;
private final String id;
private final String parentId;
private static String badIdErrorText(String id) {
return String.fo... |
I'll fix it. I just take them out of `switch..case`. | private ResourceId(final String id) {
if (id == null) {
this.subscriptionId = null;
this.resourceGroupName = null;
this.name = null;
this.providerNamespace = null;
this.resourceType = null;
this.id = null;
this.parentId = null;
return;
} else {
String[] splits = (id.startsWith("/")) ? id.substring(1).split("/") : id.sp... | if (!splits[0].equalsIgnoreCase("subscriptions")) { | private ResourceId(final String id) {
if (id == null) {
this.subscriptionId = null;
this.resourceGroupName = null;
this.name = null;
this.providerNamespace = null;
this.resourceType = null;
this.id = null;
this.parentId = null;
return;
} else {
String[] splits = (id.startsWith("/")) ? id.substring(1).split("/") : id.sp... | class ResourceId {
private final String subscriptionId;
private final String resourceGroupName;
private final String name;
private final String providerNamespace;
private final String resourceType;
private final String id;
private final String parentId;
private static String badIdErrorText(String id) {
return String.fo... | class ResourceId {
private final String subscriptionId;
private final String resourceGroupName;
private final String name;
private final String providerNamespace;
private final String resourceType;
private final String id;
private final String parentId;
private static String badIdErrorText(String id) {
return String.fo... |
done | private ResourceId(final String id) {
if (id == null) {
this.subscriptionId = null;
this.resourceGroupName = null;
this.name = null;
this.providerNamespace = null;
this.resourceType = null;
this.id = null;
this.parentId = null;
return;
} else {
String[] splits = (id.startsWith("/")) ? id.substring(1).split("/") : id.sp... | if (!splits[0].equalsIgnoreCase("subscriptions")) { | private ResourceId(final String id) {
if (id == null) {
this.subscriptionId = null;
this.resourceGroupName = null;
this.name = null;
this.providerNamespace = null;
this.resourceType = null;
this.id = null;
this.parentId = null;
return;
} else {
String[] splits = (id.startsWith("/")) ? id.substring(1).split("/") : id.sp... | class ResourceId {
private final String subscriptionId;
private final String resourceGroupName;
private final String name;
private final String providerNamespace;
private final String resourceType;
private final String id;
private final String parentId;
private static String badIdErrorText(String id) {
return String.fo... | class ResourceId {
private final String subscriptionId;
private final String resourceGroupName;
private final String name;
private final String providerNamespace;
private final String resourceType;
private final String id;
private final String parentId;
private static String badIdErrorText(String id) {
return String.fo... |
I'd rename the variable to azureCloud | public static void main(String[] args) {
LOGGER.info("---------------------");
LOGGER.info("KEY VAULT - SECRETS");
LOGGER.info("IDENTITY - CREDENTIAL");
LOGGER.info("---------------------");
String authorityHostAlias = System.getenv("AZURE_CLOUD");
String authorityHost = AUTHORITY_HOST_MAP.getOrDefault(
authorityHostAl... | String authorityHostAlias = System.getenv("AZURE_CLOUD"); | public static void main(String[] args) {
LOGGER.info("---------------------");
LOGGER.info("KEY VAULT - SECRETS");
LOGGER.info("IDENTITY - CREDENTIAL");
LOGGER.info("---------------------");
String azureCloud = System.getenv("AZURE_CLOUD");
String authorityHost = AUTHORITY_HOST_MAP.getOrDefault(
azureCloud, KnownAuthor... | class KeyVaultSecrets {
private static SecretClient secretClient;
private static final String SECRET_NAME = "MySecretName-" + UUID.randomUUID();
private static final String SECRET_VALUE = "MySecretValue";
private static final Logger LOGGER = LoggerFactory.getLogger(KeyVaultSecrets.class);
private static HashMap<String,... | class KeyVaultSecrets {
private static SecretClient secretClient;
private static final String SECRET_NAME = "MySecretName-" + UUID.randomUUID();
private static final String SECRET_VALUE = "MySecretValue";
private static final Logger LOGGER = LoggerFactory.getLogger(KeyVaultSecrets.class);
private static HashMap<String,... |
partition split normally takes 10-20 min to complete. how are we ensuring that the test sees partition split completing within its life time? | public void readFeedDocumentsAfterSplit() {
createdFeedCollectionForSplit = createFeedCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
setupReadFeedDocuments(createdFeedCollectionForSplit, FEED_COUNT);
changeFeedProcessor = ChangeFeedProcessor.changeFeedProcessorBuilder()
.hostName(hostName)
.handleChanges(changeFeedP... | createdFeedCollectionForSplit.replaceProvisionedThroughput(FEED_COLLECTION_THROUGHPUT).subscribeOn(Schedulers.elastic()) | public void readFeedDocumentsAfterSplit() throws InterruptedException {
CosmosAsyncContainer createdFeedCollectionForSplit = createLeaseCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT);
try {
List<CosmosItemProperties> cre... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private CosmosAsyncContainer createdFeedCollection... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private final String hostName = RandomStringUtils.... |
don't catch `InterruptedException` if that's thrown, we can fail the test. | public void readFeedDocumentsAfterSplit() {
createdFeedCollectionForSplit = createFeedCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
setupReadFeedDocuments(createdFeedCollectionForSplit, FEED_COUNT);
changeFeedProcessor = ChangeFeedProcessor.changeFeedProcessorBuilder()
.hostName(hostName)
.handleChanges(changeFeedP... | log.error(e.getMessage()); | public void readFeedDocumentsAfterSplit() throws InterruptedException {
CosmosAsyncContainer createdFeedCollectionForSplit = createLeaseCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT);
try {
List<CosmosItemProperties> cre... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private CosmosAsyncContainer createdFeedCollection... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private final String hostName = RandomStringUtils.... |
don't catch `InterruptedException` if that's thrown, we can fail the test. | public void readFeedDocumentsAfterSplit() {
createdFeedCollectionForSplit = createFeedCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
setupReadFeedDocuments(createdFeedCollectionForSplit, FEED_COUNT);
changeFeedProcessor = ChangeFeedProcessor.changeFeedProcessorBuilder()
.hostName(hostName)
.handleChanges(changeFeedP... | } catch (InterruptedException e) { | public void readFeedDocumentsAfterSplit() throws InterruptedException {
CosmosAsyncContainer createdFeedCollectionForSplit = createLeaseCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT);
try {
List<CosmosItemProperties> cre... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private CosmosAsyncContainer createdFeedCollection... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private final String hostName = RandomStringUtils.... |
here and elsewhere please. we don't need to catch this, let it get thrown | public void readFeedDocumentsAfterSplit() {
createdFeedCollectionForSplit = createFeedCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
setupReadFeedDocuments(createdFeedCollectionForSplit, FEED_COUNT);
changeFeedProcessor = ChangeFeedProcessor.changeFeedProcessorBuilder()
.hostName(hostName)
.handleChanges(changeFeedP... | } catch (InterruptedException e) { | public void readFeedDocumentsAfterSplit() throws InterruptedException {
CosmosAsyncContainer createdFeedCollectionForSplit = createLeaseCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT);
try {
List<CosmosItemProperties> cre... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private CosmosAsyncContainer createdFeedCollection... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private final String hostName = RandomStringUtils.... |
There's a check later to ensure that we see at least 2 partitions. In regular case it takes couple minutes (not 10 minutes) to detect the split. | public void readFeedDocumentsAfterSplit() {
createdFeedCollectionForSplit = createFeedCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
setupReadFeedDocuments(createdFeedCollectionForSplit, FEED_COUNT);
changeFeedProcessor = ChangeFeedProcessor.changeFeedProcessorBuilder()
.hostName(hostName)
.handleChanges(changeFeedP... | createdFeedCollectionForSplit.replaceProvisionedThroughput(FEED_COLLECTION_THROUGHPUT).subscribeOn(Schedulers.elastic()) | public void readFeedDocumentsAfterSplit() throws InterruptedException {
CosmosAsyncContainer createdFeedCollectionForSplit = createLeaseCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT);
try {
List<CosmosItemProperties> cre... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private CosmosAsyncContainer createdFeedCollection... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private final String hostName = RandomStringUtils.... |
The try/catch is needed to avoid compilation errors such as: "Error:(440, 29) java: unreported exception java.lang.InterruptedException; must be caught or declared to be thrown" | public void readFeedDocumentsAfterSplit() {
createdFeedCollectionForSplit = createFeedCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
setupReadFeedDocuments(createdFeedCollectionForSplit, FEED_COUNT);
changeFeedProcessor = ChangeFeedProcessor.changeFeedProcessorBuilder()
.hostName(hostName)
.handleChanges(changeFeedP... | } catch (InterruptedException e) { | public void readFeedDocumentsAfterSplit() throws InterruptedException {
CosmosAsyncContainer createdFeedCollectionForSplit = createLeaseCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT);
try {
List<CosmosItemProperties> cre... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private CosmosAsyncContainer createdFeedCollection... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private final String hostName = RandomStringUtils.... |
We need to in this case, in order to avoid compilation errors... | public void readFeedDocumentsAfterSplit() {
createdFeedCollectionForSplit = createFeedCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
setupReadFeedDocuments(createdFeedCollectionForSplit, FEED_COUNT);
changeFeedProcessor = ChangeFeedProcessor.changeFeedProcessorBuilder()
.hostName(hostName)
.handleChanges(changeFeedP... | log.error(e.getMessage()); | public void readFeedDocumentsAfterSplit() throws InterruptedException {
CosmosAsyncContainer createdFeedCollectionForSplit = createLeaseCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT);
try {
List<CosmosItemProperties> cre... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private CosmosAsyncContainer createdFeedCollection... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private final String hostName = RandomStringUtils.... |
why can't we add exception to the test method signature? | public void readFeedDocumentsAfterSplit() {
createdFeedCollectionForSplit = createFeedCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
setupReadFeedDocuments(createdFeedCollectionForSplit, FEED_COUNT);
changeFeedProcessor = ChangeFeedProcessor.changeFeedProcessorBuilder()
.hostName(hostName)
.handleChanges(changeFeedP... | log.error(e.getMessage()); | public void readFeedDocumentsAfterSplit() throws InterruptedException {
CosmosAsyncContainer createdFeedCollectionForSplit = createLeaseCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT);
try {
List<CosmosItemProperties> cre... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private CosmosAsyncContainer createdFeedCollection... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private final String hostName = RandomStringUtils.... |
makes sense here. so please use this instead to translate checked to unchecked exception. https://projectreactor.io/docs/core/release/api/reactor/core/Exceptions.html#propagate-java.lang.Throwable- if `InterruptedException` we should error out. | public void readFeedDocumentsAfterSplit() {
createdFeedCollectionForSplit = createFeedCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
setupReadFeedDocuments(createdFeedCollectionForSplit, FEED_COUNT);
changeFeedProcessor = ChangeFeedProcessor.changeFeedProcessorBuilder()
.hostName(hostName)
.handleChanges(changeFeedP... | } catch (InterruptedException e) { | public void readFeedDocumentsAfterSplit() throws InterruptedException {
CosmosAsyncContainer createdFeedCollectionForSplit = createLeaseCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT);
try {
List<CosmosItemProperties> cre... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private CosmosAsyncContainer createdFeedCollection... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private final String hostName = RandomStringUtils.... |
Good suggestion, but it goes way beyond what we need to address at this time which is to release a fix for the CFP ASAP. Feel free to open an issue and assign it to me to refactor these tests and remove the handling of the exception. | public void readFeedDocumentsAfterSplit() {
createdFeedCollectionForSplit = createFeedCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
setupReadFeedDocuments(createdFeedCollectionForSplit, FEED_COUNT);
changeFeedProcessor = ChangeFeedProcessor.changeFeedProcessorBuilder()
.hostName(hostName)
.handleChanges(changeFeedP... | } catch (InterruptedException e) { | public void readFeedDocumentsAfterSplit() throws InterruptedException {
CosmosAsyncContainer createdFeedCollectionForSplit = createLeaseCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT);
try {
List<CosmosItemProperties> cre... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private CosmosAsyncContainer createdFeedCollection... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private final String hostName = RandomStringUtils.... |
replied on a similar comment below... | public void readFeedDocumentsAfterSplit() {
createdFeedCollectionForSplit = createFeedCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
setupReadFeedDocuments(createdFeedCollectionForSplit, FEED_COUNT);
changeFeedProcessor = ChangeFeedProcessor.changeFeedProcessorBuilder()
.hostName(hostName)
.handleChanges(changeFeedP... | log.error(e.getMessage()); | public void readFeedDocumentsAfterSplit() throws InterruptedException {
CosmosAsyncContainer createdFeedCollectionForSplit = createLeaseCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT);
try {
List<CosmosItemProperties> cre... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private CosmosAsyncContainer createdFeedCollection... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private final String hostName = RandomStringUtils.... |
@milismsft I have already signed off on v3, and I agree with you on v3 as this is hotfix for v3 it should go out as soon as possible. IMO, on v4 we should do the right thing (this is not in prod yet) rather than introducing technical debt. | public void readFeedDocumentsAfterSplit() {
createdFeedCollectionForSplit = createFeedCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
setupReadFeedDocuments(createdFeedCollectionForSplit, FEED_COUNT);
changeFeedProcessor = ChangeFeedProcessor.changeFeedProcessorBuilder()
.hostName(hostName)
.handleChanges(changeFeedP... | } catch (InterruptedException e) { | public void readFeedDocumentsAfterSplit() throws InterruptedException {
CosmosAsyncContainer createdFeedCollectionForSplit = createLeaseCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT);
try {
List<CosmosItemProperties> cre... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private CosmosAsyncContainer createdFeedCollection... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private final String hostName = RandomStringUtils.... |
V4 latest release is currently used by couple customers a preview. | public void readFeedDocumentsAfterSplit() {
createdFeedCollectionForSplit = createFeedCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
setupReadFeedDocuments(createdFeedCollectionForSplit, FEED_COUNT);
changeFeedProcessor = ChangeFeedProcessor.changeFeedProcessorBuilder()
.hostName(hostName)
.handleChanges(changeFeedP... | } catch (InterruptedException e) { | public void readFeedDocumentsAfterSplit() throws InterruptedException {
CosmosAsyncContainer createdFeedCollectionForSplit = createLeaseCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT);
try {
List<CosmosItemProperties> cre... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private CosmosAsyncContainer createdFeedCollection... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private final String hostName = RandomStringUtils.... |
I'll deal with the debt later; the changes you're requesting go beyond what this PR/work item should address. IMHO et's keep things simple enough in case we need to review this later and use a different PR to address other things. | public void readFeedDocumentsAfterSplit() {
createdFeedCollectionForSplit = createFeedCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
setupReadFeedDocuments(createdFeedCollectionForSplit, FEED_COUNT);
changeFeedProcessor = ChangeFeedProcessor.changeFeedProcessorBuilder()
.hostName(hostName)
.handleChanges(changeFeedP... | } catch (InterruptedException e) { | public void readFeedDocumentsAfterSplit() throws InterruptedException {
CosmosAsyncContainer createdFeedCollectionForSplit = createLeaseCollection(FEED_COLLECTION_THROUGHPUT_FOR_SPLIT);
CosmosAsyncContainer createdLeaseCollection = createLeaseCollection(LEASE_COLLECTION_THROUGHPUT);
try {
List<CosmosItemProperties> cre... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private CosmosAsyncContainer createdFeedCollection... | class ChangeFeedProcessorTest extends TestSuiteBase {
private final static Logger log = LoggerFactory.getLogger(ChangeFeedProcessorTest.class);
private static final ObjectMapper OBJECT_MAPPER = Utils.getSimpleObjectMapper();
private CosmosAsyncDatabase createdDatabase;
private final String hostName = RandomStringUtils.... |
LeaseToken, ContinuationToken, Owner are Camel case, but timestamp, id, etag are not is that expected? also for Owner, timestamp, ContinuationToken, LeaseToken we probably should define constants. | public void serialize(ServiceItemLease lease, JsonGenerator writer, SerializerProvider serializerProvider) {
try {
writer.writeStartObject();
writer.writeStringField(Constants.Properties.ID, lease.getId());
writer.writeStringField(Constants.Properties.E_TAG, lease.getETag());
writer.writeStringField("LeaseToken", lease... | writer.writeStringField("Owner", lease.getOwner()); | public void serialize(ServiceItemLease lease, JsonGenerator writer, SerializerProvider serializerProvider) {
try {
writer.writeStartObject();
writer.writeStringField(Constants.Properties.ID, lease.getId());
writer.writeStringField(Constants.Properties.E_TAG, lease.getETag());
writer.writeStringField(PROPERTY_NAME_LEASE... | class members
private static final long serialVersionUID = 1L;
protected ServiceItemLeaseJsonSerializer() { this(null); } | class members
private static final long serialVersionUID = 1L;
protected ServiceItemLeaseJsonSerializer() { this(null); } |
The current naming convention follows .Net and the content of a lease document as written from that code. The idea behind this design is that you can have CFP instances resuming work from both platforms, Java and .NET. The ServiceItemLease is internal only (not exposed to the user); for the easy of debugging keeping th... | public void serialize(ServiceItemLease lease, JsonGenerator writer, SerializerProvider serializerProvider) {
try {
writer.writeStartObject();
writer.writeStringField(Constants.Properties.ID, lease.getId());
writer.writeStringField(Constants.Properties.E_TAG, lease.getETag());
writer.writeStringField("LeaseToken", lease... | writer.writeStringField("Owner", lease.getOwner()); | public void serialize(ServiceItemLease lease, JsonGenerator writer, SerializerProvider serializerProvider) {
try {
writer.writeStartObject();
writer.writeStringField(Constants.Properties.ID, lease.getId());
writer.writeStringField(Constants.Properties.E_TAG, lease.getETag());
writer.writeStringField(PROPERTY_NAME_LEASE... | class members
private static final long serialVersionUID = 1L;
protected ServiceItemLeaseJsonSerializer() { this(null); } | class members
private static final long serialVersionUID = 1L;
protected ServiceItemLeaseJsonSerializer() { this(null); } |
May be explaining here that `To disable auto-renew, user have to set MaxAutoRenewDuration to zero.` And default is true | public Flux<ServiceBusReceivedMessage> receive(ReceiveAsyncOptions options) {
if (isDisposed.get()) {
return fluxError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "receive")));
}
if (Objects.isNull(options)) {
return fluxError(logger, new NullPointerException("'options' cannot ... | return fluxError(logger, new IllegalArgumentException("'maxAutoRenewDuration' cannot be negative.")); | public Flux<ServiceBusReceivedMessage> receive(ReceiveAsyncOptions options) {
if (isDisposed.get()) {
return fluxError(logger, new IllegalStateException(
String.format(INVALID_OPERATION_DISPOSED_RECEIVER, "receive")));
}
if (Objects.isNull(options)) {
return fluxError(logger, new NullPointerException("'options' cannot ... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private fi... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private fi... |
What happens if they set Duration.ZERO? Would we try the window timeout approach? | void startPartitionPump(PartitionOwnership claimedOwnership, Checkpoint checkpoint) {
if (partitionPumps.containsKey(claimedOwnership.getPartitionId())) {
logger.verbose("Consumer is already running for this partition {}", claimedOwnership.getPartitionId());
return;
}
try {
PartitionContext partitionContext = new Part... | if (maxWaitTime != null) { | void startPartitionPump(PartitionOwnership claimedOwnership, Checkpoint checkpoint) {
if (partitionPumps.containsKey(claimedOwnership.getPartitionId())) {
logger.verbose("Consumer is already running for this partition {}", claimedOwnership.getPartitionId());
return;
}
try {
PartitionContext partitionContext = new Part... | class PartitionPumpManager {
private final ClientLogger logger = new ClientLogger(PartitionPumpManager.class);
private final CheckpointStore checkpointStore;
private final Map<String, EventHubConsumerAsyncClient> partitionPumps = new ConcurrentHashMap<>();
private final Supplier<PartitionProcessor> partitionProcessorFa... | class PartitionPumpManager {
private final ClientLogger logger = new ClientLogger(PartitionPumpManager.class);
private final CheckpointStore checkpointStore;
private final Map<String, EventHubConsumerAsyncClient> partitionPumps = new ConcurrentHashMap<>();
private final Supplier<PartitionProcessor> partitionProcessorFa... |
Added validation to check that duration is not zero and also switched to window timeout as that seems like the more suited operator here. | void startPartitionPump(PartitionOwnership claimedOwnership, Checkpoint checkpoint) {
if (partitionPumps.containsKey(claimedOwnership.getPartitionId())) {
logger.verbose("Consumer is already running for this partition {}", claimedOwnership.getPartitionId());
return;
}
try {
PartitionContext partitionContext = new Part... | if (maxWaitTime != null) { | void startPartitionPump(PartitionOwnership claimedOwnership, Checkpoint checkpoint) {
if (partitionPumps.containsKey(claimedOwnership.getPartitionId())) {
logger.verbose("Consumer is already running for this partition {}", claimedOwnership.getPartitionId());
return;
}
try {
PartitionContext partitionContext = new Part... | class PartitionPumpManager {
private final ClientLogger logger = new ClientLogger(PartitionPumpManager.class);
private final CheckpointStore checkpointStore;
private final Map<String, EventHubConsumerAsyncClient> partitionPumps = new ConcurrentHashMap<>();
private final Supplier<PartitionProcessor> partitionProcessorFa... | class PartitionPumpManager {
private final ClientLogger logger = new ClientLogger(PartitionPumpManager.class);
private final CheckpointStore checkpointStore;
private final Map<String, EventHubConsumerAsyncClient> partitionPumps = new ConcurrentHashMap<>();
private final Supplier<PartitionProcessor> partitionProcessorFa... |
@milismsft we need to have explicit automated tests for partition split. We have some tests for partition split that you can use as a sample: DocumentProducerTest (unit test) ReadMyWritesConsistencyTest (integration test) | public Mono<Void> run(CancellationToken cancellationToken) {
this.lastContinuation = this.settings.getStartContinuation();
this.isFirstQueryForChangeFeeds = true;
this.options.requestContinuation(this.lastContinuation);
return Flux.just(this)
.flatMap( value -> {
if (cancellationToken.isCancellationRequested()) {
retur... | this.resultException = new PartitionSplitException("Partition split.", this.lastContinuation); | public Mono<Void> run(CancellationToken cancellationToken) {
this.lastContinuation = this.settings.getStartContinuation();
this.isFirstQueryForChangeFeeds = true;
this.options.requestContinuation(this.lastContinuation);
return Flux.just(this)
.flatMap( value -> {
if (cancellationToken.isCancellationRequested()) {
retur... | class PartitionProcessorImpl implements PartitionProcessor {
private static final Logger logger = LoggerFactory.getLogger(PartitionProcessorImpl.class);
private static final int DefaultMaxItemCount = 100;
private final ProcessorSettings settings;
private final PartitionCheckpointer checkpointer;
private final ChangeFee... | class PartitionProcessorImpl implements PartitionProcessor {
private static final Logger logger = LoggerFactory.getLogger(PartitionProcessorImpl.class);
private static final int DefaultMaxItemCount = 100;
private final ProcessorSettings settings;
private final PartitionCheckpointer checkpointer;
private final ChangeFee... |
I've added a specific test for splits in V4 respective change. The challenge is that public emulator does not support splitting so the test must be run against the cloud service. | public Mono<Void> run(CancellationToken cancellationToken) {
this.lastContinuation = this.settings.getStartContinuation();
this.isFirstQueryForChangeFeeds = true;
this.options.requestContinuation(this.lastContinuation);
return Flux.just(this)
.flatMap( value -> {
if (cancellationToken.isCancellationRequested()) {
retur... | this.resultException = new PartitionSplitException("Partition split.", this.lastContinuation); | public Mono<Void> run(CancellationToken cancellationToken) {
this.lastContinuation = this.settings.getStartContinuation();
this.isFirstQueryForChangeFeeds = true;
this.options.requestContinuation(this.lastContinuation);
return Flux.just(this)
.flatMap( value -> {
if (cancellationToken.isCancellationRequested()) {
retur... | class PartitionProcessorImpl implements PartitionProcessor {
private static final Logger logger = LoggerFactory.getLogger(PartitionProcessorImpl.class);
private static final int DefaultMaxItemCount = 100;
private final ProcessorSettings settings;
private final PartitionCheckpointer checkpointer;
private final ChangeFee... | class PartitionProcessorImpl implements PartitionProcessor {
private static final Logger logger = LoggerFactory.getLogger(PartitionProcessorImpl.class);
private static final int DefaultMaxItemCount = 100;
private final ProcessorSettings settings;
private final PartitionCheckpointer checkpointer;
private final ChangeFee... |
if we add tests on v4 that should be good enough. thanks. | public Mono<Void> run(CancellationToken cancellationToken) {
this.lastContinuation = this.settings.getStartContinuation();
this.isFirstQueryForChangeFeeds = true;
this.options.requestContinuation(this.lastContinuation);
return Flux.just(this)
.flatMap( value -> {
if (cancellationToken.isCancellationRequested()) {
retur... | this.resultException = new PartitionSplitException("Partition split.", this.lastContinuation); | public Mono<Void> run(CancellationToken cancellationToken) {
this.lastContinuation = this.settings.getStartContinuation();
this.isFirstQueryForChangeFeeds = true;
this.options.requestContinuation(this.lastContinuation);
return Flux.just(this)
.flatMap( value -> {
if (cancellationToken.isCancellationRequested()) {
retur... | class PartitionProcessorImpl implements PartitionProcessor {
private static final Logger logger = LoggerFactory.getLogger(PartitionProcessorImpl.class);
private static final int DefaultMaxItemCount = 100;
private final ProcessorSettings settings;
private final PartitionCheckpointer checkpointer;
private final ChangeFee... | class PartitionProcessorImpl implements PartitionProcessor {
private static final Logger logger = LoggerFactory.getLogger(PartitionProcessorImpl.class);
private static final int DefaultMaxItemCount = 100;
private final ProcessorSettings settings;
private final PartitionCheckpointer checkpointer;
private final ChangeFee... |
To save duplicated logic, this method should call the maximal overload. | public IterableStream<ServiceBusReceivedMessage> receive(int maxMessages) {
if (maxMessages <= 0) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"'maxMessages' cannot be less than or equal to 0. maxMessages: " + maxMessages));
}
final Flux<ServiceBusReceivedMessage> messages = Flux.create(emitter -> q... | if (maxMessages <= 0) { | public IterableStream<ServiceBusReceivedMessage> receive(int maxMessages) {
return receive(maxMessages, operationTimeout);
} | class ServiceBusReceiverClient implements AutoCloseable {
private static final Duration DEFAULT_RECEIVE_WAIT_TIME = Duration.ofMinutes(1);
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverClient.class);
private final AtomicInteger idGenerator = new AtomicInteger();
private final ServiceBusReceiver... | class ServiceBusReceiverClient implements AutoCloseable {
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverClient.class);
private final AtomicInteger idGenerator = new AtomicInteger();
private final ServiceBusReceiverAsyncClient asyncClient;
private final Duration operationTimeout;
/**
* Creates a... |
Possible NullPointerException if maxWaitTime is null | public IterableStream<ServiceBusReceivedMessage> receive(int maxMessages, Duration maxWaitTime) {
if (maxMessages <= 0) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"'maxMessages' cannot be less than or equal to 0. maxMessages: " + maxMessages));
} else if (maxWaitTime.isNegative() || maxWaitTime.is... | } else if (maxWaitTime.isNegative() || maxWaitTime.isZero()) { | public IterableStream<ServiceBusReceivedMessage> receive(int maxMessages, Duration maxWaitTime) {
if (maxMessages <= 0) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"'maxMessages' cannot be less than or equal to 0. maxMessages: " + maxMessages));
} else if (Objects.isNull(maxWaitTime)) {
throw logge... | class ServiceBusReceiverClient implements AutoCloseable {
private static final Duration DEFAULT_RECEIVE_WAIT_TIME = Duration.ofMinutes(1);
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverClient.class);
private final AtomicInteger idGenerator = new AtomicInteger();
private final ServiceBusReceiver... | class ServiceBusReceiverClient implements AutoCloseable {
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverClient.class);
private final AtomicInteger idGenerator = new AtomicInteger();
private final ServiceBusReceiverAsyncClient asyncClient;
private final Duration operationTimeout;
/**
* Creates a... |
This logic is done in MessageProcessor now. | public Mono<ServiceBusReceivedMessage> receiveDeferredMessage(long sequenceNumber) {
return connectionProcessor
.flatMap(connection -> connection.getManagementNode(entityPath, entityType))
.flatMap(node -> node.receiveDeferredMessage(receiveMode, sequenceNumber))
.map(receivedMessage -> {
if (receiveMode == ReceiveMode... | .map(receivedMessage -> { | public Mono<ServiceBusReceivedMessage> receiveDeferredMessage(long sequenceNumber) {
return connectionProcessor
.flatMap(connection -> connection.getManagementNode(entityPath, entityType))
.flatMap(node -> node.receiveDeferredMessage(receiveMode, sequenceNumber))
.map(receivedMessage -> {
if (receiveMode == ReceiveMode... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private static final UUID ZERO_LOCK_TOKEN = new UUID(0L, 0L);
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private fi... |
getQueueName(). When running the test if you set the right environment variables, you don't need to make these manual changes. | protected void beforeTest() {
final String queueName = "hemant-test2";
Assertions.assertNotNull(queueName, "'queueName' cannot be null.");
sender = createBuilder().sender().queueName(queueName).buildAsyncClient();
receiver = createBuilder()
.receiver()
.queueName(queueName)
.isAutoComplete(true)
.buildAsyncClient();
re... | final String queueName = "hemant-test2"; | protected void beforeTest() {
final String queueName = getQueueName();
Assertions.assertNotNull(queueName, "'queueName' cannot be null.");
sender = createBuilder().sender().queueName(queueName).buildAsyncClient();
receiver = createBuilder()
.receiver()
.queueName(queueName)
.buildAsyncClient();
receiverManualComplete =... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private static final String CONTENTS = "Test-contents";
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClientIntegrationTest.class);
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusReceiverAsy... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private static final String CONTENTS = "Test-contents";
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClientIntegrationTest.class);
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusReceiverAsy... |
String.matches() way of matching regex to String has a good perf cost. String matches forces the input regex to always first get compiled via a Pattern.compile() and doing it on every call comes with a perf cost. There is an alternative to String.matches and retain the perf, updated with that logic. | private boolean isRefreshTokenString(String str) {
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
if ((ch < '0' || ch > '9') && (ch < 'A' || ch > 'Z') && (ch < 'a' || ch > 'z')
&& ch != '_' && ch != '-' && ch != '.') {
return false;
}
}
return true;
} | return true; | private boolean isRefreshTokenString(String str) {
return REFRESH_TOKEN_PATTERN.matcher(str).matches();
} | class VisualStudioCacheAccessor {
private static final String PLATFORM_NOT_SUPPORTED_ERROR = "Platform could not be determined for VS Code"
+ " credential authentication.";
private final ClientLogger logger = new ClientLogger(VisualStudioCacheAccessor.class);
/**
* Creates an instance of {@link VisualStudioCacheAccesso... | class VisualStudioCacheAccessor {
private static final String PLATFORM_NOT_SUPPORTED_ERROR = "Platform could not be determined for VS Code"
+ " credential authentication.";
private final ClientLogger logger = new ClientLogger(VisualStudioCacheAccessor.class);
private static final Pattern REFRESH_TOKEN_PATTERN = Pattern... |
It won't be zero lock token. It'll be null or empty. They had zero lock token because they used uuid before. | public Mono<ServiceBusReceivedMessage> receiveDeferredMessage(long sequenceNumber) {
return connectionProcessor
.flatMap(connection -> connection.getManagementNode(entityPath, entityType))
.flatMap(node -> node.receiveDeferredMessage(receiveMode, sequenceNumber))
.map(receivedMessage -> {
if (receiveMode == ReceiveMode... | if (receiveMode == ReceiveMode.PEEK_LOCK && !CoreUtils.isNullOrEmpty(receivedMessage.getLockToken())) { | public Mono<ServiceBusReceivedMessage> receiveDeferredMessage(long sequenceNumber) {
return connectionProcessor
.flatMap(connection -> connection.getManagementNode(entityPath, entityType))
.flatMap(node -> node.receiveDeferredMessage(receiveMode, sequenceNumber))
.map(receivedMessage -> {
if (receiveMode == ReceiveMode... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private static final UUID ZERO_LOCK_TOKEN = new UUID(0L, 0L);
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private fi... |
You need to format this document. Ctrl+Alt+L. The spacing is off. | void receiveBySequenceNumberAndAbandon() {
final String messageTrackingId = UUID.randomUUID().toString();
final ServiceBusMessage message = TestUtils.getServiceBusMessage(CONTENTS, messageTrackingId, 0);
final Duration timeout = Duration.ofSeconds(2);
final ServiceBusReceivedMessage receivedMessage = sender.send(messag... | final ServiceBusReceivedMessage receivedDeferredMessage = receiverManualComplete | void receiveBySequenceNumberAndAbandon() {
final String messageTrackingId = UUID.randomUUID().toString();
final ServiceBusMessage message = TestUtils.getServiceBusMessage(CONTENTS, messageTrackingId, 0);
final Duration timeout = Duration.ofSeconds(2);
final ReceiveAsyncOptions options = new ReceiveAsyncOptions().setEna... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private static final String CONTENTS = "Test-contents";
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClientIntegrationTest.class);
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusReceiverAsy... | class ServiceBusReceiverAsyncClientIntegrationTest extends IntegrationTestBase {
private static final String CONTENTS = "Test-contents";
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClientIntegrationTest.class);
private ServiceBusReceiverAsyncClient receiver;
private ServiceBusReceiverAsy... |
So you don't need to do the conversion to uuid from string | public Mono<ServiceBusReceivedMessage> receiveDeferredMessage(long sequenceNumber) {
return connectionProcessor
.flatMap(connection -> connection.getManagementNode(entityPath, entityType))
.flatMap(node -> node.receiveDeferredMessage(receiveMode, sequenceNumber))
.map(receivedMessage -> {
if (receiveMode == ReceiveMode... | if (receiveMode == ReceiveMode.PEEK_LOCK && !CoreUtils.isNullOrEmpty(receivedMessage.getLockToken())) { | public Mono<ServiceBusReceivedMessage> receiveDeferredMessage(long sequenceNumber) {
return connectionProcessor
.flatMap(connection -> connection.getManagementNode(entityPath, entityType))
.flatMap(node -> node.receiveDeferredMessage(receiveMode, sequenceNumber))
.map(receivedMessage -> {
if (receiveMode == ReceiveMode... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private static final UUID ZERO_LOCK_TOKEN = new UUID(0L, 0L);
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new... | class ServiceBusReceiverAsyncClient implements AutoCloseable {
private static final DeadLetterOptions DEFAULT_DEAD_LETTER_OPTIONS = new DeadLetterOptions();
private final AtomicBoolean isDisposed = new AtomicBoolean();
private final ClientLogger logger = new ClientLogger(ServiceBusReceiverAsyncClient.class);
private fi... |
Does setting the default timeout change the timeout for all tests running outside this class too? | static void beforeAll() {
StepVerifier.setDefaultTimeout(Duration.ofSeconds(30));
} | StepVerifier.setDefaultTimeout(Duration.ofSeconds(30)); | static void beforeAll() {
StepVerifier.setDefaultTimeout(Duration.ofSeconds(30));
} | class ActiveClientTokenManagerTest {
private static final String AUDIENCE = "an-audience-test";
private static final String SCOPES = "scopes-test";
private static final Duration DEFAULT_DURATION = Duration.ofSeconds(20);
@Mock
private ClaimsBasedSecurityNode cbsNode;
@BeforeAll
@AfterAll
static void afterAll() {
StepVe... | class ActiveClientTokenManagerTest {
private static final String AUDIENCE = "an-audience-test";
private static final String SCOPES = "scopes-test";
private static final Duration DEFAULT_DURATION = Duration.ofSeconds(20);
@Mock
private ClaimsBasedSecurityNode cbsNode;
@BeforeAll
@AfterAll
static void afterAll() {
StepVe... |
No. I have an `AfterAll` notation to reset the timeout. | static void beforeAll() {
StepVerifier.setDefaultTimeout(Duration.ofSeconds(30));
} | StepVerifier.setDefaultTimeout(Duration.ofSeconds(30)); | static void beforeAll() {
StepVerifier.setDefaultTimeout(Duration.ofSeconds(30));
} | class ActiveClientTokenManagerTest {
private static final String AUDIENCE = "an-audience-test";
private static final String SCOPES = "scopes-test";
private static final Duration DEFAULT_DURATION = Duration.ofSeconds(20);
@Mock
private ClaimsBasedSecurityNode cbsNode;
@BeforeAll
@AfterAll
static void afterAll() {
StepVe... | class ActiveClientTokenManagerTest {
private static final String AUDIENCE = "an-audience-test";
private static final String SCOPES = "scopes-test";
private static final Duration DEFAULT_DURATION = Duration.ofSeconds(20);
@Mock
private ClaimsBasedSecurityNode cbsNode;
@BeforeAll
@AfterAll
static void afterAll() {
StepVe... |
It would be better to have a null check in all these retryPolicy setters. | public KeyClientBuilder retryPolicy(RetryPolicy retryPolicy) {
this.retryPolicy = retryPolicy;
return this;
} | this.retryPolicy = retryPolicy; | public KeyClientBuilder retryPolicy(RetryPolicy retryPolicy) {
Objects.requireNonNull(retryPolicy, "The retry policy cannot be bull");
this.retryPolicy = retryPolicy;
return this;
} | class KeyClientBuilder {
private final ClientLogger logger = new ClientLogger(KeyClientBuilder.class);
private static final String AZURE_KEY_VAULT_KEYS = "azure-key-vault-keys.properties";
private static final String SDK_NAME = "name";
private static final String SDK_VERSION = "version";
private final List<HttpPipeline... | class KeyClientBuilder {
private final ClientLogger logger = new ClientLogger(KeyClientBuilder.class);
private static final String AZURE_KEY_VAULT_KEYS = "azure-key-vault-keys.properties";
private static final String SDK_NAME = "name";
private static final String SDK_VERSION = "version";
private final List<HttpPipeline... |
The options don't seem to be propagated here. | public ServiceBusReceiverAsyncClient buildAsyncClient() {
final MessagingEntityType entityType = validateEntityPaths(logger, connectionStringEntityName, topicName,
queueName);
final String entityPath;
switch (entityType) {
case QUEUE:
entityPath = queueName;
break;
case TOPIC:
if (isNullOrEmpty(subscriptionName)) {
thr... | final ReceiverOptions receiverOptions = new ReceiverOptions(receiveMode, prefetchCount); | public ServiceBusReceiverAsyncClient buildAsyncClient() {
final MessagingEntityType entityType = validateEntityPaths(logger, connectionStringEntityName, topicName,
queueName);
final String entityPath;
switch (entityType) {
case QUEUE:
entityPath = queueName;
break;
case TOPIC:
if (isNullOrEmpty(subscriptionName)) {
thr... | class ServiceBusReceiverClientBuilder {
private static final int DEFAULT_PREFETCH_COUNT = 1;
private int prefetchCount = DEFAULT_PREFETCH_COUNT;
private String queueName;
private String subscriptionName;
private String topicName;
private String sessionId;
private ReceiveMode receiveMode = ReceiveMode.PEEK_LOCK;
private... | class ServiceBusReceiverClientBuilder {
private static final int DEFAULT_PREFETCH_COUNT = 1;
private int prefetchCount = DEFAULT_PREFETCH_COUNT;
private String queueName;
private String subscriptionName;
private String topicName;
private String sessionId;
private ReceiveMode receiveMode = ReceiveMode.PEEK_LOCK;
private... |
Why is it always false? If later on, you're inferring it from the presence of a `sessionId`, the "enableSession" isn't required. | public ServiceBusReceiverAsyncClient buildAsyncClient() {
final MessagingEntityType entityType = validateEntityPaths(logger, connectionStringEntityName, topicName,
queueName);
final String entityPath;
switch (entityType) {
case QUEUE:
entityPath = queueName;
break;
case TOPIC:
if (isNullOrEmpty(subscriptionName)) {
thr... | false, sessionId); | public ServiceBusReceiverAsyncClient buildAsyncClient() {
final MessagingEntityType entityType = validateEntityPaths(logger, connectionStringEntityName, topicName,
queueName);
final String entityPath;
switch (entityType) {
case QUEUE:
entityPath = queueName;
break;
case TOPIC:
if (isNullOrEmpty(subscriptionName)) {
thr... | class ServiceBusReceiverClientBuilder {
private static final int DEFAULT_PREFETCH_COUNT = 1;
private int prefetchCount = DEFAULT_PREFETCH_COUNT;
private String queueName;
private String subscriptionName;
private String topicName;
private String sessionId;
private ReceiveMode receiveMode = ReceiveMode.PEEK_LOCK;
private... | class ServiceBusReceiverClientBuilder {
private static final int DEFAULT_PREFETCH_COUNT = 1;
private int prefetchCount = DEFAULT_PREFETCH_COUNT;
private String queueName;
private String subscriptionName;
private String topicName;
private String sessionId;
private ReceiveMode receiveMode = ReceiveMode.PEEK_LOCK;
private... |
Should this be logger throw? | public static Flux<ByteBuffer> toFluxByteBuffer(InputStream inputStream) {
Pair pair = new Pair();
return Flux.just(true)
.repeat()
.map(ignore -> {
byte[] buffer = new byte[BYTE_BUFFER_CHUNK_SIZE];
try {
int numBytes = inputStream.read(buffer);
if (numBytes > 0) {
return pair.buffer(ByteBuffer.wrap(buffer, 0, numBytes... | throw Exceptions.propagate(ioe); | public static Flux<ByteBuffer> toFluxByteBuffer(InputStream inputStream) {
Pair pair = new Pair();
return Flux.just(true)
.repeat()
.map(ignore -> {
byte[] buffer = new byte[BYTE_BUFFER_CHUNK_SIZE];
try {
int numBytes = inputStream.read(buffer);
if (numBytes > 0) {
return pair.buffer(ByteBuffer.wrap(buffer, 0, numBytes... | class Utility {
private static final ClientLogger LOGGER = new ClientLogger(Utility.class);
private static final int BYTE_BUFFER_CHUNK_SIZE = 4096;
private Utility() {
}
/**
* Creates a Flux of ByteBuffer, with each ByteBuffer wrapping bytes read from the given
* InputStream.
*
* @param inputStream InputStream to back ... | class Utility {
private static final ClientLogger LOGGER = new ClientLogger(Utility.class);
private static final int BYTE_BUFFER_CHUNK_SIZE = 4096;
private Utility() {
}
/**
* Automatically detect byte buffer's content type.
*
* Given the source: <a href="https:
*
* @param buffer The byte buffer input.
*
* @return The ... |
updated | public static Flux<ByteBuffer> toFluxByteBuffer(InputStream inputStream) {
Pair pair = new Pair();
return Flux.just(true)
.repeat()
.map(ignore -> {
byte[] buffer = new byte[BYTE_BUFFER_CHUNK_SIZE];
try {
int numBytes = inputStream.read(buffer);
if (numBytes > 0) {
return pair.buffer(ByteBuffer.wrap(buffer, 0, numBytes... | throw Exceptions.propagate(ioe); | public static Flux<ByteBuffer> toFluxByteBuffer(InputStream inputStream) {
Pair pair = new Pair();
return Flux.just(true)
.repeat()
.map(ignore -> {
byte[] buffer = new byte[BYTE_BUFFER_CHUNK_SIZE];
try {
int numBytes = inputStream.read(buffer);
if (numBytes > 0) {
return pair.buffer(ByteBuffer.wrap(buffer, 0, numBytes... | class Utility {
private static final ClientLogger LOGGER = new ClientLogger(Utility.class);
private static final int BYTE_BUFFER_CHUNK_SIZE = 4096;
private Utility() {
}
/**
* Creates a Flux of ByteBuffer, with each ByteBuffer wrapping bytes read from the given
* InputStream.
*
* @param inputStream InputStream to back ... | class Utility {
private static final ClientLogger LOGGER = new ClientLogger(Utility.class);
private static final int BYTE_BUFFER_CHUNK_SIZE = 4096;
private Utility() {
}
/**
* Automatically detect byte buffer's content type.
*
* Given the source: <a href="https:
*
* @param buffer The byte buffer input.
*
* @return The ... |
just 'ModelInfo' should be good | static CustomFormModel toCustomFormModel(Model modelResponse) {
com.azure.ai.formrecognizer.implementation.models.ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(new IllegalArgumentException("Invalid status Model Id."));
}
List<For... | } | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with invalid status.",
modelInfo.getModelId())));
}
L... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
private static List<FormRecognizerError> setTrainingErrors(List<ErrorInformation> trainingErrorList) {
List<FormRecognizerError> formRecognizerErrorList = new Array... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... |
If the underlying polling results in an error state/invalid completion state what does this `IterableStream` end up being? | public void extractReceipt() {
String receiptSourceUrl = "https:
SyncPoller<OperationResult, IterableStream<RecognizedReceipt>> syncPoller =
formRecognizerClient.beginRecognizeReceiptsFromUrl(receiptSourceUrl);
IterableStream<RecognizedReceipt> receiptPageResults = syncPoller.getFinalResult();
receiptPageResults.forEac... | IterableStream<RecognizedReceipt> receiptPageResults = syncPoller.getFinalResult(); | public void extractReceipt() {
String receiptSourceUrl = "https:
SyncPoller<OperationResult, IterableStream<RecognizedReceipt>> syncPoller =
formRecognizerClient.beginRecognizeReceiptsFromUrl(receiptSourceUrl);
IterableStream<RecognizedReceipt> receiptPageResults = syncPoller.getFinalResult();
receiptPageResults.forEac... | class ReadmeSamples {
private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient();
/**
* Code snippet for configuring http client.
*/
public void configureHttpClient() {
HttpClient client = new NettyAsyncHttpClientBuilder()
.port(8080)
.wiretap(true)
.build();
}
/**
* Code snippe... | class ReadmeSamples {
private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient();
/**
* Code snippet for configuring http client.
*/
public void configureHttpClient() {
HttpClient client = new NettyAsyncHttpClientBuilder()
.port(8080)
.wiretap(true)
.build();
}
/**
* Code snippe... |
Should this check for `null`, empty, and less than eight elements? | private static BoundingBox toBoundingBox(List<Float> serviceBoundingBox) {
if (CoreUtils.isNullOrEmpty(serviceBoundingBox)) {
return null;
}
Point topLeft = new Point(serviceBoundingBox.get(0), serviceBoundingBox.get(1));
Point topRight = new Point(serviceBoundingBox.get(2), serviceBoundingBox.get(3));
Point bottomLeft... | if (CoreUtils.isNullOrEmpty(serviceBoundingBox)) { | private static BoundingBox toBoundingBox(List<Float> serviceBoundingBox) {
if (CoreUtils.isNullOrEmpty(serviceBoundingBox) || (serviceBoundingBox.size() % 2) != 0) {
return null;
}
List<Point> pointList = new ArrayList<>();
for (int i = 0; i < serviceBoundingBox.size(); i++) {
pointList.add(new Point(serviceBoundingBox... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern COMPILE = Pattern.compile("[^0-9]+");
private Transforms() {
}
/**
* Helper method to transform the service returned {@link AnalyzeResult} to SDK model {@link RecognizedForm}.
*
* @param analyz... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... |
Since `BoundingBox` infers a box shape, four corners, should it accept the specific points as parameters in the constructor? Unless `BoundingBox` is meant to be more generic and should be renamed `BoundingArea`. Magic parameter ordering in lists is generally a confusing API design. | private static BoundingBox toBoundingBox(List<Float> serviceBoundingBox) {
if (CoreUtils.isNullOrEmpty(serviceBoundingBox)) {
return null;
}
Point topLeft = new Point(serviceBoundingBox.get(0), serviceBoundingBox.get(1));
Point topRight = new Point(serviceBoundingBox.get(2), serviceBoundingBox.get(3));
Point bottomLeft... | return new BoundingBox(Arrays.asList(topLeft, topRight, bottomLeft, bottomRight)); | private static BoundingBox toBoundingBox(List<Float> serviceBoundingBox) {
if (CoreUtils.isNullOrEmpty(serviceBoundingBox) || (serviceBoundingBox.size() % 2) != 0) {
return null;
}
List<Point> pointList = new ArrayList<>();
for (int i = 0; i < serviceBoundingBox.size(); i++) {
pointList.add(new Point(serviceBoundingBox... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern COMPILE = Pattern.compile("[^0-9]+");
private Transforms() {
}
/**
* Helper method to transform the service returned {@link AnalyzeResult} to SDK model {@link RecognizedForm}.
*
* @param analyz... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... |
Could make this a little more performant by hard coding in `ModelStatus.INVALID`'s `toString` value since that is the only time we will reach this code path. ```java new IllegalArgumentException(String.format("Model Id %s returned with invalid status", modelInfo.getModelId()) ``` | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with status: %s",
modelInfo.getModelId(), modelInfo.g... | modelInfo.getModelId(), modelInfo.getStatus()))); | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with invalid status.",
modelInfo.getModelId())));
}
L... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... |
Same here - this can be created from the builder instead. | public FormTrainingClient getFormTrainingClient() {
return new FormTrainingClient(client.getFormTrainingAsyncClient());
} | } | public FormTrainingClient getFormTrainingClient() {
return new FormTrainingClient(client.getFormTrainingAsyncClient());
} | class FormRecognizerClient {
private final FormRecognizerAsyncClient client;
/**
* Create a {@link FormRecognizerClient client} that sends requests to the Form Recognizer service's endpoint.
* Each service call goes through the {@link FormRecognizerClientBuilder
*
* @param client The {@link FormRecognizerClient} that t... | class FormRecognizerClient {
private final FormRecognizerAsyncClient client;
/**
* Create a {@link FormRecognizerClient client} that sends requests to the Form Recognizer service's endpoint.
* Each service call goes through the {@link FormRecognizerClientBuilder
*
* @param client The {@link FormRecognizerClient} that t... |
Should move the instantiation of `USReceiptItem` outside of the inner for loop, this will construct it when the entire `entrySet` has been processed and will churn a lot of short lived objects. | private static List<USReceiptItem> toReceiptItems(FormField<?> fieldValueItems) {
List<FormField<?>> fieldValueArray = (List<FormField<?>>) fieldValueItems.getFieldValue();
List<USReceiptItem> receiptItemList = new ArrayList<>();
FormField<String> name = null;
FormField<Float> quantity = null;
FormField<Float> price = ... | receiptItem = new USReceiptItem(name, quantity, price, totalPrice); | private static List<USReceiptItem> toReceiptItems(FormField<?> fieldValueItems) {
List<FormField<?>> fieldValueArray = (List<FormField<?>>) fieldValueItems.getFieldValue();
List<USReceiptItem> receiptItemList = null;
for (FormField<?> eachFieldValue : fieldValueArray) {
receiptItemList = new ArrayList<>();
Map<String, ... | class ReceiptExtensions {
/**
* Static method to convert an incoming receipt to a {@link USReceipt type}.
*
* @param receipt The {@link RecognizedReceipt recognized receipt}.
*
* @return The converted {@link USReceipt US locale receipt} type.
*/
public static USReceipt asUSReceipt(RecognizedReceipt receipt) {
USReceipt... | class ReceiptExtensions {
private ReceiptExtensions() {
}
/**
* Static method to convert an incoming receipt to a {@link USReceipt type}.
*
* @param receipt The {@link RecognizedReceipt recognized receipt}.
*
* @return The converted {@link USReceipt US locale receipt} type.
*/
@SuppressWarnings("unchecked")
public stat... |
It may be more performant to use `Collections.singletonList` here, note that this will create an unmodifiable list so if this will be added onto that will throw an exception. | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | new IterableStream<FormPage>(Arrays.asList(formPages.get(pageNumber - 1))))); | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern COMPILE = Pattern.compile("[^0-9]+");
private Transforms() {
}
/**
* Helper method to transform the service returned {@link AnalyzeResult} to SDK model {@link RecognizedForm}.
*
* @param analyz... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... |
As per naming conventions, acronyms should follow camel-case convention but in this case, I am not sure naming this as `asUsReceipt` is good. | public static USReceipt asUSReceipt(RecognizedReceipt receipt) {
USReceiptType receiptType = null;
FormField<String> merchantName = null;
FormField<String> merchantAddress = null;
FormField<String> merchantPhoneNumber = null;
FormField<Float> subtotal = null;
FormField<Float> tax = null;
FormField<Float> tip = null;
Fo... | FormField<String> merchantName = null; | public static USReceipt asUSReceipt(RecognizedReceipt receipt) {
USReceiptType receiptType = null;
FormField<String> merchantName = null;
FormField<String> merchantAddress = null;
FormField<String> merchantPhoneNumber = null;
FormField<Float> subtotal = null;
FormField<Float> tax = null;
FormField<Float> tip = null;
Fo... | class ReceiptExtensions {
/**
* Static method to convert an incoming receipt to a {@link USReceipt type}.
*
* @param receipt The {@link RecognizedReceipt recognized receipt}.
*
* @return The converted {@link USReceipt US locale receipt} type.
*/
/**
* Helper method to convert the service level
* {@link com.azure.ai.for... | class ReceiptExtensions {
private ReceiptExtensions() {
}
/**
* Static method to convert an incoming receipt to a {@link USReceipt type}.
*
* @param receipt The {@link RecognizedReceipt recognized receipt}.
*
* @return The converted {@link USReceipt US locale receipt} type.
*/
@SuppressWarnings("unchecked")
/**
* Helpe... |
Uncomment this. | public static void main(final String[] args) {
FormTrainingClient client = new FormRecognizerClientBuilder()
.apiKey(new AzureKeyCredential("{api_key}"))
.endpoint("https:
.buildClient().getFormTrainingClient();
String modelId = "{model-Id}";
CustomFormModel customModel = client.getCustomModel(modelId);
System.out.prin... | public static void main(final String[] args) {
FormTrainingClient client = new FormRecognizerClientBuilder()
.apiKey(new AzureKeyCredential("{api_key}"))
.endpoint("https:
.buildClient().getFormTrainingClient();
String modelId = "{model-Id}";
CustomFormModel customModel = client.getCustomModel(modelId);
System.out.prin... | class CustomModelOperations {
/**
* Main program to invoke the demo for performing operations of a custom model.
*
* @param args Unused. Arguments to the program.
*/
} | class CustomModelOperations {
/**
* Main program to invoke the demo for performing operations of a custom model.
*
* @param args Unused. Arguments to the program.
*/
} | |
Dependent on this open PR - #9975. | public static void main(final String[] args) {
FormTrainingClient client = new FormRecognizerClientBuilder()
.apiKey(new AzureKeyCredential("{api_key}"))
.endpoint("https:
.buildClient().getFormTrainingClient();
String modelId = "{model-Id}";
CustomFormModel customModel = client.getCustomModel(modelId);
System.out.prin... | public static void main(final String[] args) {
FormTrainingClient client = new FormRecognizerClientBuilder()
.apiKey(new AzureKeyCredential("{api_key}"))
.endpoint("https:
.buildClient().getFormTrainingClient();
String modelId = "{model-Id}";
CustomFormModel customModel = client.getCustomModel(modelId);
System.out.prin... | class CustomModelOperations {
/**
* Main program to invoke the demo for performing operations of a custom model.
*
* @param args Unused. Arguments to the program.
*/
} | class CustomModelOperations {
/**
* Main program to invoke the demo for performing operations of a custom model.
*
* @param args Unused. Arguments to the program.
*/
} | |
updated. | private static List<USReceiptItem> toReceiptItems(FormField<?> fieldValueItems) {
List<FormField<?>> fieldValueArray = (List<FormField<?>>) fieldValueItems.getFieldValue();
List<USReceiptItem> receiptItemList = new ArrayList<>();
FormField<String> name = null;
FormField<Float> quantity = null;
FormField<Float> price = ... | receiptItem = new USReceiptItem(name, quantity, price, totalPrice); | private static List<USReceiptItem> toReceiptItems(FormField<?> fieldValueItems) {
List<FormField<?>> fieldValueArray = (List<FormField<?>>) fieldValueItems.getFieldValue();
List<USReceiptItem> receiptItemList = null;
for (FormField<?> eachFieldValue : fieldValueArray) {
receiptItemList = new ArrayList<>();
Map<String, ... | class ReceiptExtensions {
/**
* Static method to convert an incoming receipt to a {@link USReceipt type}.
*
* @param receipt The {@link RecognizedReceipt recognized receipt}.
*
* @return The converted {@link USReceipt US locale receipt} type.
*/
public static USReceipt asUSReceipt(RecognizedReceipt receipt) {
USReceipt... | class ReceiptExtensions {
private ReceiptExtensions() {
}
/**
* Static method to convert an incoming receipt to a {@link USReceipt type}.
*
* @param receipt The {@link RecognizedReceipt recognized receipt}.
*
* @return The converted {@link USReceipt US locale receipt} type.
*/
@SuppressWarnings("unchecked")
public stat... |
It was originally designed to be accepting specific four parameters in the constructor but with service feedback that it could be in future grow to accept more than just 8 points extended, updated this to accept a list. | private static BoundingBox toBoundingBox(List<Float> serviceBoundingBox) {
if (CoreUtils.isNullOrEmpty(serviceBoundingBox)) {
return null;
}
Point topLeft = new Point(serviceBoundingBox.get(0), serviceBoundingBox.get(1));
Point topRight = new Point(serviceBoundingBox.get(2), serviceBoundingBox.get(3));
Point bottomLeft... | return new BoundingBox(Arrays.asList(topLeft, topRight, bottomLeft, bottomRight)); | private static BoundingBox toBoundingBox(List<Float> serviceBoundingBox) {
if (CoreUtils.isNullOrEmpty(serviceBoundingBox) || (serviceBoundingBox.size() % 2) != 0) {
return null;
}
List<Point> pointList = new ArrayList<>();
for (int i = 0; i < serviceBoundingBox.size(); i++) {
pointList.add(new Point(serviceBoundingBox... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern COMPILE = Pattern.compile("[^0-9]+");
private Transforms() {
}
/**
* Helper method to transform the service returned {@link AnalyzeResult} to SDK model {@link RecognizedForm}.
*
* @param analyz... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... |
The respective fetch operation checks for the status on the returned model and raises exception on the model.errors. | public void extractReceipt() {
String receiptSourceUrl = "https:
SyncPoller<OperationResult, IterableStream<RecognizedReceipt>> syncPoller =
formRecognizerClient.beginRecognizeReceiptsFromUrl(receiptSourceUrl);
IterableStream<RecognizedReceipt> receiptPageResults = syncPoller.getFinalResult();
receiptPageResults.forEac... | IterableStream<RecognizedReceipt> receiptPageResults = syncPoller.getFinalResult(); | public void extractReceipt() {
String receiptSourceUrl = "https:
SyncPoller<OperationResult, IterableStream<RecognizedReceipt>> syncPoller =
formRecognizerClient.beginRecognizeReceiptsFromUrl(receiptSourceUrl);
IterableStream<RecognizedReceipt> receiptPageResults = syncPoller.getFinalResult();
receiptPageResults.forEac... | class ReadmeSamples {
private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient();
/**
* Code snippet for configuring http client.
*/
public void configureHttpClient() {
HttpClient client = new NettyAsyncHttpClientBuilder()
.port(8080)
.wiretap(true)
.build();
}
/**
* Code snippe... | class ReadmeSamples {
private FormRecognizerClient formRecognizerClient = new FormRecognizerClientBuilder().buildClient();
/**
* Code snippet for configuring http client.
*/
public void configureHttpClient() {
HttpClient client = new NettyAsyncHttpClientBuilder()
.port(8080)
.wiretap(true)
.build();
}
/**
* Code snippe... |
same as https://github.com/Azure/azure-sdk-for-java/pull/9988#discussion_r407790136 | public FormTrainingClient getFormTrainingClient() {
return new FormTrainingClient(client.getFormTrainingAsyncClient());
} | } | public FormTrainingClient getFormTrainingClient() {
return new FormTrainingClient(client.getFormTrainingAsyncClient());
} | class FormRecognizerClient {
private final FormRecognizerAsyncClient client;
/**
* Create a {@link FormRecognizerClient client} that sends requests to the Form Recognizer service's endpoint.
* Each service call goes through the {@link FormRecognizerClientBuilder
*
* @param client The {@link FormRecognizerClient} that t... | class FormRecognizerClient {
private final FormRecognizerAsyncClient client;
/**
* Create a {@link FormRecognizerClient client} that sends requests to the Form Recognizer service's endpoint.
* Each service call goes through the {@link FormRecognizerClientBuilder
*
* @param client The {@link FormRecognizerClient} that t... |
Looks like label and name are mixed (?) name should contain the "field-" string, and label the value you have in `eachField` | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with status: %s",
modelInfo.getModelId(), modelInfo.g... | String fieldLabel = "field-" + i; | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with invalid status.",
modelInfo.getModelId())));
}
L... | class CustomModelTransforms {
public static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... |
Will this apply even if this is accuracy and not confidence? | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with status: %s",
modelInfo.getModelId(), modelInfo.g... | DEFAULT_CONFIDENCE_VALUE, | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with invalid status.",
modelInfo.getModelId())));
}
L... | class CustomModelTransforms {
public static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... |
It shouldn't apply to accuracy, updated! | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with status: %s",
modelInfo.getModelId(), modelInfo.g... | DEFAULT_CONFIDENCE_VALUE, | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with invalid status.",
modelInfo.getModelId())));
}
L... | class CustomModelTransforms {
public static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... |
Why do we instantiate `clusterFieldSize` in the for loop and use it nowhere else? | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with status: %s",
modelInfo.getModelId(), modelInfo.g... | for (int i = 0, clusterFieldsSize = clusterFields.size(); i < clusterFieldsSize; i++) { | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with invalid status.",
modelInfo.getModelId())));
}
L... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... |
I'm seeing a lot of cases where we are looping over an iterable where we also need to know which index we are at, should we add a helper function which takes a `BiConsumer<Integer, T>` which will maintain the index count and pass the appropriate element? ```java static void forEachWithIndex(Iterable<T> iterable, BiCon... | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with status: %s",
modelInfo.getModelId(), modelInfo.g... | String eachField = clusterFields.get(i); | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with invalid status.",
modelInfo.getModelId())));
}
L... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... |
not sure how Java does it, but asking the same Krista pointed out in in .net, TrainResult can be null. So, will `modelResponse.getTrainResult().getTrainingDocuments()` and all other references work? | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with status: %s",
modelInfo.getModelId(), modelInfo.g... | modelResponse.getTrainResult().getTrainingDocuments().stream() | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with invalid status.",
modelInfo.getModelId())));
}
L... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... |
Updated to check for trainResult as it can be null before referencing the training documents. | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with status: %s",
modelInfo.getModelId(), modelInfo.g... | modelResponse.getTrainResult().getTrainingDocuments().stream() | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with invalid status.",
modelInfo.getModelId())));
}
L... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... |
Updated! | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with status: %s",
modelInfo.getModelId(), modelInfo.g... | String eachField = clusterFields.get(i); | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with invalid status.",
modelInfo.getModelId())));
}
L... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... |
Oh yes, thank you for finding that! | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with status: %s",
modelInfo.getModelId(), modelInfo.g... | String fieldLabel = "field-" + i; | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with invalid status.",
modelInfo.getModelId())));
}
L... | class CustomModelTransforms {
public static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... |
I think that is what we had decided as a team. Do you have any suggestions we discuss it with the crew. | public static USReceipt asUSReceipt(RecognizedReceipt receipt) {
USReceiptType receiptType = null;
FormField<String> merchantName = null;
FormField<String> merchantAddress = null;
FormField<String> merchantPhoneNumber = null;
FormField<Float> subtotal = null;
FormField<Float> tax = null;
FormField<Float> tip = null;
Fo... | FormField<String> merchantName = null; | public static USReceipt asUSReceipt(RecognizedReceipt receipt) {
USReceiptType receiptType = null;
FormField<String> merchantName = null;
FormField<String> merchantAddress = null;
FormField<String> merchantPhoneNumber = null;
FormField<Float> subtotal = null;
FormField<Float> tax = null;
FormField<Float> tip = null;
Fo... | class ReceiptExtensions {
/**
* Static method to convert an incoming receipt to a {@link USReceipt type}.
*
* @param receipt The {@link RecognizedReceipt recognized receipt}.
*
* @return The converted {@link USReceipt US locale receipt} type.
*/
/**
* Helper method to convert the service level
* {@link com.azure.ai.for... | class ReceiptExtensions {
private ReceiptExtensions() {
}
/**
* Static method to convert an incoming receipt to a {@link USReceipt type}.
*
* @param receipt The {@link RecognizedReceipt recognized receipt}.
*
* @return The converted {@link USReceipt US locale receipt} type.
*/
@SuppressWarnings("unchecked")
/**
* Helpe... |
This should use `IterableStream.of`, there is a possibility where `trainingDocumentInfoList` is `null` and the constructor will throw a `NullPointerException` but the factory method will return an empty instance. | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with status: %s",
modelInfo.getModelId(), modelInfo.g... | new IterableStream<TrainingDocumentInfo>(trainingDocumentInfoList)); | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with invalid status.",
modelInfo.getModelId())));
}
L... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... |
Could `subModelList` ever end up empty if both the `if` and `else if` don't pass? | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with status: %s",
modelInfo.getModelId(), modelInfo.g... | List<CustomFormSubModel> subModelList = new ArrayList<>(); | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with invalid status.",
modelInfo.getModelId())));
}
L... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... |
Do these need to be atomic references? | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | AtomicReference<String> formType = new AtomicReference<>("form-"); | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... |
Since `PageRange` is immutable could we create a static instance that is used here? | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | pageRange.set(new PageRange(1, 1)); | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... |
What are some example page ranges the service would return? Taking an example from most printing UIs where you can set an option of print page 3, would the service return a page range of `{ 3 }` or would it be `{ 3, 3 }`? If it is the former would it make defaults to range `1-1` incorrect? | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | if (documentPageRange.size() == 2) { | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... |
The logic here shows that you can't have both labeled and unlabeled, can you change this into an `if / else if`. Once that is done you can remove the check below for `CoreUtils.isNullOrEmpty(documentResults)`. | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... | |
Could you try in PLAYBACK whether these are now OK? | public void canPostDeploymentWhatIfOnResourceGroup() throws Exception {
final String dpName = "dpA" + testId;
resourceClient.deployments()
.define(dpName)
.withExistingResourceGroup(rgName)
.withTemplateLink(templateUri, contentVersion)
.withParametersLink(parametersUri, contentVersion)
.withMode(DeploymentMode.COMPLET... | public void canPostDeploymentWhatIfOnResourceGroup() throws Exception {
final String dpName = "dpA" + testId;
resourceClient.deployments()
.define(dpName)
.withExistingResourceGroup(rgName)
.withTemplateLink(templateUri, contentVersion)
.withParametersLink(parametersUri, contentVersion)
.withMode(DeploymentMode.COMPLET... | class DeploymentsTests extends ResourceManagerTestBase {
private ResourceGroups resourceGroups;
private ResourceGroup resourceGroup;
private String testId;
private String rgName;
private static String templateUri = "https:
private static String blankTemplateUri = "https:
private static String parametersUri = "https:
pr... | class DeploymentsTests extends ResourceManagerTestBase {
private ResourceGroups resourceGroups;
private ResourceGroup resourceGroup;
private String testId;
private String rgName;
private static String templateUri = "https:
private static String blankTemplateUri = "https:
private static String parametersUri = "https:
pr... | |
Could we make this into a variable outside of the scope of the for loop? Should only need to check this once. | static List<FormPage> toRecognizedLayout(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<FormPage> formPages = new ArrayList<>();
forEachWithIndex(readResults, ((index, readResul... | if (!CoreUtils.isNullOrEmpty(pageResults)) { | static List<FormPage> toRecognizedLayout(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<FormPage> formPages = new ArrayList<>();
boolean pageResultsIsNullOrEmpty = CoreUtils.isN... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... |
This could be simplified a bit by using a stream, the logic inside of the lambda would be the same except adding it to the list. ```java return pageResultItem.getTables().stream() .map(/* convert to FormTable */) .collect(Collectors.toList()); ``` | static List<FormTable> getPageTables(PageResult pageResultItem, List<ReadResult> readResults, Integer pageNumber) {
List<FormTable> extractedTablesList = new ArrayList<>();
pageResultItem.getTables().forEach(dataTable -> {
IterableStream<FormTableCell> tableCellList = new IterableStream<>(dataTable.getCells().stream()
... | pageResultItem.getTables().forEach(dataTable -> { | static List<FormTable> getPageTables(PageResult pageResultItem, List<ReadResult> readResults, Integer pageNumber) {
return pageResultItem.getTables().stream()
.map(dataTable ->
new FormTable(dataTable.getRows(), dataTable.getColumns(),
new IterableStream<>(dataTable.getCells().stream()
.map(dataTableCell -> new FormTab... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... |
That is not a known case and should not occur. | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with status: %s",
modelInfo.getModelId(), modelInfo.g... | List<CustomFormSubModel> subModelList = new ArrayList<>(); | static CustomFormModel toCustomFormModel(Model modelResponse) {
ModelInfo modelInfo = modelResponse.getModelInfo();
if (modelInfo.getStatus() == ModelStatus.INVALID) {
throw LOGGER.logExceptionAsError(
new IllegalArgumentException(String.format("Model Id %s returned with invalid status.",
modelInfo.getModelId())));
}
L... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... | class CustomModelTransforms {
private static final ClientLogger LOGGER = new ClientLogger(CustomModelTransforms.class);
private CustomModelTransforms() {
}
/**
* Helper method to convert the {@link Model model Response} from service to {@link CustomFormModel}.
*
* @param modelResponse The {@code Model model response} r... |
Since I am using these two variables in lambda expression below they need to be final in nature. | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | AtomicReference<String> formType = new AtomicReference<>("form-"); | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... |
Yes, it would return {3, 3} according to the current implementation of the service. | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | if (documentPageRange.size() == 2) { | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... |
Either leave `US` as-is or expand it. Don't really like changing this to `Us`. Check with @JonathanGiles too. | public static USReceipt asUSReceipt(RecognizedReceipt receipt) {
USReceiptType receiptType = null;
FormField<String> merchantName = null;
FormField<String> merchantAddress = null;
FormField<String> merchantPhoneNumber = null;
FormField<Float> subtotal = null;
FormField<Float> tax = null;
FormField<Float> tip = null;
Fo... | FormField<String> merchantName = null; | public static USReceipt asUSReceipt(RecognizedReceipt receipt) {
USReceiptType receiptType = null;
FormField<String> merchantName = null;
FormField<String> merchantAddress = null;
FormField<String> merchantPhoneNumber = null;
FormField<Float> subtotal = null;
FormField<Float> tax = null;
FormField<Float> tip = null;
Fo... | class ReceiptExtensions {
/**
* Static method to convert an incoming receipt to a {@link USReceipt type}.
*
* @param receipt The {@link RecognizedReceipt recognized receipt}.
*
* @return The converted {@link USReceipt US locale receipt} type.
*/
/**
* Helper method to convert the service level
* {@link com.azure.ai.for... | class ReceiptExtensions {
private ReceiptExtensions() {
}
/**
* Static method to convert an incoming receipt to a {@link USReceipt type}.
*
* @param receipt The {@link RecognizedReceipt recognized receipt}.
*
* @return The converted {@link USReceipt US locale receipt} type.
*/
@SuppressWarnings("unchecked")
/**
* Helpe... |
edit: updated this. | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | AtomicReference<String> formType = new AtomicReference<>("form-"); | static List<RecognizedForm> toRecognizedForm(AnalyzeResult analyzeResult, boolean includeTextDetails) {
List<ReadResult> readResults = analyzeResult.getReadResults();
List<DocumentResult> documentResults = analyzeResult.getDocumentResults();
List<PageResult> pageResults = analyzeResult.getPageResults();
List<Recognized... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... | class Transforms {
private static final ClientLogger LOGGER = new ClientLogger(Transforms.class);
private static final Pattern NON_DIGIT_PATTERN = Pattern.compile("[^0-9]+");
private static final float DEFAULT_CONFIDENCE_VALUE = 1.0f;
private Transforms() {
}
/**
* Helper method to transform the service returned {@link... |
From what I remember when we are associating requests to responses when using the playback records we explicitly ignore the entire host string. Should be able to simplify the logic to redact the entire host string. | private void redactedAccountName(UrlBuilder urlBuilder) {
String[] hostParts = urlBuilder.getHost().split("\\.");
hostParts[0] = "REDACTED";
urlBuilder.setHost(String.join(".", hostParts));
} | hostParts[0] = "REDACTED"; | private void redactedAccountName(UrlBuilder urlBuilder) {
String[] hostParts = urlBuilder.getHost().split("\\.");
hostParts[0] = "REDACTED";
urlBuilder.setHost(String.join(".", hostParts));
} | class RecordNetworkCallPolicy implements HttpPipelinePolicy {
private static final int DEFAULT_BUFFER_LENGTH = 1024;
private static final String CONTENT_TYPE = "Content-Type";
private static final String CONTENT_ENCODING = "Content-Encoding";
private static final String CONTENT_LENGTH = "Content-Length";
private static... | class RecordNetworkCallPolicy implements HttpPipelinePolicy {
private static final int DEFAULT_BUFFER_LENGTH = 1024;
private static final String CONTENT_TYPE = "Content-Type";
private static final String CONTENT_ENCODING = "Content-Encoding";
private static final String CONTENT_LENGTH = "Content-Length";
private static... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.