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
We need to do this to preserve the case where a user has a URL that looks encoded. - Like if they pass in a url with hello%20hello - if we encode that it'll become hello(whatever % encoding is)20hello, which we don't want to do
public static String encodeUrlPath(String url) { /* Deconstruct the URL and reconstruct it making sure the path is encoded. */ UrlBuilder builder = UrlBuilder.parse(url); String path = builder.getPath(); if (path.startsWith("/")) { path = path.substring(1); } path = Utility.urlEncode(Utility.urlDecode(path)); builder.s...
path = Utility.urlEncode(Utility.urlDecode(path));
public static String encodeUrlPath(String url) { /* Deconstruct the URL and reconstruct it making sure the path is encoded. */ UrlBuilder builder = UrlBuilder.parse(url); String path = builder.getPath(); if (path.startsWith("/")) { path = path.substring(1); } path = Utility.urlEncode(Utility.urlDecode(path)); builder.s...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
This particular if case is because when you call getPath, it returns the path including the starting /. Then when you do setPath for some reason, it makes the URL have two slashes - so I'm just trying to prevent that error from happening. Does that make sense?
public static String encodeUrlPath(String url) { /* Deconstruct the URL and reconstruct it making sure the path is encoded. */ UrlBuilder builder = UrlBuilder.parse(url); String path = builder.getPath(); if (path.startsWith("/")) { path = path.substring(1); } path = Utility.urlEncode(Utility.urlDecode(path)); builder.s...
if (path.startsWith("/")) {
public static String encodeUrlPath(String url) { /* Deconstruct the URL and reconstruct it making sure the path is encoded. */ UrlBuilder builder = UrlBuilder.parse(url); String path = builder.getPath(); if (path.startsWith("/")) { path = path.substring(1); } path = Utility.urlEncode(Utility.urlDecode(path)); builder.s...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
That's not what I meant. Please take a look on this sample url https://github.com/Azure/azure-sdk-for-java/blob/6e23e4acf9b639a87da2bd0f95923c7370290dc8/sdk/storage/azure-storage-blob/src/test/resources/session-records/BlobAPITestcopysourceac%5B4%5D.json#L95 `https://azstoragesdkaccount.blob.core.windows.net/jtccopyso...
public static String encodeUrlPath(String url) { /* Deconstruct the URL and reconstruct it making sure the path is encoded. */ UrlBuilder builder = UrlBuilder.parse(url); String path = builder.getPath(); if (path.startsWith("/")) { path = path.substring(1); } path = Utility.urlEncode(Utility.urlDecode(path)); builder.s...
if (path.startsWith("/")) {
public static String encodeUrlPath(String url) { /* Deconstruct the URL and reconstruct it making sure the path is encoded. */ UrlBuilder builder = UrlBuilder.parse(url); String path = builder.getPath(); if (path.startsWith("/")) { path = path.substring(1); } path = Utility.urlEncode(Utility.urlDecode(path)); builder.s...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
That makes sense.
public static String encodeUrlPath(String url) { /* Deconstruct the URL and reconstruct it making sure the path is encoded. */ UrlBuilder builder = UrlBuilder.parse(url); String path = builder.getPath(); if (path.startsWith("/")) { path = path.substring(1); } path = Utility.urlEncode(Utility.urlDecode(path)); builder.s...
path = Utility.urlEncode(Utility.urlDecode(path));
public static String encodeUrlPath(String url) { /* Deconstruct the URL and reconstruct it making sure the path is encoded. */ UrlBuilder builder = UrlBuilder.parse(url); String path = builder.getPath(); if (path.startsWith("/")) { path = path.substring(1); } path = Utility.urlEncode(Utility.urlDecode(path)); builder.s...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
Oh. Both are equivalent as per the service so it shouldnt matter
public static String encodeUrlPath(String url) { /* Deconstruct the URL and reconstruct it making sure the path is encoded. */ UrlBuilder builder = UrlBuilder.parse(url); String path = builder.getPath(); if (path.startsWith("/")) { path = path.substring(1); } path = Utility.urlEncode(Utility.urlDecode(path)); builder.s...
if (path.startsWith("/")) {
public static String encodeUrlPath(String url) { /* Deconstruct the URL and reconstruct it making sure the path is encoded. */ UrlBuilder builder = UrlBuilder.parse(url); String path = builder.getPath(); if (path.startsWith("/")) { path = path.substring(1); } path = Utility.urlEncode(Utility.urlDecode(path)); builder.s...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
Do we have a test covering that?
public static String encodeUrlPath(String url) { /* Deconstruct the URL and reconstruct it making sure the path is encoded. */ UrlBuilder builder = UrlBuilder.parse(url); String path = builder.getPath(); if (path.startsWith("/")) { path = path.substring(1); } path = Utility.urlEncode(Utility.urlDecode(path)); builder.s...
if (path.startsWith("/")) {
public static String encodeUrlPath(String url) { /* Deconstruct the URL and reconstruct it making sure the path is encoded. */ UrlBuilder builder = UrlBuilder.parse(url); String path = builder.getPath(); if (path.startsWith("/")) { path = path.substring(1); } path = Utility.urlEncode(Utility.urlDecode(path)); builder.s...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
The fact that the tests work is validation that they are the same since otherwise the service would come back with a 404 saying the source doesnt exist.
public static String encodeUrlPath(String url) { /* Deconstruct the URL and reconstruct it making sure the path is encoded. */ UrlBuilder builder = UrlBuilder.parse(url); String path = builder.getPath(); if (path.startsWith("/")) { path = path.substring(1); } path = Utility.urlEncode(Utility.urlDecode(path)); builder.s...
if (path.startsWith("/")) {
public static String encodeUrlPath(String url) { /* Deconstruct the URL and reconstruct it making sure the path is encoded. */ UrlBuilder builder = UrlBuilder.parse(url); String path = builder.getPath(); if (path.startsWith("/")) { path = path.substring(1); } path = Utility.urlEncode(Utility.urlDecode(path)); builder.s...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
I think this need to go into troubleshooting string, rather than just Exception.toSTring() @simplynaveen20
public String toString() { return getClass().getSimpleName() + "{" + "sdkVersion=" + SDK_VERSION + ", error=" + cosmosError + ", resourceAddress='" + resourceAddress + '\'' + ", statusCode=" + statusCode + ", message=" + getMessage() + ", causeInfo=" + causeInfo() + ", responseHeaders=" + responseHeaders + ", requestHe...
return getClass().getSimpleName() + "{" + "sdkVersion=" + SDK_VERSION + ", error=" + cosmosError + ", resourceAddress='"
public String toString() { return getClass().getSimpleName() + "{" + "userAgent=" + USER_AGENT + ", error=" + cosmosError + ", resourceAddress='" + resourceAddress + '\'' + ", statusCode=" + statusCode + ", message=" + getMessage() + ", causeInfo=" + causeInfo() + ", responseHeaders=" + responseHeaders + ", requestHead...
class CosmosException extends AzureException { private static final long serialVersionUID = 1L; private final static String SDK_VERSION = HttpConstants.Versions.SDK_VERSION; private final int statusCode; private final Map<String, String> responseHeaders; private CosmosDiagnostics cosmosDiagnostics; private final Reques...
class CosmosException extends AzureException { private static final long serialVersionUID = 1L; private final static String USER_AGENT = Utils.getUserAgent(); private final int statusCode; private final Map<String, String> responseHeaders; private CosmosDiagnostics cosmosDiagnostics; private final RequestTimeline reque...
My initial thought on that is, we don't want our customers to rely on getting diagnostics string and then logging the exception. It would be much better to have it in all scenarios. For example, below is a very common scenario is : ``` try { some operation. } catch (Exception e) { logger.error("Exception occur...
public String toString() { return getClass().getSimpleName() + "{" + "sdkVersion=" + SDK_VERSION + ", error=" + cosmosError + ", resourceAddress='" + resourceAddress + '\'' + ", statusCode=" + statusCode + ", message=" + getMessage() + ", causeInfo=" + causeInfo() + ", responseHeaders=" + responseHeaders + ", requestHe...
return getClass().getSimpleName() + "{" + "sdkVersion=" + SDK_VERSION + ", error=" + cosmosError + ", resourceAddress='"
public String toString() { return getClass().getSimpleName() + "{" + "userAgent=" + USER_AGENT + ", error=" + cosmosError + ", resourceAddress='" + resourceAddress + '\'' + ", statusCode=" + statusCode + ", message=" + getMessage() + ", causeInfo=" + causeInfo() + ", responseHeaders=" + responseHeaders + ", requestHead...
class CosmosException extends AzureException { private static final long serialVersionUID = 1L; private final static String SDK_VERSION = HttpConstants.Versions.SDK_VERSION; private final int statusCode; private final Map<String, String> responseHeaders; private CosmosDiagnostics cosmosDiagnostics; private final Reques...
class CosmosException extends AzureException { private static final long serialVersionUID = 1L; private final static String USER_AGENT = Utils.getUserAgent(); private final int statusCode; private final Map<String, String> responseHeaders; private CosmosDiagnostics cosmosDiagnostics; private final RequestTimeline reque...
diagnostics string should have all the needed info for troubleshooting (including sdk version). However it is good to have it here too. We can consider adding it to troubleshooting string later.
public String toString() { return getClass().getSimpleName() + "{" + "sdkVersion=" + SDK_VERSION + ", error=" + cosmosError + ", resourceAddress='" + resourceAddress + '\'' + ", statusCode=" + statusCode + ", message=" + getMessage() + ", causeInfo=" + causeInfo() + ", responseHeaders=" + responseHeaders + ", requestHe...
return getClass().getSimpleName() + "{" + "sdkVersion=" + SDK_VERSION + ", error=" + cosmosError + ", resourceAddress='"
public String toString() { return getClass().getSimpleName() + "{" + "userAgent=" + USER_AGENT + ", error=" + cosmosError + ", resourceAddress='" + resourceAddress + '\'' + ", statusCode=" + statusCode + ", message=" + getMessage() + ", causeInfo=" + causeInfo() + ", responseHeaders=" + responseHeaders + ", requestHead...
class CosmosException extends AzureException { private static final long serialVersionUID = 1L; private final static String SDK_VERSION = HttpConstants.Versions.SDK_VERSION; private final int statusCode; private final Map<String, String> responseHeaders; private CosmosDiagnostics cosmosDiagnostics; private final Reques...
class CosmosException extends AzureException { private static final long serialVersionUID = 1L; private final static String USER_AGENT = Utils.getUserAgent(); private final int statusCode; private final Map<String, String> responseHeaders; private CosmosDiagnostics cosmosDiagnostics; private final RequestTimeline reque...
Valid point, I can add it to the diagnostics string as well in this PR. Let me see what needs to be done for that.
public String toString() { return getClass().getSimpleName() + "{" + "sdkVersion=" + SDK_VERSION + ", error=" + cosmosError + ", resourceAddress='" + resourceAddress + '\'' + ", statusCode=" + statusCode + ", message=" + getMessage() + ", causeInfo=" + causeInfo() + ", responseHeaders=" + responseHeaders + ", requestHe...
return getClass().getSimpleName() + "{" + "sdkVersion=" + SDK_VERSION + ", error=" + cosmosError + ", resourceAddress='"
public String toString() { return getClass().getSimpleName() + "{" + "userAgent=" + USER_AGENT + ", error=" + cosmosError + ", resourceAddress='" + resourceAddress + '\'' + ", statusCode=" + statusCode + ", message=" + getMessage() + ", causeInfo=" + causeInfo() + ", responseHeaders=" + responseHeaders + ", requestHead...
class CosmosException extends AzureException { private static final long serialVersionUID = 1L; private final static String SDK_VERSION = HttpConstants.Versions.SDK_VERSION; private final int statusCode; private final Map<String, String> responseHeaders; private CosmosDiagnostics cosmosDiagnostics; private final Reques...
class CosmosException extends AzureException { private static final long serialVersionUID = 1L; private final static String USER_AGENT = Utils.getUserAgent(); private final int statusCode; private final Map<String, String> responseHeaders; private CosmosDiagnostics cosmosDiagnostics; private final RequestTimeline reque...
@moderakh @simplynaveen20 - would it make sense to include the complete `user agent string` on diagnostics or just the SDK_VERSION ?
public String toString() { return getClass().getSimpleName() + "{" + "sdkVersion=" + SDK_VERSION + ", error=" + cosmosError + ", resourceAddress='" + resourceAddress + '\'' + ", statusCode=" + statusCode + ", message=" + getMessage() + ", causeInfo=" + causeInfo() + ", responseHeaders=" + responseHeaders + ", requestHe...
return getClass().getSimpleName() + "{" + "sdkVersion=" + SDK_VERSION + ", error=" + cosmosError + ", resourceAddress='"
public String toString() { return getClass().getSimpleName() + "{" + "userAgent=" + USER_AGENT + ", error=" + cosmosError + ", resourceAddress='" + resourceAddress + '\'' + ", statusCode=" + statusCode + ", message=" + getMessage() + ", causeInfo=" + causeInfo() + ", responseHeaders=" + responseHeaders + ", requestHead...
class CosmosException extends AzureException { private static final long serialVersionUID = 1L; private final static String SDK_VERSION = HttpConstants.Versions.SDK_VERSION; private final int statusCode; private final Map<String, String> responseHeaders; private CosmosDiagnostics cosmosDiagnostics; private final Reques...
class CosmosException extends AzureException { private static final long serialVersionUID = 1L; private final static String USER_AGENT = Utils.getUserAgent(); private final int statusCode; private final Map<String, String> responseHeaders; private CosmosDiagnostics cosmosDiagnostics; private final RequestTimeline reque...
Honestly I prefer it to diagnostic , given we print diagnostic on every exception. It look little odd here on exception
public String toString() { return getClass().getSimpleName() + "{" + "sdkVersion=" + SDK_VERSION + ", error=" + cosmosError + ", resourceAddress='" + resourceAddress + '\'' + ", statusCode=" + statusCode + ", message=" + getMessage() + ", causeInfo=" + causeInfo() + ", responseHeaders=" + responseHeaders + ", requestHe...
return getClass().getSimpleName() + "{" + "sdkVersion=" + SDK_VERSION + ", error=" + cosmosError + ", resourceAddress='"
public String toString() { return getClass().getSimpleName() + "{" + "userAgent=" + USER_AGENT + ", error=" + cosmosError + ", resourceAddress='" + resourceAddress + '\'' + ", statusCode=" + statusCode + ", message=" + getMessage() + ", causeInfo=" + causeInfo() + ", responseHeaders=" + responseHeaders + ", requestHead...
class CosmosException extends AzureException { private static final long serialVersionUID = 1L; private final static String SDK_VERSION = HttpConstants.Versions.SDK_VERSION; private final int statusCode; private final Map<String, String> responseHeaders; private CosmosDiagnostics cosmosDiagnostics; private final Reques...
class CosmosException extends AzureException { private static final long serialVersionUID = 1L; private final static String USER_AGENT = Utils.getUserAgent(); private final int statusCode; private final Map<String, String> responseHeaders; private CosmosDiagnostics cosmosDiagnostics; private final RequestTimeline reque...
Is there an Environment.NewLine or equivalent for Java? It might not work correctly on Windows where new line is `\r\n`
public String toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("userAgent=").append(USER_AGENT).append("\n"); if (this.feedResponseDiagnostics != null) { stringBuilder.append(feedResponseDiagnostics); } else { try { stringBuilder.append(OBJECT_MAPPER.writeValueAsString(this.clientSid...
stringBuilder.append("userAgent=").append(USER_AGENT).append("\n");
public String toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("userAgent=").append(USER_AGENT).append("\n"); if (this.feedResponseDiagnostics != null) { stringBuilder.append(feedResponseDiagnostics); } else { try { stringBuilder.append(OBJECT_MAPPER.writeValueAsString(this.clientSid...
class CosmosDiagnostics { private static final Logger LOGGER = LoggerFactory.getLogger(CosmosDiagnostics.class); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final String USER_AGENT = Utils.getUserAgent(); private ClientSideRequestStatistics clientSideRequestStatistics; private F...
class CosmosDiagnostics { private static final Logger LOGGER = LoggerFactory.getLogger(CosmosDiagnostics.class); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final String USER_AGENT = Utils.getUserAgent(); private ClientSideRequestStatistics clientSideRequestStatistics; private F...
Good point @j82w, we can use - `System.lineSeparator()` https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#lineSeparator-- I will port that change as a separate PR for everywhere in SDK code.
public String toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("userAgent=").append(USER_AGENT).append("\n"); if (this.feedResponseDiagnostics != null) { stringBuilder.append(feedResponseDiagnostics); } else { try { stringBuilder.append(OBJECT_MAPPER.writeValueAsString(this.clientSid...
stringBuilder.append("userAgent=").append(USER_AGENT).append("\n");
public String toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("userAgent=").append(USER_AGENT).append("\n"); if (this.feedResponseDiagnostics != null) { stringBuilder.append(feedResponseDiagnostics); } else { try { stringBuilder.append(OBJECT_MAPPER.writeValueAsString(this.clientSid...
class CosmosDiagnostics { private static final Logger LOGGER = LoggerFactory.getLogger(CosmosDiagnostics.class); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final String USER_AGENT = Utils.getUserAgent(); private ClientSideRequestStatistics clientSideRequestStatistics; private F...
class CosmosDiagnostics { private static final Logger LOGGER = LoggerFactory.getLogger(CosmosDiagnostics.class); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final String USER_AGENT = Utils.getUserAgent(); private ClientSideRequestStatistics clientSideRequestStatistics; private F...
Tracking this issue here : https://github.com/Azure/azure-sdk-for-java/issues/11594
public String toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("userAgent=").append(USER_AGENT).append("\n"); if (this.feedResponseDiagnostics != null) { stringBuilder.append(feedResponseDiagnostics); } else { try { stringBuilder.append(OBJECT_MAPPER.writeValueAsString(this.clientSid...
stringBuilder.append("userAgent=").append(USER_AGENT).append("\n");
public String toString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("userAgent=").append(USER_AGENT).append("\n"); if (this.feedResponseDiagnostics != null) { stringBuilder.append(feedResponseDiagnostics); } else { try { stringBuilder.append(OBJECT_MAPPER.writeValueAsString(this.clientSid...
class CosmosDiagnostics { private static final Logger LOGGER = LoggerFactory.getLogger(CosmosDiagnostics.class); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final String USER_AGENT = Utils.getUserAgent(); private ClientSideRequestStatistics clientSideRequestStatistics; private F...
class CosmosDiagnostics { private static final Logger LOGGER = LoggerFactory.getLogger(CosmosDiagnostics.class); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final String USER_AGENT = Utils.getUserAgent(); private ClientSideRequestStatistics clientSideRequestStatistics; private F...
We should also rename the string wordings -> `maxChannelsPerEndpoint` -> `maxConnectionsPerEndpoint` and `maxRequestsPerChannel` -> `maxRequestsPerConnection`
public String toString() { return "ConnectionPolicy{" + "requestTimeout=" + requestTimeout + ", connectionMode=" + connectionMode + ", maxConnectionPoolSize=" + maxConnectionPoolSize + ", idleConnectionTimeout=" + idleConnectionTimeout + ", userAgentSuffix='" + userAgentSuffix + '\'' + ", throttlingRetryOptions=" + thr...
", maxRequestsPerChannel=" + maxRequestsPerConnection +
public String toString() { return "ConnectionPolicy{" + "requestTimeout=" + requestTimeout + ", connectionMode=" + connectionMode + ", maxConnectionPoolSize=" + maxConnectionPoolSize + ", idleConnectionTimeout=" + idleConnectionTimeout + ", userAgentSuffix='" + userAgentSuffix + '\'' + ", throttlingRetryOptions=" + thr...
class for * more details. * * @param throttlingRetryOptions the RetryOptions instance. * @return the ConnectionPolicy. * @throws IllegalArgumentException thrown if an error occurs */ public ConnectionPolicy setThrottlingRetryOptions(ThrottlingRetryOptions throttlingRetryOptions) { if (throttlingRetryOptions == null) { ...
class for * more details. * * @param throttlingRetryOptions the RetryOptions instance. * @return the ConnectionPolicy. * @throws IllegalArgumentException thrown if an error occurs */ public ConnectionPolicy setThrottlingRetryOptions(ThrottlingRetryOptions throttlingRetryOptions) { if (throttlingRetryOptions == null) { ...
another good catch. change made on my branch. to be committed with this PR.
public String toString() { return "ConnectionPolicy{" + "requestTimeout=" + requestTimeout + ", connectionMode=" + connectionMode + ", maxConnectionPoolSize=" + maxConnectionPoolSize + ", idleConnectionTimeout=" + idleConnectionTimeout + ", userAgentSuffix='" + userAgentSuffix + '\'' + ", throttlingRetryOptions=" + thr...
", maxRequestsPerChannel=" + maxRequestsPerConnection +
public String toString() { return "ConnectionPolicy{" + "requestTimeout=" + requestTimeout + ", connectionMode=" + connectionMode + ", maxConnectionPoolSize=" + maxConnectionPoolSize + ", idleConnectionTimeout=" + idleConnectionTimeout + ", userAgentSuffix='" + userAgentSuffix + '\'' + ", throttlingRetryOptions=" + thr...
class for * more details. * * @param throttlingRetryOptions the RetryOptions instance. * @return the ConnectionPolicy. * @throws IllegalArgumentException thrown if an error occurs */ public ConnectionPolicy setThrottlingRetryOptions(ThrottlingRetryOptions throttlingRetryOptions) { if (throttlingRetryOptions == null) { ...
class for * more details. * * @param throttlingRetryOptions the RetryOptions instance. * @return the ConnectionPolicy. * @throws IllegalArgumentException thrown if an error occurs */ public ConnectionPolicy setThrottlingRetryOptions(ThrottlingRetryOptions throttlingRetryOptions) { if (throttlingRetryOptions == null) { ...
These exceptions should be logged before throwing.
public static JsonElement toGsonElement(JsonNode jsonNode) { if (jsonNode.isArray()) { if (jsonNode instanceof GsonJsonArray) { return ((GsonJsonArray) jsonNode).getJsonArray(); } throw new IllegalArgumentException("JsonNode is an array but isn't GsonJsonArray."); } else if (jsonNode.isNull()) { if (jsonNode instanceof...
throw new IllegalArgumentException("JsonNode is an array but isn't GsonJsonObject.");
public static JsonElement toGsonElement(JsonNode jsonNode) { if (jsonNode.isArray()) { if (jsonNode instanceof GsonJsonArray) { return ((GsonJsonArray) jsonNode).getJsonArray(); } throw LOGGER.logExceptionAsError( new IllegalArgumentException("JsonNode is an array but isn't GsonJsonArray.")); } else if (jsonNode.isNull...
class JsonNodeUtils { /** * Converts an Azure Core {@link JsonNode} into a GSON {@link JsonElement}. * * @param jsonNode The Azure Core {@link JsonNode}. * @return The corresponding GSON {@link JsonElement}. * @throws IllegalArgumentException If the {@link JsonNode} cannot be converted to a {@link JsonElement}. */ /** ...
class JsonNodeUtils { private static final ClientLogger LOGGER = new ClientLogger(JsonNodeUtils.class); /** * Converts an Azure Core {@link JsonNode} into a GSON {@link JsonElement}. * * @param jsonNode The Azure Core {@link JsonNode}. * @return The corresponding GSON {@link JsonElement}. * @throws IllegalArgumentExcep...
Add some tests to include UTF-8 chars.
private static Stream<Arguments> toGsonElementSupplier() { JsonArray jsonArray = new JsonArray(); JsonNull jsonNull = JsonNull.INSTANCE; JsonObject jsonObject = new JsonObject(); JsonPrimitive booleanNode = new JsonPrimitive(true); JsonPrimitive doubleNode = new JsonPrimitive(42D); JsonPrimitive floatNode = new JsonPri...
Arguments.of(new GsonJsonValue("42"), textNode)
private static Stream<Arguments> toGsonElementSupplier() { JsonArray jsonArray = new JsonArray(); JsonNull jsonNull = JsonNull.INSTANCE; JsonObject jsonObject = new JsonObject(); JsonPrimitive booleanNode = new JsonPrimitive(true); JsonPrimitive doubleNode = new JsonPrimitive(42D); JsonPrimitive floatNode = new JsonPri...
class JsonNodeUtilsTests { @AfterEach public void cleanupInlineMocks() { Mockito.framework().clearInlineMocks(); } @ParameterizedTest @MethodSource("toGsonElementSupplier") public void toGsonElement(JsonNode jsonNode, JsonElement expected) { assertEquals(expected, JsonNodeUtils.toGsonElement(jsonNode)); } @Parameterize...
class JsonNodeUtilsTests { @AfterEach public void cleanupInlineMocks() { Mockito.framework().clearInlineMocks(); } @ParameterizedTest @MethodSource("toGsonElementSupplier") public void toGsonElement(JsonNode jsonNode, JsonElement expected) { assertEquals(expected, JsonNodeUtils.toGsonElement(jsonNode)); } @Parameterize...
Will add logging before throwing.
public static JsonElement toGsonElement(JsonNode jsonNode) { if (jsonNode.isArray()) { if (jsonNode instanceof GsonJsonArray) { return ((GsonJsonArray) jsonNode).getJsonArray(); } throw new IllegalArgumentException("JsonNode is an array but isn't GsonJsonArray."); } else if (jsonNode.isNull()) { if (jsonNode instanceof...
throw new IllegalArgumentException("JsonNode is an array but isn't GsonJsonObject.");
public static JsonElement toGsonElement(JsonNode jsonNode) { if (jsonNode.isArray()) { if (jsonNode instanceof GsonJsonArray) { return ((GsonJsonArray) jsonNode).getJsonArray(); } throw LOGGER.logExceptionAsError( new IllegalArgumentException("JsonNode is an array but isn't GsonJsonArray.")); } else if (jsonNode.isNull...
class JsonNodeUtils { /** * Converts an Azure Core {@link JsonNode} into a GSON {@link JsonElement}. * * @param jsonNode The Azure Core {@link JsonNode}. * @return The corresponding GSON {@link JsonElement}. * @throws IllegalArgumentException If the {@link JsonNode} cannot be converted to a {@link JsonElement}. */ /** ...
class JsonNodeUtils { private static final ClientLogger LOGGER = new ClientLogger(JsonNodeUtils.class); /** * Converts an Azure Core {@link JsonNode} into a GSON {@link JsonElement}. * * @param jsonNode The Azure Core {@link JsonNode}. * @return The corresponding GSON {@link JsonElement}. * @throws IllegalArgumentExcep...
Added
private static Stream<Arguments> toGsonElementSupplier() { JsonArray jsonArray = new JsonArray(); JsonNull jsonNull = JsonNull.INSTANCE; JsonObject jsonObject = new JsonObject(); JsonPrimitive booleanNode = new JsonPrimitive(true); JsonPrimitive doubleNode = new JsonPrimitive(42D); JsonPrimitive floatNode = new JsonPri...
Arguments.of(new GsonJsonValue("42"), textNode)
private static Stream<Arguments> toGsonElementSupplier() { JsonArray jsonArray = new JsonArray(); JsonNull jsonNull = JsonNull.INSTANCE; JsonObject jsonObject = new JsonObject(); JsonPrimitive booleanNode = new JsonPrimitive(true); JsonPrimitive doubleNode = new JsonPrimitive(42D); JsonPrimitive floatNode = new JsonPri...
class JsonNodeUtilsTests { @AfterEach public void cleanupInlineMocks() { Mockito.framework().clearInlineMocks(); } @ParameterizedTest @MethodSource("toGsonElementSupplier") public void toGsonElement(JsonNode jsonNode, JsonElement expected) { assertEquals(expected, JsonNodeUtils.toGsonElement(jsonNode)); } @Parameterize...
class JsonNodeUtilsTests { @AfterEach public void cleanupInlineMocks() { Mockito.framework().clearInlineMocks(); } @ParameterizedTest @MethodSource("toGsonElementSupplier") public void toGsonElement(JsonNode jsonNode, JsonElement expected) { assertEquals(expected, JsonNodeUtils.toGsonElement(jsonNode)); } @Parameterize...
nit; GsonJsonValue -> GsonJsonPrimitive
public static JsonElement toGsonElement(JsonNode jsonNode) { if (jsonNode.isArray()) { if (jsonNode instanceof GsonJsonArray) { return ((GsonJsonArray) jsonNode).getJsonArray(); } throw LOGGER.logExceptionAsError( new IllegalArgumentException("JsonNode is an array but isn't GsonJsonArray.")); } else if (jsonNode.isNull...
new IllegalArgumentException("JsonNode is a value but isn't GsonJsonValue."));
public static JsonElement toGsonElement(JsonNode jsonNode) { if (jsonNode.isArray()) { if (jsonNode instanceof GsonJsonArray) { return ((GsonJsonArray) jsonNode).getJsonArray(); } throw LOGGER.logExceptionAsError( new IllegalArgumentException("JsonNode is an array but isn't GsonJsonArray.")); } else if (jsonNode.isNull...
class JsonNodeUtils { private static final ClientLogger LOGGER = new ClientLogger(JsonNodeUtils.class); /** * Converts an Azure Core {@link JsonNode} into a GSON {@link JsonElement}. * * @param jsonNode The Azure Core {@link JsonNode}. * @return The corresponding GSON {@link JsonElement}. * @throws IllegalArgumentExcep...
class JsonNodeUtils { private static final ClientLogger LOGGER = new ClientLogger(JsonNodeUtils.class); /** * Converts an Azure Core {@link JsonNode} into a GSON {@link JsonElement}. * * @param jsonNode The Azure Core {@link JsonNode}. * @return The corresponding GSON {@link JsonElement}. * @throws IllegalArgumentExcep...
Good catch
public static JsonElement toGsonElement(JsonNode jsonNode) { if (jsonNode.isArray()) { if (jsonNode instanceof GsonJsonArray) { return ((GsonJsonArray) jsonNode).getJsonArray(); } throw LOGGER.logExceptionAsError( new IllegalArgumentException("JsonNode is an array but isn't GsonJsonArray.")); } else if (jsonNode.isNull...
new IllegalArgumentException("JsonNode is a value but isn't GsonJsonValue."));
public static JsonElement toGsonElement(JsonNode jsonNode) { if (jsonNode.isArray()) { if (jsonNode instanceof GsonJsonArray) { return ((GsonJsonArray) jsonNode).getJsonArray(); } throw LOGGER.logExceptionAsError( new IllegalArgumentException("JsonNode is an array but isn't GsonJsonArray.")); } else if (jsonNode.isNull...
class JsonNodeUtils { private static final ClientLogger LOGGER = new ClientLogger(JsonNodeUtils.class); /** * Converts an Azure Core {@link JsonNode} into a GSON {@link JsonElement}. * * @param jsonNode The Azure Core {@link JsonNode}. * @return The corresponding GSON {@link JsonElement}. * @throws IllegalArgumentExcep...
class JsonNodeUtils { private static final ClientLogger LOGGER = new ClientLogger(JsonNodeUtils.class); /** * Converts an Azure Core {@link JsonNode} into a GSON {@link JsonElement}. * * @param jsonNode The Azure Core {@link JsonNode}. * @return The corresponding GSON {@link JsonElement}. * @throws IllegalArgumentExcep...
Ok, `com.google.gson.JsonArray::get` return `JsonNull.INSTANCE` for null value. In azure-core `JacksonJsonArray::has` we use native Jackson::JsonArray::[has](https://fasterxml.github.io/jackson-databind/javadoc/2.6/com/fasterxml/jackson/databind/JsonNode.html#has-int-)(int). As per doc that native method return `true`...
public boolean has(int index) { if (index < 0 || index >= jsonArray.size()) { return false; } return jsonArray.get(index) != null; }
return jsonArray.get(index) != null;
public boolean has(int index) { if (index < 0 || index >= jsonArray.size()) { return false; } return jsonArray.get(index) != null; }
class GsonJsonArray implements JsonArray { private final ClientLogger logger = new ClientLogger(GsonJsonArray.class); private final com.google.gson.JsonArray jsonArray; /** * Constructs a {@link JsonArray} backed by an empty GSON {@link com.google.gson.JsonArray}. */ public GsonJsonArray() { this.jsonArray = new com.go...
class GsonJsonArray implements JsonArray { private final ClientLogger logger = new ClientLogger(GsonJsonArray.class); private final com.google.gson.JsonArray jsonArray; /** * Constructs a {@link JsonArray} backed by an empty GSON {@link com.google.gson.JsonArray}. */ public GsonJsonArray() { this.jsonArray = new com.go...
Should we use our "utils" for that?
public Mono<Response<BlockBlobItem>> uploadWithResponse(BlobParallelUploadOptions options) { try { Objects.requireNonNull(options); final Map<String, String> metadataFinal = options.getMetadata() == null ? new HashMap<>() : options.getMetadata(); options.setMetadata(metadataFinal); Flux<ByteBuffer> data = options.getDa...
Objects.requireNonNull(options);
new BlobParallelUploadOptions(df) .setParallelTransferOptions(options.getParallelTransferOptions()).setHeaders(options.getHeaders()) .setMetadata(metadataFinal).setTags(options.getTags()).setTier(options.getTier()) .setRequestConditions(options.getRequestConditions()))); } catch (RuntimeException ex) { return monoError...
class EncryptedBlobAsyncClient extends BlobAsyncClient { static final int BLOB_DEFAULT_UPLOAD_BLOCK_SIZE = 4 * Constants.MB; private static final long BLOB_MAX_UPLOAD_BLOCK_SIZE = 4000L * Constants.MB; private final ClientLogger logger = new ClientLogger(EncryptedBlobAsyncClient.class); /** * An object of type {@link A...
class EncryptedBlobAsyncClient extends BlobAsyncClient { static final int BLOB_DEFAULT_UPLOAD_BLOCK_SIZE = 4 * Constants.MB; private static final long BLOB_MAX_UPLOAD_BLOCK_SIZE = 4000L * Constants.MB; private final ClientLogger logger = new ClientLogger(EncryptedBlobAsyncClient.class); /** * An object of type {@link A...
Thanks for getting this. I thought the information was getting rather verbose.
public void subscribe(CoreSubscriber<? super T> actual) { if (isDisposed()) { if (lastError != null) { actual.onSubscribe(Operators.emptySubscription()); actual.onError(lastError); } else { Operators.error(actual, logger.logExceptionAsError(new IllegalStateException( String.format("namespace[%s] entityPath[%s]: Cannot ...
logger.verbose("Added a subscriber {} to AMQP channel processor. Total "
public void subscribe(CoreSubscriber<? super T> actual) { if (isDisposed()) { if (lastError != null) { actual.onSubscribe(Operators.emptySubscription()); actual.onError(lastError); } else { Operators.error(actual, logger.logExceptionAsError(new IllegalStateException( String.format("namespace[%s] entityPath[%s]: Cannot ...
class AmqpChannelProcessor<T> extends Mono<T> implements Processor<T, T>, CoreSubscriber<T>, Disposable { @SuppressWarnings("rawtypes") private static final AtomicReferenceFieldUpdater<AmqpChannelProcessor, Subscription> UPSTREAM = AtomicReferenceFieldUpdater.newUpdater(AmqpChannelProcessor.class, Subscription.class, "...
class AmqpChannelProcessor<T> extends Mono<T> implements Processor<T, T>, CoreSubscriber<T>, Disposable { @SuppressWarnings("rawtypes") private static final AtomicReferenceFieldUpdater<AmqpChannelProcessor, Subscription> UPSTREAM = AtomicReferenceFieldUpdater.newUpdater(AmqpChannelProcessor.class, Subscription.class, "...
We should change this. Since this is in examples module, we should not use `*BridgeInternal` classes here. Also please check if you have not un-intentionally made this change in other public surface area (examples sub-module)
private DocumentCollection getMultiPartitionCollectionDefinition() { DocumentCollection collectionDefinition = new DocumentCollection(); collectionDefinition.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); List<String> paths = new ArrayList<>(); paths.a...
ModelBridgeInternal.setIncludedPathIndexes(includedPath, indexes);
private DocumentCollection getMultiPartitionCollectionDefinition() { DocumentCollection collectionDefinition = new DocumentCollection(); collectionDefinition.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); List<String> paths = new ArrayList<>(); paths.a...
class CollectionCRUDAsyncAPITest extends DocumentClientTest { private final static int TIMEOUT = 120000; private Database createdDatabase; private AsyncDocumentClient client; private DocumentCollection collectionDefinition; @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void before_CollectionCRUDAsyncAPITes...
class CollectionCRUDAsyncAPITest extends DocumentClientTest { private final static int TIMEOUT = 120000; private Database createdDatabase; private AsyncDocumentClient client; private DocumentCollection collectionDefinition; @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void before_CollectionCRUDAsyncAPITes...
hmm, I need to change it because I hide the setIndexes method of IncludedPath, should I keep it public? Checked the .net SDK, the setter and getter are both internal. So I changed the setIndexes method to package private
private DocumentCollection getMultiPartitionCollectionDefinition() { DocumentCollection collectionDefinition = new DocumentCollection(); collectionDefinition.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); List<String> paths = new ArrayList<>(); paths.a...
ModelBridgeInternal.setIncludedPathIndexes(includedPath, indexes);
private DocumentCollection getMultiPartitionCollectionDefinition() { DocumentCollection collectionDefinition = new DocumentCollection(); collectionDefinition.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); List<String> paths = new ArrayList<>(); paths.a...
class CollectionCRUDAsyncAPITest extends DocumentClientTest { private final static int TIMEOUT = 120000; private Database createdDatabase; private AsyncDocumentClient client; private DocumentCollection collectionDefinition; @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void before_CollectionCRUDAsyncAPITes...
class CollectionCRUDAsyncAPITest extends DocumentClientTest { private final static int TIMEOUT = 120000; private Database createdDatabase; private AsyncDocumentClient client; private DocumentCollection collectionDefinition; @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void before_CollectionCRUDAsyncAPITes...
chatted offline, make sense that do not call this new method here, since it is not accessible publicly. Will remove.
private DocumentCollection getMultiPartitionCollectionDefinition() { DocumentCollection collectionDefinition = new DocumentCollection(); collectionDefinition.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); List<String> paths = new ArrayList<>(); paths.a...
ModelBridgeInternal.setIncludedPathIndexes(includedPath, indexes);
private DocumentCollection getMultiPartitionCollectionDefinition() { DocumentCollection collectionDefinition = new DocumentCollection(); collectionDefinition.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); List<String> paths = new ArrayList<>(); paths.a...
class CollectionCRUDAsyncAPITest extends DocumentClientTest { private final static int TIMEOUT = 120000; private Database createdDatabase; private AsyncDocumentClient client; private DocumentCollection collectionDefinition; @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void before_CollectionCRUDAsyncAPITes...
class CollectionCRUDAsyncAPITest extends DocumentClientTest { private final static int TIMEOUT = 120000; private Database createdDatabase; private AsyncDocumentClient client; private DocumentCollection collectionDefinition; @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void before_CollectionCRUDAsyncAPITes...
Removed from all tests.
private DocumentCollection getMultiPartitionCollectionDefinition() { DocumentCollection collectionDefinition = new DocumentCollection(); collectionDefinition.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); List<String> paths = new ArrayList<>(); paths.a...
ModelBridgeInternal.setIncludedPathIndexes(includedPath, indexes);
private DocumentCollection getMultiPartitionCollectionDefinition() { DocumentCollection collectionDefinition = new DocumentCollection(); collectionDefinition.setId(UUID.randomUUID().toString()); PartitionKeyDefinition partitionKeyDefinition = new PartitionKeyDefinition(); List<String> paths = new ArrayList<>(); paths.a...
class CollectionCRUDAsyncAPITest extends DocumentClientTest { private final static int TIMEOUT = 120000; private Database createdDatabase; private AsyncDocumentClient client; private DocumentCollection collectionDefinition; @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void before_CollectionCRUDAsyncAPITes...
class CollectionCRUDAsyncAPITest extends DocumentClientTest { private final static int TIMEOUT = 120000; private Database createdDatabase; private AsyncDocumentClient client; private DocumentCollection collectionDefinition; @BeforeClass(groups = "samples", timeOut = TIMEOUT) public void before_CollectionCRUDAsyncAPITes...
should I throw exception here?
public GatewayConnectionConfig setProxy(ProxyOptions proxy) { if (proxy.getType() != ProxyOptions.Type.HTTP) { throw new IllegalArgumentException("Proxy type is not supported " + proxy.getType()); } this.proxy = proxy; return this; }
if (proxy.getType() != ProxyOptions.Type.HTTP) {
public GatewayConnectionConfig setProxy(ProxyOptions proxy) { if (proxy.getType() != ProxyOptions.Type.HTTP) { throw new IllegalArgumentException("Only http proxy type is supported."); } this.proxy = proxy; return this; }
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
should I also add the proxy type?
public String toString() { return "GatewayConnectionConfig{" + "requestTimeout=" + requestTimeout + ", maxConnectionPoolSize=" + maxConnectionPoolSize + ", idleConnectionTimeout=" + idleConnectionTimeout + ", proxyType=" + proxy.getType() + ", inetSocketProxyAddress=" + proxy.getAddress() + '}'; }
", proxyType=" + proxy.getType() +
public String toString() { String proxyType = proxy != null ? proxy.getType().toString() : null; String proxyAddress = proxy != null ? proxy.getAddress().toString() : null; return "GatewayConnectionConfig{" + "requestTimeout=" + requestTimeout + ", maxConnectionPoolSize=" + maxConnectionPoolSize + ", idleConnectionTime...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
Yes, throw `IllegalArgumentException` - with message - only Http Proxy type is supported.
public GatewayConnectionConfig setProxy(ProxyOptions proxy) { if (proxy.getType() != ProxyOptions.Type.HTTP) { throw new IllegalArgumentException("Proxy type is not supported " + proxy.getType()); } this.proxy = proxy; return this; }
if (proxy.getType() != ProxyOptions.Type.HTTP) {
public GatewayConnectionConfig setProxy(ProxyOptions proxy) { if (proxy.getType() != ProxyOptions.Type.HTTP) { throw new IllegalArgumentException("Only http proxy type is supported."); } this.proxy = proxy; return this; }
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
to the `toString()` - yes.
public String toString() { return "GatewayConnectionConfig{" + "requestTimeout=" + requestTimeout + ", maxConnectionPoolSize=" + maxConnectionPoolSize + ", idleConnectionTimeout=" + idleConnectionTimeout + ", proxyType=" + proxy.getType() + ", inetSocketProxyAddress=" + proxy.getAddress() + '}'; }
", proxyType=" + proxy.getType() +
public String toString() { String proxyType = proxy != null ? proxy.getType().toString() : null; String proxyAddress = proxy != null ? proxy.getAddress().toString() : null; return "GatewayConnectionConfig{" + "requestTimeout=" + requestTimeout + ", maxConnectionPoolSize=" + maxConnectionPoolSize + ", idleConnectionTime...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
Thanks, changed the message to be "Only http proxy type is supported."
public GatewayConnectionConfig setProxy(ProxyOptions proxy) { if (proxy.getType() != ProxyOptions.Type.HTTP) { throw new IllegalArgumentException("Proxy type is not supported " + proxy.getType()); } this.proxy = proxy; return this; }
if (proxy.getType() != ProxyOptions.Type.HTTP) {
public GatewayConnectionConfig setProxy(ProxyOptions proxy) { if (proxy.getType() != ProxyOptions.Type.HTTP) { throw new IllegalArgumentException("Only http proxy type is supported."); } this.proxy = proxy; return this; }
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
just found out that the spotbug checks all the properties should be referenced in the toString(), so need to exclude the proxy check for pattern UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR
public String toString() { return "GatewayConnectionConfig{" + "requestTimeout=" + requestTimeout + ", maxConnectionPoolSize=" + maxConnectionPoolSize + ", idleConnectionTimeout=" + idleConnectionTimeout + ", proxyType=" + proxy.getType() + ", inetSocketProxyAddress=" + proxy.getAddress() + '}'; }
", proxyType=" + proxy.getType() +
public String toString() { String proxyType = proxy != null ? proxy.getType().toString() : null; String proxyAddress = proxy != null ? proxy.getAddress().toString() : null; return "GatewayConnectionConfig{" + "requestTimeout=" + requestTimeout + ", maxConnectionPoolSize=" + maxConnectionPoolSize + ", idleConnectionTime...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
I am wondering why this wasn't a problem with `InetSocketAddress` ? It was also present in `toString()` and was not initialized in Constructor.
public String toString() { return "GatewayConnectionConfig{" + "requestTimeout=" + requestTimeout + ", maxConnectionPoolSize=" + maxConnectionPoolSize + ", idleConnectionTimeout=" + idleConnectionTimeout + ", proxyType=" + proxy.getType() + ", inetSocketProxyAddress=" + proxy.getAddress() + '}'; }
", proxyType=" + proxy.getType() +
public String toString() { String proxyType = proxy != null ? proxy.getType().toString() : null; String proxyAddress = proxy != null ? proxy.getAddress().toString() : null; return "GatewayConnectionConfig{" + "requestTimeout=" + requestTimeout + ", maxConnectionPoolSize=" + maxConnectionPoolSize + ", idleConnectionTime...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
oo, I see, I think the UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR was really checking is that I used proxy.getType, proxy.getAddress, but it might never be inistialized, so may get null pointer exception. Updated to check proxy is null or not.
public String toString() { return "GatewayConnectionConfig{" + "requestTimeout=" + requestTimeout + ", maxConnectionPoolSize=" + maxConnectionPoolSize + ", idleConnectionTimeout=" + idleConnectionTimeout + ", proxyType=" + proxy.getType() + ", inetSocketProxyAddress=" + proxy.getAddress() + '}'; }
", proxyType=" + proxy.getType() +
public String toString() { String proxyType = proxy != null ? proxy.getType().toString() : null; String proxyAddress = proxy != null ? proxy.getAddress().toString() : null; return "GatewayConnectionConfig{" + "requestTimeout=" + requestTimeout + ", maxConnectionPoolSize=" + maxConnectionPoolSize + ", idleConnectionTime...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
Alternatively we can wrap the original `Flux` inside a `Flux.defer` and have ```java final long[] currentTotalLength = new long[1]; ``` inside the defer which is some what more idiomatic I think.
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { final long[] currentTotalLength = new long[1]; return Flux.range(0, (int) Math.ceil((double) length / (double) blockSize)) .map(i -> i * blockSize) .concatMap(pos -> Mono.fromCallable(() -> { long count = pos + bloc...
})
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { data.mark(Integer.MAX_VALUE); return Flux.defer(() -> { /* If the request needs to be retried, the flux will be resubscribed to. The stream and counter must be reset in order to correctly return the same data again....
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
as we don't support password with proxy, shouldn't we throw if password is set?
public GatewayConnectionConfig setProxy(ProxyOptions proxy) { if (proxy.getType() != ProxyOptions.Type.HTTP) { throw new IllegalArgumentException("Only http proxy type is supported."); } this.proxy = proxy; return this; }
throw new IllegalArgumentException("Only http proxy type is supported.");
public GatewayConnectionConfig setProxy(ProxyOptions proxy) { if (proxy.getType() != ProxyOptions.Type.HTTP) { throw new IllegalArgumentException("Only http proxy type is supported."); } this.proxy = proxy; return this; }
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
I am not sure. may be we should, may be we should not, it will just get ignored. But we definitely should add more documentation to setProxy() API that we only support HTTP proxy as of now - without any username and password. I see, `setProxy()` docs are incorrect and should be updated. @xinlian12 - please create...
public GatewayConnectionConfig setProxy(ProxyOptions proxy) { if (proxy.getType() != ProxyOptions.Type.HTTP) { throw new IllegalArgumentException("Only http proxy type is supported."); } this.proxy = proxy; return this; }
throw new IllegalArgumentException("Only http proxy type is supported.");
public GatewayConnectionConfig setProxy(ProxyOptions proxy) { if (proxy.getType() != ProxyOptions.Type.HTTP) { throw new IllegalArgumentException("Only http proxy type is supported."); } this.proxy = proxy; return this; }
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
Thanks~ have created another PR for the docs update: chttps://github.com/Azure/azure-sdk-for-java/pull/11672
public GatewayConnectionConfig setProxy(ProxyOptions proxy) { if (proxy.getType() != ProxyOptions.Type.HTTP) { throw new IllegalArgumentException("Only http proxy type is supported."); } this.proxy = proxy; return this; }
throw new IllegalArgumentException("Only http proxy type is supported.");
public GatewayConnectionConfig setProxy(ProxyOptions proxy) { if (proxy.getType() != ProxyOptions.Type.HTTP) { throw new IllegalArgumentException("Only http proxy type is supported."); } this.proxy = proxy; return this; }
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
class GatewayConnectionConfig { private static final Duration DEFAULT_REQUEST_TIMEOUT = Duration.ofSeconds(60); private static final Duration DEFAULT_IDLE_CONNECTION_TIMEOUT = Duration.ofSeconds(60); private static final int DEFAULT_MAX_POOL_SIZE = 1000; private Duration requestTimeout; private int maxConnectionPoolSiz...
Should this be a `HttpResponseException` or just `AzureException`? `HttpResponseException` is usually an error returned by the HTTP call with a status code not equal to 2xx. From [HttpResponseException JavaDoc](https://azuresdkartifacts.blob.core.windows.net/azure-sdk-for-java/staging/apidocs/com/azure/core/exception/...
private void throwIfModelStatusInvalid(Model customModel) { if (ModelStatus.INVALID.equals(customModel.getModelInfo().getStatus())) { List<ErrorInformation> errorInformationList = customModel.getTrainResult().getErrors(); if (!CoreUtils.isNullOrEmpty(errorInformationList)) { throw logger.logExceptionAsError(new HttpRes...
throw logger.logExceptionAsError(new HttpResponseException(
private void throwIfModelStatusInvalid(Model customModel) { if (ModelStatus.INVALID.equals(customModel.getModelInfo().getStatus())) { List<ErrorInformation> errorInformationList = customModel.getTrainResult().getErrors(); if (!CoreUtils.isNullOrEmpty(errorInformationList)) { throw logger.logExceptionAsError(new HttpRes...
class FormTrainingAsyncClient { private final ClientLogger logger = new ClientLogger(FormTrainingAsyncClient.class); private final FormRecognizerClientImpl service; private final FormRecognizerServiceVersion serviceVersion; /** * Create a {@link FormTrainingClient} that sends requests to the Form Recognizer service's e...
class FormTrainingAsyncClient { private final ClientLogger logger = new ClientLogger(FormTrainingAsyncClient.class); private final FormRecognizerClientImpl service; private final FormRecognizerServiceVersion serviceVersion; /** * Create a {@link FormTrainingClient} that sends requests to the Form Recognizer service's e...
For failures for service requests (3XX, 4XX etc) we have [ErroeResponseException](https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/formrecognizer/azure-ai-formrecognizer/src/main/java/com/azure/ai/formrecognizer/implementation/FormRecognizerClientImpl.java#L143). Using the equivalent for other languages C#-...
private void throwIfModelStatusInvalid(Model customModel) { if (ModelStatus.INVALID.equals(customModel.getModelInfo().getStatus())) { List<ErrorInformation> errorInformationList = customModel.getTrainResult().getErrors(); if (!CoreUtils.isNullOrEmpty(errorInformationList)) { throw logger.logExceptionAsError(new HttpRes...
throw logger.logExceptionAsError(new HttpResponseException(
private void throwIfModelStatusInvalid(Model customModel) { if (ModelStatus.INVALID.equals(customModel.getModelInfo().getStatus())) { List<ErrorInformation> errorInformationList = customModel.getTrainResult().getErrors(); if (!CoreUtils.isNullOrEmpty(errorInformationList)) { throw logger.logExceptionAsError(new HttpRes...
class FormTrainingAsyncClient { private final ClientLogger logger = new ClientLogger(FormTrainingAsyncClient.class); private final FormRecognizerClientImpl service; private final FormRecognizerServiceVersion serviceVersion; /** * Create a {@link FormTrainingClient} that sends requests to the Form Recognizer service's e...
class FormTrainingAsyncClient { private final ClientLogger logger = new ClientLogger(FormTrainingAsyncClient.class); private final FormRecognizerClientImpl service; private final FormRecognizerServiceVersion serviceVersion; /** * Create a {@link FormTrainingClient} that sends requests to the Form Recognizer service's e...
Discussed offline. Maintaining the Javadoc for `HttpResponseException` and TA convention for exception handling, consider adding a new Exception Type or use AzureException. https://github.com/Azure/azure-sdk-for-java/issues/11705
private void throwIfModelStatusInvalid(Model customModel) { if (ModelStatus.INVALID.equals(customModel.getModelInfo().getStatus())) { List<ErrorInformation> errorInformationList = customModel.getTrainResult().getErrors(); if (!CoreUtils.isNullOrEmpty(errorInformationList)) { throw logger.logExceptionAsError(new HttpRes...
throw logger.logExceptionAsError(new HttpResponseException(
private void throwIfModelStatusInvalid(Model customModel) { if (ModelStatus.INVALID.equals(customModel.getModelInfo().getStatus())) { List<ErrorInformation> errorInformationList = customModel.getTrainResult().getErrors(); if (!CoreUtils.isNullOrEmpty(errorInformationList)) { throw logger.logExceptionAsError(new HttpRes...
class FormTrainingAsyncClient { private final ClientLogger logger = new ClientLogger(FormTrainingAsyncClient.class); private final FormRecognizerClientImpl service; private final FormRecognizerServiceVersion serviceVersion; /** * Create a {@link FormTrainingClient} that sends requests to the Form Recognizer service's e...
class FormTrainingAsyncClient { private final ClientLogger logger = new ClientLogger(FormTrainingAsyncClient.class); private final FormRecognizerClientImpl service; private final FormRecognizerServiceVersion serviceVersion; /** * Create a {@link FormTrainingClient} that sends requests to the Form Recognizer service's e...
https://github.com/Azure/azure-sdk-for-java/pull/11720
private void throwIfModelStatusInvalid(Model customModel) { if (ModelStatus.INVALID.equals(customModel.getModelInfo().getStatus())) { List<ErrorInformation> errorInformationList = customModel.getTrainResult().getErrors(); if (!CoreUtils.isNullOrEmpty(errorInformationList)) { throw logger.logExceptionAsError(new HttpRes...
throw logger.logExceptionAsError(new HttpResponseException(
private void throwIfModelStatusInvalid(Model customModel) { if (ModelStatus.INVALID.equals(customModel.getModelInfo().getStatus())) { List<ErrorInformation> errorInformationList = customModel.getTrainResult().getErrors(); if (!CoreUtils.isNullOrEmpty(errorInformationList)) { throw logger.logExceptionAsError(new HttpRes...
class FormTrainingAsyncClient { private final ClientLogger logger = new ClientLogger(FormTrainingAsyncClient.class); private final FormRecognizerClientImpl service; private final FormRecognizerServiceVersion serviceVersion; /** * Create a {@link FormTrainingClient} that sends requests to the Form Recognizer service's e...
class FormTrainingAsyncClient { private final ClientLogger logger = new ClientLogger(FormTrainingAsyncClient.class); private final FormRecognizerClientImpl service; private final FormRecognizerServiceVersion serviceVersion; /** * Create a {@link FormTrainingClient} that sends requests to the Form Recognizer service's e...
ohhh and does ` @since 9` signals that? or should there be a comment with that info?
public static void main(String[] args) throws IOException { FormRecognizerAsyncClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildAsyncClient(); File analyzeFile = new File("../formrecognizer/azure-ai-formrecognizer/src/samples/java/sample-forms/" + "f...
public static void main(String[] args) throws IOException { FormRecognizerAsyncClient client = new FormRecognizerClientBuilder() .credential(new AzureKeyCredential("{key}")) .endpoint("https: .buildAsyncClient(); File analyzeFile = new File("../formrecognizer/azure-ai-formrecognizer/src/samples/java/sample-forms/" + "f...
class AdvancedDiffLabeledUnlabeledDataAsync { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. * * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. */ }
class AdvancedDiffLabeledUnlabeledDataAsync { /** * Main method to invoke this demo. * * @param args Unused arguments to the program. * * @throws IOException Exception thrown when there is an error in reading all the bytes from the File. */ }
It will also match what we do in `RestProxy`. https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RestProxy.java#L146
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { final long[] currentTotalLength = new long[1]; return Flux.range(0, (int) Math.ceil((double) length / (double) blockSize)) .map(i -> i * blockSize) .concatMap(pos -> Mono.fromCallable(() -> { long count = pos + bloc...
})
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { data.mark(Integer.MAX_VALUE); return Flux.defer(() -> { /* If the request needs to be retried, the flux will be resubscribed to. The stream and counter must be reset in order to correctly return the same data again....
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
Not all input streams support `reset()`. Some may throw IOException as specified in [javadoc](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html#reset--). Also, if the input stream does support resetting the position, this will reset to the last marked position that may be different from where the user ...
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { final long[] currentTotalLength = new long[1]; return Flux.range(0, (int) Math.ceil((double) length / (double) blockSize)) .map(i -> i * blockSize) .concatMap(pos -> Mono.fromCallable(() -> { long count = pos + bloc...
data.reset();
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { data.mark(Integer.MAX_VALUE); return Flux.defer(() -> { /* If the request needs to be retried, the flux will be resubscribed to. The stream and counter must be reset in order to correctly return the same data again....
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
Yes. The most common `InputStream` in the upload case, FileInputStream (FIS), does not support `reset`. Users might have to wrap FIS in `BufferedInputStream` (BIS) and give it as input to upload API. But BIS comes with extra allocation cost as worse as the size of the file. Few options I could think of are: 1. If we...
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { final long[] currentTotalLength = new long[1]; return Flux.range(0, (int) Math.ceil((double) length / (double) blockSize)) .map(i -> i * blockSize) .concatMap(pos -> Mono.fromCallable(() -> { long count = pos + bloc...
data.reset();
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { data.mark(Integer.MAX_VALUE); return Flux.defer(() -> { /* If the request needs to be retried, the flux will be resubscribed to. The stream and counter must be reset in order to correctly return the same data again....
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
Good call. I was just working with what was already there, but I can clean that up.
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { final long[] currentTotalLength = new long[1]; return Flux.range(0, (int) Math.ceil((double) length / (double) blockSize)) .map(i -> i * blockSize) .concatMap(pos -> Mono.fromCallable(() -> { long count = pos + bloc...
})
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { data.mark(Integer.MAX_VALUE); return Flux.defer(() -> { /* If the request needs to be retried, the flux will be resubscribed to. The stream and counter must be reset in order to correctly return the same data again....
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
Yes, I have added docs to all the apis which call this method indicating that the stream must be markable and giving guidance if it is not. I suggested opening a BlobOutputStream in those cases. I can also add a suggestion to consider wrapping it in a BufferedStream. I didn't add those javadocs to this method because i...
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { final long[] currentTotalLength = new long[1]; return Flux.range(0, (int) Math.ceil((double) length / (double) blockSize)) .map(i -> i * blockSize) .concatMap(pos -> Mono.fromCallable(() -> { long count = pos + bloc...
data.reset();
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { data.mark(Integer.MAX_VALUE); return Flux.defer(() -> { /* If the request needs to be retried, the flux will be resubscribed to. The stream and counter must be reset in order to correctly return the same data again....
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
Don't the async operations support non-replayable publishers? This [javadoc](https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/BlobAsyncClient.java#L242) says that the flux doesn't have to be replayable.
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { final long[] currentTotalLength = new long[1]; return Flux.range(0, (int) Math.ceil((double) length / (double) blockSize)) .map(i -> i * blockSize) .concatMap(pos -> Mono.fromCallable(() -> { long count = pos + bloc...
data.reset();
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { data.mark(Integer.MAX_VALUE); return Flux.defer(() -> { /* If the request needs to be retried, the flux will be resubscribed to. The stream and counter must be reset in order to correctly return the same data again....
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
Those are on the BlobClient, which does support non-replayable publishers for both async and sync. The analogues I'm referring to are on BlockBlobAsyncClient. e.g. [stage block](https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/specialized/BlockB...
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { final long[] currentTotalLength = new long[1]; return Flux.range(0, (int) Math.ceil((double) length / (double) blockSize)) .map(i -> i * blockSize) .concatMap(pos -> Mono.fromCallable(() -> { long count = pos + bloc...
data.reset();
public static Flux<ByteBuffer> convertStreamToByteBuffer(InputStream data, long length, int blockSize) { data.mark(Integer.MAX_VALUE); return Flux.defer(() -> { /* If the request needs to be retried, the flux will be resubscribed to. The stream and counter must be reset in order to correctly return the same data again....
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
class Utility { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); private static final String UTF8_CHARSET = "UTF-8"; private static final String INVALID_DATE_STRING = "Invalid Date String: %s."; public static final String STORAGE_TRACING_NAMESPACE_VALUE = "Microsoft.Storage"; /** * Stores a r...
`areOriginalTokensReplaced`?
public static PhoneticTokenFilter map(com.azure.search.documents.indexes.implementation.models.PhoneticTokenFilter obj) { if (obj == null) { return null; } PhoneticTokenFilter phoneticTokenFilter = new PhoneticTokenFilter(); String name = obj.getName(); phoneticTokenFilter.setName(name); Boolean replaceOriginalTokens =...
Boolean replaceOriginalTokens = obj.isOriginalTokensReplaced();
public static PhoneticTokenFilter map(com.azure.search.documents.indexes.implementation.models.PhoneticTokenFilter obj) { if (obj == null) { return null; } PhoneticTokenFilter phoneticTokenFilter = new PhoneticTokenFilter(); String name = obj.getName(); phoneticTokenFilter.setName(name); Boolean replaceOriginalTokens =...
class PhoneticTokenFilterConverter { /** * Maps from {@link com.azure.search.documents.indexes.implementation.models.PhoneticTokenFilter} to * {@link PhoneticTokenFilter}. */ /** * Maps from {@link PhoneticTokenFilter} to * {@link com.azure.search.documents.indexes.implementation.models.PhoneticTokenFilter}. */ public ...
class PhoneticTokenFilterConverter { /** * Maps from {@link com.azure.search.documents.indexes.implementation.models.PhoneticTokenFilter} to * {@link PhoneticTokenFilter}. */ /** * Maps from {@link PhoneticTokenFilter} to * {@link com.azure.search.documents.indexes.implementation.models.PhoneticTokenFilter}. */ public ...
This should be done once in the constructor instead of doing it every time `getMessage()` is called.
public String getMessage() { final String baseMessage = super.getMessage(); StringBuilder errorInformationMessage = new StringBuilder().append(baseMessage); if (errorInformationList.size() > 0) { for (ErrorInformation errorInformation : errorInformationList) { errorInformationMessage.append(", " + "errorCode" + ": [" +...
return errorInformationMessage.toString();
public String getMessage() { return this.errorInformationMessage; }
class FormRecognizerException extends AzureException { private final List<ErrorInformation> errorInformationList; /** * Initializes a new instance of {@link FormRecognizerException} class * * @param message Text containing the details of the exception. * @param errorInformationList The List of error information that ca...
class FormRecognizerException extends AzureException { private final List<ErrorInformation> errorInformationList; private final String errorInformationMessage; /** * Initializes a new instance of {@link FormRecognizerException} class * * @param message Text containing the details of the exception. * @param errorInforma...
I thought we need to throw error in this case, as CFP will not work in consistency below `SESSION`, no ?
public ChangeFeedProcessorBuilderImpl leaseContainer(CosmosAsyncContainer leaseClient) { if (leaseClient == null) { throw new IllegalArgumentException("leaseClient"); } if (!getContextClient(leaseClient).isContentResponseOnWriteEnabled()) { throw new IllegalArgumentException("leaseClient: content response on write sett...
logger.warn("leaseClient consistency level setting are less then expected which is SESSION");
public ChangeFeedProcessorBuilderImpl leaseContainer(CosmosAsyncContainer leaseClient) { if (leaseClient == null) { throw new IllegalArgumentException("leaseClient"); } if (!getContextClient(leaseClient).isContentResponseOnWriteEnabled()) { throw new IllegalArgumentException("leaseClient: content response on write sett...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor.BuilderDefinition, ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private fin...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor.BuilderDefinition, ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private fin...
I think we should fail on these cases, logs may go unnoticed by user
public ChangeFeedProcessorBuilderImpl leaseContainer(CosmosAsyncContainer leaseClient) { if (leaseClient == null) { throw new IllegalArgumentException("leaseClient"); } if (!getContextClient(leaseClient).isContentResponseOnWriteEnabled()) { throw new IllegalArgumentException("leaseClient: content response on write sett...
logger.warn("leaseClient consistency level setting are less then expected which is SESSION");
public ChangeFeedProcessorBuilderImpl leaseContainer(CosmosAsyncContainer leaseClient) { if (leaseClient == null) { throw new IllegalArgumentException("leaseClient"); } if (!getContextClient(leaseClient).isContentResponseOnWriteEnabled()) { throw new IllegalArgumentException("leaseClient: content response on write sett...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor.BuilderDefinition, ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private fin...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor.BuilderDefinition, ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private fin...
this is called `setContainerName` but in the test `.setContainerName("AQAAAJ0fgTc=")` uses portion of the selflink. So is this the container name or just a portion of the selflink?
public void createPermission() throws Exception { createdUser = safeCreateUser(client, createdDatabase.getId(), getUserDefinition()); CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() .setId(UUID.randomUUID().toString()) .setPermissionMode(PermissionMode.READ) .setContainerName("AQAAAJ0fg...
.setContainerName("AQAAAJ0fgTc=")
public void createPermission() throws Exception { createdUser = safeCreateUser(client, createdDatabase.getId(), getUserDefinition()); CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() .setId(UUID.randomUUID().toString()) .setPermissionMode(PermissionMode.READ) .setContainerName("myContain...
class PermissionCrudTest extends TestSuiteBase { private CosmosAsyncDatabase createdDatabase; private CosmosAsyncUser createdUser; private final String databaseId = CosmosDatabaseForTest.generateId(); private CosmosAsyncClient client; @Factory(dataProvider = "clientBuilders") public PermissionCrudTest(CosmosClientBuild...
class PermissionCrudTest extends TestSuiteBase { private CosmosAsyncDatabase createdDatabase; private CosmosAsyncUser createdUser; private final String databaseId = CosmosDatabaseForTest.generateId(); private CosmosAsyncClient client; @Factory(dataProvider = "clientBuilders") public PermissionCrudTest(CosmosClientBuild...
this is called withPermissionContainerName but in the test `. withPermissionContainerName("AQAAAJ0fgTc=")` uses portion of the selflink. So is this the container name or just a portion of the selflink? ditto
public void readPermission() throws Exception { createdUser = safeCreateUser(client, createdDatabase.getId(), getUserDefinition()); CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() .setId(UUID.randomUUID().toString()) .setPermissionMode(PermissionMode.READ) .setContainerName("AQAAAJ0fgTc...
.withPermissionContainerName("AQAAAJ0fgTc=")
public void readPermission() throws Exception { createdUser = safeCreateUser(client, createdDatabase.getId(), getUserDefinition()); CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() .setId(UUID.randomUUID().toString()) .setPermissionMode(PermissionMode.READ) .setContainerName("myContainer...
class PermissionCrudTest extends TestSuiteBase { private CosmosAsyncDatabase createdDatabase; private CosmosAsyncUser createdUser; private final String databaseId = CosmosDatabaseForTest.generateId(); private CosmosAsyncClient client; @Factory(dataProvider = "clientBuilders") public PermissionCrudTest(CosmosClientBuild...
class PermissionCrudTest extends TestSuiteBase { private CosmosAsyncDatabase createdDatabase; private CosmosAsyncUser createdUser; private final String databaseId = CosmosDatabaseForTest.generateId(); private CosmosAsyncClient client; @Factory(dataProvider = "clientBuilders") public PermissionCrudTest(CosmosClientBuild...
it's the container name... I will make a change to make it more obvious; initially I did not want to mess with the test used/expected values.
public void createPermission() throws Exception { createdUser = safeCreateUser(client, createdDatabase.getId(), getUserDefinition()); CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() .setId(UUID.randomUUID().toString()) .setPermissionMode(PermissionMode.READ) .setContainerName("AQAAAJ0fg...
.setContainerName("AQAAAJ0fgTc=")
public void createPermission() throws Exception { createdUser = safeCreateUser(client, createdDatabase.getId(), getUserDefinition()); CosmosPermissionProperties permissionSettings = new CosmosPermissionProperties() .setId(UUID.randomUUID().toString()) .setPermissionMode(PermissionMode.READ) .setContainerName("myContain...
class PermissionCrudTest extends TestSuiteBase { private CosmosAsyncDatabase createdDatabase; private CosmosAsyncUser createdUser; private final String databaseId = CosmosDatabaseForTest.generateId(); private CosmosAsyncClient client; @Factory(dataProvider = "clientBuilders") public PermissionCrudTest(CosmosClientBuild...
class PermissionCrudTest extends TestSuiteBase { private CosmosAsyncDatabase createdDatabase; private CosmosAsyncUser createdUser; private final String databaseId = CosmosDatabaseForTest.generateId(); private CosmosAsyncClient client; @Factory(dataProvider = "clientBuilders") public PermissionCrudTest(CosmosClientBuild...
The CFP should continue to work with lesser than SESSION consistency level; the downside of it is that lease documents might not be updated in a timely fashion by the current CFP instance in certain conditions which at worst can lead to documents being seen more than once. SESSION or better will help avoid that because...
public ChangeFeedProcessorBuilderImpl leaseContainer(CosmosAsyncContainer leaseClient) { if (leaseClient == null) { throw new IllegalArgumentException("leaseClient"); } if (!getContextClient(leaseClient).isContentResponseOnWriteEnabled()) { throw new IllegalArgumentException("leaseClient: content response on write sett...
logger.warn("leaseClient consistency level setting are less then expected which is SESSION");
public ChangeFeedProcessorBuilderImpl leaseContainer(CosmosAsyncContainer leaseClient) { if (leaseClient == null) { throw new IllegalArgumentException("leaseClient"); } if (!getContextClient(leaseClient).isContentResponseOnWriteEnabled()) { throw new IllegalArgumentException("leaseClient: content response on write sett...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor.BuilderDefinition, ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private fin...
class ChangeFeedProcessorBuilderImpl implements ChangeFeedProcessor.BuilderDefinition, ChangeFeedProcessor, AutoCloseable { private final Logger logger = LoggerFactory.getLogger(ChangeFeedProcessorBuilderImpl.class); private static final long DefaultUnhealthinessDuration = Duration.ofMinutes(15).toMillis(); private fin...
Could we make this String value a constant, I believe making the implementation constant public would work. Same comment for other places where we are doing this.
public EdgeNGramTokenFilter() { odataType = " }
odataType = "
public EdgeNGramTokenFilter() { odataType = V2_ODATA_TYPE; }
class EdgeNGramTokenFilter extends TokenFilter { @JsonProperty(value = "@odata.type") private String odataType; /* * The minimum n-gram length. Default is 1. Must be less than the value of * maxGram. */ @JsonProperty(value = "minGram") private Integer minGram; /* * The maximum n-gram length. Default is 2. */ @JsonPrope...
class EdgeNGramTokenFilter extends TokenFilter { private static final String V2_ODATA_TYPE = " @JsonProperty(value = "@odata.type") private String odataType; /* * The minimum n-gram length. Default is 1. Must be less than the value of * maxGram. */ @JsonProperty(value = "minGram") private Integer minGram; /* * The maxi...
How large can this `Integer` be? According to the service team, we'll eventually start supporting 64-bits integers here (not a concern for Preview 3, I think).
public FieldValue setFormFieldInteger(final Integer formFieldInteger) { this.formFieldInteger = formFieldInteger; return this; }
}
public FieldValue setFormFieldInteger(final Integer formFieldInteger) { this.formFieldInteger = formFieldInteger; return this; }
class FieldValue { private final FieldValueType type; private Map<String, FormField> formFieldMap; private List<FormField> formFieldList; private Float formFieldFloat; private Integer formFieldInteger; private LocalDate formFieldDate; private LocalTime formFieldTime; private String formFieldString; private String formF...
class FieldValue { private final FieldValueType type; private Map<String, FormField> formFieldMap; private List<FormField> formFieldList; private Float formFieldFloat; private Integer formFieldInteger; private LocalDate formFieldDate; private LocalTime formFieldTime; private String formFieldString; private String formF...
I think that should change the generated code for the service to start sending in a `Long` value so will defer doing this with the service update.
public FieldValue setFormFieldInteger(final Integer formFieldInteger) { this.formFieldInteger = formFieldInteger; return this; }
}
public FieldValue setFormFieldInteger(final Integer formFieldInteger) { this.formFieldInteger = formFieldInteger; return this; }
class FieldValue { private final FieldValueType type; private Map<String, FormField> formFieldMap; private List<FormField> formFieldList; private Float formFieldFloat; private Integer formFieldInteger; private LocalDate formFieldDate; private LocalTime formFieldTime; private String formFieldString; private String formF...
class FieldValue { private final FieldValueType type; private Map<String, FormField> formFieldMap; private List<FormField> formFieldList; private Float formFieldFloat; private Integer formFieldInteger; private LocalDate formFieldDate; private LocalTime formFieldTime; private String formFieldString; private String formF...
If the first thread that runs `supplier.get()` throws an error, then all subsequent `getValue()` calls will return an error. Instead, if the first attempt failed, should the next call to `getValue()` again attempt to get from the supplier?
public Mono<T> getValue() { if (cache != null) { return Mono.just(cache); } return Mono.defer(() -> { if (!wip.getAndSet(true)) { try { cache = supplier.get(); sink.next(cache); } catch (Exception e) { sink.error(e); } finally { wip.set(false); } } return emitterProcessor.next(); }); }
sink.error(e);
public Mono<T> getValue() { return Mono.defer(() -> { if (cache != null) { return Mono.just(cache); } if (!wip.getAndSet(true)) { try { cache = supplier.get(); sink.next(cache); } catch (Exception e) { sink.error(e); } } return replayProcessor.next(); }); }
class SynchronizedAccessor<T> { private final AtomicBoolean wip; private T cache; private final ReplayProcessor<T> emitterProcessor = ReplayProcessor.create(1); private final FluxSink<T> sink = emitterProcessor.sink(FluxSink.OverflowStrategy.BUFFER); private final Supplier<T> supplier; public SynchronizedAccessor(Suppl...
class SynchronizedAccessor<T> { private final AtomicBoolean wip; private volatile T cache; private final ReplayProcessor<T> replayProcessor = ReplayProcessor.create(1); private final FluxSink<T> sink = replayProcessor.sink(FluxSink.OverflowStrategy.BUFFER); private final Supplier<T> supplier; public SynchronizedAccesso...
Yes. In this test, Retry-After is 1sec, default interval is 100ms.
public void lroRetryAfter() { ServerConfigure configure = new ServerConfigure(); Duration expectedPollingDuration = Duration.ofSeconds(3); configure.pollingCountTillSuccess = 3; configure.additionalHeaders = new HttpHeaders(new HttpHeader("Retry-After", "1")); WireMockServer lroServer = startServer(configure); lroServe...
Assertions.assertTrue(pollingDuration.compareTo(expectedPollingDuration) > 0);
public void lroRetryAfter() { ServerConfigure configure = new ServerConfigure(); Duration expectedPollingDuration = Duration.ofSeconds(3); configure.pollingCountTillSuccess = 3; configure.additionalHeaders = new HttpHeaders(new HttpHeader("Retry-After", "1")); WireMockServer lroServer = startServer(configure); lroServe...
class LROPollerTests { private static final SerializerAdapter SERIALIZER = new AzureJacksonAdapter(); private static final Duration POLLING_DURATION = Duration.ofMillis(100); @BeforeEach public void beforeTest() { MockitoAnnotations.initMocks(this); } @AfterEach public void afterTest() { Mockito.framework().clearInline...
class LROPollerTests { private static final SerializerAdapter SERIALIZER = new AzureJacksonAdapter(); private static final Duration POLLING_DURATION = Duration.ofMillis(100); @BeforeEach public void beforeTest() { MockitoAnnotations.initMocks(this); } @AfterEach public void afterTest() { Mockito.framework().clearInline...
There's still a chance of race condition here when a thread marks `wip` as false and then another thread enters the `if` block and calls `supplier.get()` again updating the reference to `cache`. How critical is the need to call the supplier only once?
public Mono<T> getValue() { if (cache != null) { return Mono.just(cache); } return Mono.defer(() -> { if (!wip.getAndSet(true)) { try { cache = supplier.get(); sink.next(cache); } catch (Exception e) { sink.error(e); } finally { wip.set(false); } } return emitterProcessor.next(); }); }
wip.set(false);
public Mono<T> getValue() { return Mono.defer(() -> { if (cache != null) { return Mono.just(cache); } if (!wip.getAndSet(true)) { try { cache = supplier.get(); sink.next(cache); } catch (Exception e) { sink.error(e); } } return replayProcessor.next(); }); }
class SynchronizedAccessor<T> { private final AtomicBoolean wip; private T cache; private final ReplayProcessor<T> emitterProcessor = ReplayProcessor.create(1); private final FluxSink<T> sink = emitterProcessor.sink(FluxSink.OverflowStrategy.BUFFER); private final Supplier<T> supplier; public SynchronizedAccessor(Suppl...
class SynchronizedAccessor<T> { private final AtomicBoolean wip; private volatile T cache; private final ReplayProcessor<T> replayProcessor = ReplayProcessor.create(1); private final FluxSink<T> sink = replayProcessor.sink(FluxSink.OverflowStrategy.BUFFER); private final Supplier<T> supplier; public SynchronizedAccesso...
This should also be inside `defer()`. The check should happen when there is a `subscriber`.
public Mono<T> getValue() { if (cache != null) { return Mono.just(cache); } return Mono.defer(() -> { if (!wip.getAndSet(true)) { try { cache = supplier.get(); sink.next(cache); } catch (Exception e) { sink.error(e); } finally { wip.set(false); } } return emitterProcessor.next(); }); }
}
public Mono<T> getValue() { return Mono.defer(() -> { if (cache != null) { return Mono.just(cache); } if (!wip.getAndSet(true)) { try { cache = supplier.get(); sink.next(cache); } catch (Exception e) { sink.error(e); } } return replayProcessor.next(); }); }
class SynchronizedAccessor<T> { private final AtomicBoolean wip; private T cache; private final ReplayProcessor<T> emitterProcessor = ReplayProcessor.create(1); private final FluxSink<T> sink = emitterProcessor.sink(FluxSink.OverflowStrategy.BUFFER); private final Supplier<T> supplier; public SynchronizedAccessor(Suppl...
class SynchronizedAccessor<T> { private final AtomicBoolean wip; private volatile T cache; private final ReplayProcessor<T> replayProcessor = ReplayProcessor.create(1); private final FluxSink<T> sink = replayProcessor.sink(FluxSink.OverflowStrategy.BUFFER); private final Supplier<T> supplier; public SynchronizedAccesso...
as discussed. The supplier will use the same user config locked in at construction time, so a new instance of Identity client will need to be created to fix the issue with the passed in user configuration.
public Mono<T> getValue() { if (cache != null) { return Mono.just(cache); } return Mono.defer(() -> { if (!wip.getAndSet(true)) { try { cache = supplier.get(); sink.next(cache); } catch (Exception e) { sink.error(e); } finally { wip.set(false); } } return emitterProcessor.next(); }); }
sink.error(e);
public Mono<T> getValue() { return Mono.defer(() -> { if (cache != null) { return Mono.just(cache); } if (!wip.getAndSet(true)) { try { cache = supplier.get(); sink.next(cache); } catch (Exception e) { sink.error(e); } } return replayProcessor.next(); }); }
class SynchronizedAccessor<T> { private final AtomicBoolean wip; private T cache; private final ReplayProcessor<T> emitterProcessor = ReplayProcessor.create(1); private final FluxSink<T> sink = emitterProcessor.sink(FluxSink.OverflowStrategy.BUFFER); private final Supplier<T> supplier; public SynchronizedAccessor(Suppl...
class SynchronizedAccessor<T> { private final AtomicBoolean wip; private volatile T cache; private final ReplayProcessor<T> replayProcessor = ReplayProcessor.create(1); private final FluxSink<T> sink = replayProcessor.sink(FluxSink.OverflowStrategy.BUFFER); private final Supplier<T> supplier; public SynchronizedAccesso...
moved it to the defer block.
public Mono<T> getValue() { if (cache != null) { return Mono.just(cache); } return Mono.defer(() -> { if (!wip.getAndSet(true)) { try { cache = supplier.get(); sink.next(cache); } catch (Exception e) { sink.error(e); } finally { wip.set(false); } } return emitterProcessor.next(); }); }
wip.set(false);
public Mono<T> getValue() { return Mono.defer(() -> { if (cache != null) { return Mono.just(cache); } if (!wip.getAndSet(true)) { try { cache = supplier.get(); sink.next(cache); } catch (Exception e) { sink.error(e); } } return replayProcessor.next(); }); }
class SynchronizedAccessor<T> { private final AtomicBoolean wip; private T cache; private final ReplayProcessor<T> emitterProcessor = ReplayProcessor.create(1); private final FluxSink<T> sink = emitterProcessor.sink(FluxSink.OverflowStrategy.BUFFER); private final Supplier<T> supplier; public SynchronizedAccessor(Suppl...
class SynchronizedAccessor<T> { private final AtomicBoolean wip; private volatile T cache; private final ReplayProcessor<T> replayProcessor = ReplayProcessor.create(1); private final FluxSink<T> sink = replayProcessor.sink(FluxSink.OverflowStrategy.BUFFER); private final Supplier<T> supplier; public SynchronizedAccesso...
If the expectation is to create a new `IdentityClient` in case of errors, there's no need to reset `wip` to false. Only one thread ever has to enter the `wip` block and should either get `value` from supplier or throw an error. There's no need for another thread to re-enter this block.
public Mono<T> getValue() { if (cache != null) { return Mono.just(cache); } return Mono.defer(() -> { if (!wip.getAndSet(true)) { try { cache = supplier.get(); sink.next(cache); } catch (Exception e) { sink.error(e); } finally { wip.set(false); } } return emitterProcessor.next(); }); }
wip.set(false);
public Mono<T> getValue() { return Mono.defer(() -> { if (cache != null) { return Mono.just(cache); } if (!wip.getAndSet(true)) { try { cache = supplier.get(); sink.next(cache); } catch (Exception e) { sink.error(e); } } return replayProcessor.next(); }); }
class SynchronizedAccessor<T> { private final AtomicBoolean wip; private T cache; private final ReplayProcessor<T> emitterProcessor = ReplayProcessor.create(1); private final FluxSink<T> sink = emitterProcessor.sink(FluxSink.OverflowStrategy.BUFFER); private final Supplier<T> supplier; public SynchronizedAccessor(Suppl...
class SynchronizedAccessor<T> { private final AtomicBoolean wip; private volatile T cache; private final ReplayProcessor<T> replayProcessor = ReplayProcessor.create(1); private final FluxSink<T> sink = replayProcessor.sink(FluxSink.OverflowStrategy.BUFFER); private final Supplier<T> supplier; public SynchronizedAccesso...
In test case, set `Retry-After` header to different value of default poll interval.
public void lroRetryAfter() { ServerConfigure configure = new ServerConfigure(); Duration expectedPollingDuration = Duration.ofSeconds(3); configure.pollingCountTillSuccess = 3; configure.additionalHeaders = new HttpHeaders(new HttpHeader("Retry-After", "1")); WireMockServer lroServer = startServer(configure); lroServe...
configure.additionalHeaders = new HttpHeaders(new HttpHeader("Retry-After", "1"));
public void lroRetryAfter() { ServerConfigure configure = new ServerConfigure(); Duration expectedPollingDuration = Duration.ofSeconds(3); configure.pollingCountTillSuccess = 3; configure.additionalHeaders = new HttpHeaders(new HttpHeader("Retry-After", "1")); WireMockServer lroServer = startServer(configure); lroServe...
class LROPollerTests { private static final SerializerAdapter SERIALIZER = new AzureJacksonAdapter(); private static final Duration POLLING_DURATION = Duration.ofMillis(100); @BeforeEach public void beforeTest() { MockitoAnnotations.initMocks(this); } @AfterEach public void afterTest() { Mockito.framework().clearInline...
class LROPollerTests { private static final SerializerAdapter SERIALIZER = new AzureJacksonAdapter(); private static final Duration POLLING_DURATION = Duration.ofMillis(100); @BeforeEach public void beforeTest() { MockitoAnnotations.initMocks(this); } @AfterEach public void afterTest() { Mockito.framework().clearInline...
If we just check polling duration larger than expected. I think we could make `Retry-After` larger than the original one.
public void lroRetryAfter() { ServerConfigure configure = new ServerConfigure(); Duration expectedPollingDuration = Duration.ofSeconds(3); configure.pollingCountTillSuccess = 3; configure.additionalHeaders = new HttpHeaders(new HttpHeader("Retry-After", "1")); WireMockServer lroServer = startServer(configure); lroServe...
Assertions.assertTrue(pollingDuration.compareTo(expectedPollingDuration) > 0);
public void lroRetryAfter() { ServerConfigure configure = new ServerConfigure(); Duration expectedPollingDuration = Duration.ofSeconds(3); configure.pollingCountTillSuccess = 3; configure.additionalHeaders = new HttpHeaders(new HttpHeader("Retry-After", "1")); WireMockServer lroServer = startServer(configure); lroServe...
class LROPollerTests { private static final SerializerAdapter SERIALIZER = new AzureJacksonAdapter(); private static final Duration POLLING_DURATION = Duration.ofMillis(100); @BeforeEach public void beforeTest() { MockitoAnnotations.initMocks(this); } @AfterEach public void afterTest() { Mockito.framework().clearInline...
class LROPollerTests { private static final SerializerAdapter SERIALIZER = new AzureJacksonAdapter(); private static final Duration POLLING_DURATION = Duration.ofMillis(100); @BeforeEach public void beforeTest() { MockitoAnnotations.initMocks(this); } @AfterEach public void afterTest() { Mockito.framework().clearInline...
Got it. I had thought it was 30s.
public void lroRetryAfter() { ServerConfigure configure = new ServerConfigure(); Duration expectedPollingDuration = Duration.ofSeconds(3); configure.pollingCountTillSuccess = 3; configure.additionalHeaders = new HttpHeaders(new HttpHeader("Retry-After", "1")); WireMockServer lroServer = startServer(configure); lroServe...
Assertions.assertTrue(pollingDuration.compareTo(expectedPollingDuration) > 0);
public void lroRetryAfter() { ServerConfigure configure = new ServerConfigure(); Duration expectedPollingDuration = Duration.ofSeconds(3); configure.pollingCountTillSuccess = 3; configure.additionalHeaders = new HttpHeaders(new HttpHeader("Retry-After", "1")); WireMockServer lroServer = startServer(configure); lroServe...
class LROPollerTests { private static final SerializerAdapter SERIALIZER = new AzureJacksonAdapter(); private static final Duration POLLING_DURATION = Duration.ofMillis(100); @BeforeEach public void beforeTest() { MockitoAnnotations.initMocks(this); } @AfterEach public void afterTest() { Mockito.framework().clearInline...
class LROPollerTests { private static final SerializerAdapter SERIALIZER = new AzureJacksonAdapter(); private static final Duration POLLING_DURATION = Duration.ofMillis(100); @BeforeEach public void beforeTest() { MockitoAnnotations.initMocks(this); } @AfterEach public void afterTest() { Mockito.framework().clearInline...
I'm okay with this as it follows what the service will be doing. It is a little concerning though as we are implicitly mutating passed customer value, so we need to make sure this is documented strongly somewhere.
public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); format.setTimeZone(TimeZone.getTimeZone("UTC")); String dateString = format.format(dateValue); gen.writeString(dateString); }
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { String dateString = dateValue.toInstant().atOffset(ZoneOffset.UTC) .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); gen.writeString(dateString); }
class Iso8601DateSerializer extends JsonSerializer<Date> { /** * Gets a module wrapping this serializer as an adapter for the Jackson * ObjectMapper. * * @return a simple module to be plugged onto Jackson ObjectMapper. */ public static SimpleModule getModule() { SimpleModule module = new SimpleModule(); module.addSeria...
class Iso8601DateSerializer extends JsonSerializer<Date> { /** * Gets a module wrapping this serializer as an adapter for the Jackson * ObjectMapper. * * @return a simple module to be plugged onto Jackson ObjectMapper. */ public static SimpleModule getModule() { SimpleModule module = new SimpleModule(); module.addSeria...
Can we make `format` a static property on the class, it is the same during every call. Check if it is thread safe before making the change though.
public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); format.setTimeZone(TimeZone.getTimeZone("UTC")); String dateString = format.format(dateValue); gen.writeString(dateString); }
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { String dateString = dateValue.toInstant().atOffset(ZoneOffset.UTC) .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); gen.writeString(dateString); }
class Iso8601DateSerializer extends JsonSerializer<Date> { /** * Gets a module wrapping this serializer as an adapter for the Jackson * ObjectMapper. * * @return a simple module to be plugged onto Jackson ObjectMapper. */ public static SimpleModule getModule() { SimpleModule module = new SimpleModule(); module.addSeria...
class Iso8601DateSerializer extends JsonSerializer<Date> { /** * Gets a module wrapping this serializer as an adapter for the Jackson * ObjectMapper. * * @return a simple module to be plugged onto Jackson ObjectMapper. */ public static SimpleModule getModule() { SimpleModule module = new SimpleModule(); module.addSeria...
Why was the logic here changed to eagerly call the deserializer?
public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { Object obj = defaultDeserializer.deserialize(jp, ctxt); if (jp.currentTokenId() == JsonTokenId.ID_START_OBJECT) { return parseDateType(obj); } else if (jp.currentTokenId() == JsonTokenId.ID_START_ARRAY) { List<?> list = (List) ob...
Object obj = defaultDeserializer.deserialize(jp, ctxt);
public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { Object obj = defaultDeserializer.deserialize(jp, ctxt); if (jp.currentTokenId() == JsonTokenId.ID_START_OBJECT) { return parseDateType(obj); } else if (jp.currentTokenId() == JsonTokenId.ID_START_ARRAY) { List<?> list = (List) ob...
class Iso8601DateDeserializer extends UntypedObjectDeserializer { private static final long serialVersionUID = 1L; private final UntypedObjectDeserializer defaultDeserializer; protected Iso8601DateDeserializer(final UntypedObjectDeserializer defaultDeserializer) { super(null, null); this.defaultDeserializer = defaultDe...
class Iso8601DateDeserializer extends UntypedObjectDeserializer { private static final long serialVersionUID = 1L; private final UntypedObjectDeserializer defaultDeserializer; private static final String ISO8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; protected Iso8601DateDeserializer(final UntypedObjectDeserializer d...
Why was this logic flipped?
public static void configureMapper(ObjectMapper mapper) { mapper.registerModule(new JavaTimeModule()); mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); UntypedObjectDeserializer defaultDeserializer = new UntypedObjectDeserializer(null, null); GeoPointDeserializer geoPointDeserializer = new GeoP...
Iso8601DateDeserializer iso8601DateDeserializer = new Iso8601DateDeserializer(geoPointDeserializer);
public static void configureMapper(ObjectMapper mapper) { mapper.registerModule(new JavaTimeModule()); mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); UntypedObjectDeserializer defaultDeserializer = new UntypedObjectDeserializer(null, null); GeoPointDeserializer geoPointDeserializer = new GeoP...
class SerializationUtil { /** * Configures an {@link ObjectMapper} with custom behavior needed to work with the Azure Cognitive Search REST API. * * @param mapper the mapper to be configured */ }
class SerializationUtil { /** * Configures an {@link ObjectMapper} with custom behavior needed to work with the Azure Cognitive Search REST API. * * @param mapper the mapper to be configured */ }
I'm a little confused on the decimal to String conversion, is there any reason we can't use `%+02f` anymore in the `String.format` call? Are we looking to get additional units of precision in the decimal part?
public String toString() { if (isValid()) { String longitude = ("" + coordinates.get(0)).contains(".") ? "" + coordinates.get(0) : "" + coordinates.get(0) + ".0"; String latitude = ("" + coordinates.get(1)).contains(".") ? "" + coordinates.get(1) : "" + coordinates.get(1) + ".0"; return String.format( Locale.US, "{type...
String longitude = ("" + coordinates.get(0)).contains(".")
public String toString() { if (isValid()) { String longitude = Double.toString(coordinates.get(0)); String latitude = Double.toString(coordinates.get(1)); return String.format( Locale.ROOT, "{type=Point, coordinates=[%s, %s], crs={%s}}", "" + longitude, latitude, coordinateSystem); } return ""; }
class GeoPoint { private static final String POINT = "Point"; @JsonProperty private String type; @JsonProperty private List<Double> coordinates; @JsonProperty("crs") private CoordinateSystem coordinateSystem; private GeoPoint() { this.coordinateSystem = CoordinateSystem.create(); this.type = POINT; } /** * Retrieve Geo...
class GeoPoint { private static final String POINT = "Point"; @JsonProperty private String type; @JsonProperty private List<Double> coordinates; @JsonProperty("crs") private CoordinateSystem coordinateSystem; private GeoPoint() { this.coordinateSystem = CoordinateSystem.create(); this.type = POINT; } /** * Retrieve Geo...
Don't need to call `toString` here as the formatting function should implicitly do that.
public String toString() { if (isValid()) { String longitude = ("" + coordinates.get(0)).contains(".") ? "" + coordinates.get(0) : "" + coordinates.get(0) + ".0"; String latitude = ("" + coordinates.get(1)).contains(".") ? "" + coordinates.get(1) : "" + coordinates.get(1) + ".0"; return String.format( Locale.US, "{type...
coordinateSystem.toString());
public String toString() { if (isValid()) { String longitude = Double.toString(coordinates.get(0)); String latitude = Double.toString(coordinates.get(1)); return String.format( Locale.ROOT, "{type=Point, coordinates=[%s, %s], crs={%s}}", "" + longitude, latitude, coordinateSystem); } return ""; }
class GeoPoint { private static final String POINT = "Point"; @JsonProperty private String type; @JsonProperty private List<Double> coordinates; @JsonProperty("crs") private CoordinateSystem coordinateSystem; private GeoPoint() { this.coordinateSystem = CoordinateSystem.create(); this.type = POINT; } /** * Retrieve Geo...
class GeoPoint { private static final String POINT = "Point"; @JsonProperty private String type; @JsonProperty private List<Double> coordinates; @JsonProperty("crs") private CoordinateSystem coordinateSystem; private GeoPoint() { this.coordinateSystem = CoordinateSystem.create(); this.type = POINT; } /** * Retrieve Geo...
Sure. Will add JavaDoc.
public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); format.setTimeZone(TimeZone.getTimeZone("UTC")); String dateString = format.format(dateValue); gen.writeString(dateString); }
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { String dateString = dateValue.toInstant().atOffset(ZoneOffset.UTC) .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); gen.writeString(dateString); }
class Iso8601DateSerializer extends JsonSerializer<Date> { /** * Gets a module wrapping this serializer as an adapter for the Jackson * ObjectMapper. * * @return a simple module to be plugged onto Jackson ObjectMapper. */ public static SimpleModule getModule() { SimpleModule module = new SimpleModule(); module.addSeria...
class Iso8601DateSerializer extends JsonSerializer<Date> { /** * Gets a module wrapping this serializer as an adapter for the Jackson * ObjectMapper. * * @return a simple module to be plugged onto Jackson ObjectMapper. */ public static SimpleModule getModule() { SimpleModule module = new SimpleModule(); module.addSeria...
SimpleDateFormat is not thread safe. It will trigger the spotbugs https://stackoverflow.com/questions/6840803/why-is-javas-simpledateformat-not-thread-safe
public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); format.setTimeZone(TimeZone.getTimeZone("UTC")); String dateString = format.format(dateValue); gen.writeString(dateString); }
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { String dateString = dateValue.toInstant().atOffset(ZoneOffset.UTC) .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); gen.writeString(dateString); }
class Iso8601DateSerializer extends JsonSerializer<Date> { /** * Gets a module wrapping this serializer as an adapter for the Jackson * ObjectMapper. * * @return a simple module to be plugged onto Jackson ObjectMapper. */ public static SimpleModule getModule() { SimpleModule module = new SimpleModule(); module.addSeria...
class Iso8601DateSerializer extends JsonSerializer<Date> { /** * Gets a module wrapping this serializer as an adapter for the Jackson * ObjectMapper. * * @return a simple module to be plugged onto Jackson ObjectMapper. */ public static SimpleModule getModule() { SimpleModule module = new SimpleModule(); module.addSeria...
The order does not make any differences.
public static void configureMapper(ObjectMapper mapper) { mapper.registerModule(new JavaTimeModule()); mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); UntypedObjectDeserializer defaultDeserializer = new UntypedObjectDeserializer(null, null); GeoPointDeserializer geoPointDeserializer = new GeoP...
Iso8601DateDeserializer iso8601DateDeserializer = new Iso8601DateDeserializer(geoPointDeserializer);
public static void configureMapper(ObjectMapper mapper) { mapper.registerModule(new JavaTimeModule()); mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); UntypedObjectDeserializer defaultDeserializer = new UntypedObjectDeserializer(null, null); GeoPointDeserializer geoPointDeserializer = new GeoP...
class SerializationUtil { /** * Configures an {@link ObjectMapper} with custom behavior needed to work with the Azure Cognitive Search REST API. * * @param mapper the mapper to be configured */ }
class SerializationUtil { /** * Configures an {@link ObjectMapper} with custom behavior needed to work with the Azure Cognitive Search REST API. * * @param mapper the mapper to be configured */ }
This date format is used in multiple places. Consider making this a string constant.
private Object parseDateType(Object obj) { try { return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse((String) obj); } catch (ParseException e) { } return obj; }
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse((String) obj);
private Object parseDateType(Object obj) { try { return new SimpleDateFormat(ISO8601_FORMAT).parse((String) obj); } catch (ParseException e) { return obj; } }
class Iso8601DateDeserializer extends UntypedObjectDeserializer { private static final long serialVersionUID = 1L; private final UntypedObjectDeserializer defaultDeserializer; protected Iso8601DateDeserializer(final UntypedObjectDeserializer defaultDeserializer) { super(null, null); this.defaultDeserializer = defaultDe...
class Iso8601DateDeserializer extends UntypedObjectDeserializer { private static final long serialVersionUID = 1L; private final UntypedObjectDeserializer defaultDeserializer; private static final String ISO8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; protected Iso8601DateDeserializer(final UntypedObjectDeserializer d...
Return the `obj` here instead of having empty `catch` block.
private Object parseDateType(Object obj) { try { return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse((String) obj); } catch (ParseException e) { } return obj; }
private Object parseDateType(Object obj) { try { return new SimpleDateFormat(ISO8601_FORMAT).parse((String) obj); } catch (ParseException e) { return obj; } }
class Iso8601DateDeserializer extends UntypedObjectDeserializer { private static final long serialVersionUID = 1L; private final UntypedObjectDeserializer defaultDeserializer; protected Iso8601DateDeserializer(final UntypedObjectDeserializer defaultDeserializer) { super(null, null); this.defaultDeserializer = defaultDe...
class Iso8601DateDeserializer extends UntypedObjectDeserializer { private static final long serialVersionUID = 1L; private final UntypedObjectDeserializer defaultDeserializer; private static final String ISO8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; protected Iso8601DateDeserializer(final UntypedObjectDeserializer d...
Since `Date` is in UTC, the mutation is not resulting in data-loss. So, it's okay to set the timezone to UTC and format the string.
public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); format.setTimeZone(TimeZone.getTimeZone("UTC")); String dateString = format.format(dateValue); gen.writeString(dateString); }
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { String dateString = dateValue.toInstant().atOffset(ZoneOffset.UTC) .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); gen.writeString(dateString); }
class Iso8601DateSerializer extends JsonSerializer<Date> { /** * Gets a module wrapping this serializer as an adapter for the Jackson * ObjectMapper. * * @return a simple module to be plugged onto Jackson ObjectMapper. */ public static SimpleModule getModule() { SimpleModule module = new SimpleModule(); module.addSeria...
class Iso8601DateSerializer extends JsonSerializer<Date> { /** * Gets a module wrapping this serializer as an adapter for the Jackson * ObjectMapper. * * @return a simple module to be plugged onto Jackson ObjectMapper. */ public static SimpleModule getModule() { SimpleModule module = new SimpleModule(); module.addSeria...
Is this required? `module`, which has the date deserializer, is registered to the `mapper` in the next line.
public static void configureMapper(ObjectMapper mapper) { mapper.registerModule(new JavaTimeModule()); mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); UntypedObjectDeserializer defaultDeserializer = new UntypedObjectDeserializer(null, null); GeoPointDeserializer geoPointDeserializer = new GeoP...
mapper.registerModule(Iso8601DateSerializer.getModule());
public static void configureMapper(ObjectMapper mapper) { mapper.registerModule(new JavaTimeModule()); mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); UntypedObjectDeserializer defaultDeserializer = new UntypedObjectDeserializer(null, null); GeoPointDeserializer geoPointDeserializer = new GeoP...
class SerializationUtil { /** * Configures an {@link ObjectMapper} with custom behavior needed to work with the Azure Cognitive Search REST API. * * @param mapper the mapper to be configured */ }
class SerializationUtil { /** * Configures an {@link ObjectMapper} with custom behavior needed to work with the Azure Cognitive Search REST API. * * @param mapper the mapper to be configured */ }
Set the locale to `Locale.ROOT`.
public String toString() { if (isValid()) { String longitude = ("" + coordinates.get(0)).contains(".") ? "" + coordinates.get(0) : "" + coordinates.get(0) + ".0"; String latitude = ("" + coordinates.get(1)).contains(".") ? "" + coordinates.get(1) : "" + coordinates.get(1) + ".0"; return String.format( Locale.US, "{type...
Locale.US,
public String toString() { if (isValid()) { String longitude = Double.toString(coordinates.get(0)); String latitude = Double.toString(coordinates.get(1)); return String.format( Locale.ROOT, "{type=Point, coordinates=[%s, %s], crs={%s}}", "" + longitude, latitude, coordinateSystem); } return ""; }
class GeoPoint { private static final String POINT = "Point"; @JsonProperty private String type; @JsonProperty private List<Double> coordinates; @JsonProperty("crs") private CoordinateSystem coordinateSystem; private GeoPoint() { this.coordinateSystem = CoordinateSystem.create(); this.type = POINT; } /** * Retrieve Geo...
class GeoPoint { private static final String POINT = "Point"; @JsonProperty private String type; @JsonProperty private List<Double> coordinates; @JsonProperty("crs") private CoordinateSystem coordinateSystem; private GeoPoint() { this.coordinateSystem = CoordinateSystem.create(); this.type = POINT; } /** * Retrieve Geo...
`isValid` should also check that `coordinates.get(0)` and `coordinates.get(1)` are not null?
public boolean isValid() { return coordinates != null && coordinates.size() == 2 && coordinates.get(0) >= -180.0 && coordinates.get(0) <= 180.0 && coordinates.get(1) >= -90.0 && coordinates.get(1) <= 90.0 && (coordinateSystem == null || coordinateSystem.isValid()); }
&& coordinates.get(0) >= -180.0 && coordinates.get(0) <= 180.0
public boolean isValid() { return coordinates != null && coordinates.size() == 2 && coordinates.get(0) != null && coordinates.get(1) != null && coordinates.get(0) >= -180.0 && coordinates.get(0) <= 180.0 && coordinates.get(1) >= -90.0 && coordinates.get(1) <= 90.0 && (coordinateSystem == null || coordinateSystem.isVali...
class GeoPoint { private static final String POINT = "Point"; @JsonProperty private String type; @JsonProperty private List<Double> coordinates; @JsonProperty("crs") private CoordinateSystem coordinateSystem; private GeoPoint() { this.coordinateSystem = CoordinateSystem.create(); this.type = POINT; } /** * Retrieve Geo...
class GeoPoint { private static final String POINT = "Point"; @JsonProperty private String type; @JsonProperty private List<Double> coordinates; @JsonProperty("crs") private CoordinateSystem coordinateSystem; private GeoPoint() { this.coordinateSystem = CoordinateSystem.create(); this.type = POINT; } /** * Retrieve Geo...
`Double.toString(value)` will append `.0`. Don't have to do this explicitly. ```suggestion String latitude = Double.toString(coordinates.get(1)); ```
public String toString() { if (isValid()) { String longitude = ("" + coordinates.get(0)).contains(".") ? "" + coordinates.get(0) : "" + coordinates.get(0) + ".0"; String latitude = ("" + coordinates.get(1)).contains(".") ? "" + coordinates.get(1) : "" + coordinates.get(1) + ".0"; return String.format( Locale.US, "{type...
? "" + coordinates.get(1) : "" + coordinates.get(1) + ".0";
public String toString() { if (isValid()) { String longitude = Double.toString(coordinates.get(0)); String latitude = Double.toString(coordinates.get(1)); return String.format( Locale.ROOT, "{type=Point, coordinates=[%s, %s], crs={%s}}", "" + longitude, latitude, coordinateSystem); } return ""; }
class GeoPoint { private static final String POINT = "Point"; @JsonProperty private String type; @JsonProperty private List<Double> coordinates; @JsonProperty("crs") private CoordinateSystem coordinateSystem; private GeoPoint() { this.coordinateSystem = CoordinateSystem.create(); this.type = POINT; } /** * Retrieve Geo...
class GeoPoint { private static final String POINT = "Point"; @JsonProperty private String type; @JsonProperty private List<Double> coordinates; @JsonProperty("crs") private CoordinateSystem coordinateSystem; private GeoPoint() { this.coordinateSystem = CoordinateSystem.create(); this.type = POINT; } /** * Retrieve Geo...
Here we register both serializer and deserializer for java.utl.Date type
public static void configureMapper(ObjectMapper mapper) { mapper.registerModule(new JavaTimeModule()); mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); UntypedObjectDeserializer defaultDeserializer = new UntypedObjectDeserializer(null, null); GeoPointDeserializer geoPointDeserializer = new GeoP...
mapper.registerModule(Iso8601DateSerializer.getModule());
public static void configureMapper(ObjectMapper mapper) { mapper.registerModule(new JavaTimeModule()); mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); UntypedObjectDeserializer defaultDeserializer = new UntypedObjectDeserializer(null, null); GeoPointDeserializer geoPointDeserializer = new GeoP...
class SerializationUtil { /** * Configures an {@link ObjectMapper} with custom behavior needed to work with the Azure Cognitive Search REST API. * * @param mapper the mapper to be configured */ }
class SerializationUtil { /** * Configures an {@link ObjectMapper} with custom behavior needed to work with the Azure Cognitive Search REST API. * * @param mapper the mapper to be configured */ }
I am trying to replicate the format service return.
public String toString() { if (isValid()) { String longitude = ("" + coordinates.get(0)).contains(".") ? "" + coordinates.get(0) : "" + coordinates.get(0) + ".0"; String latitude = ("" + coordinates.get(1)).contains(".") ? "" + coordinates.get(1) : "" + coordinates.get(1) + ".0"; return String.format( Locale.US, "{type...
String longitude = ("" + coordinates.get(0)).contains(".")
public String toString() { if (isValid()) { String longitude = Double.toString(coordinates.get(0)); String latitude = Double.toString(coordinates.get(1)); return String.format( Locale.ROOT, "{type=Point, coordinates=[%s, %s], crs={%s}}", "" + longitude, latitude, coordinateSystem); } return ""; }
class GeoPoint { private static final String POINT = "Point"; @JsonProperty private String type; @JsonProperty private List<Double> coordinates; @JsonProperty("crs") private CoordinateSystem coordinateSystem; private GeoPoint() { this.coordinateSystem = CoordinateSystem.create(); this.type = POINT; } /** * Retrieve Geo...
class GeoPoint { private static final String POINT = "Point"; @JsonProperty private String type; @JsonProperty private List<Double> coordinates; @JsonProperty("crs") private CoordinateSystem coordinateSystem; private GeoPoint() { this.coordinateSystem = CoordinateSystem.create(); this.type = POINT; } /** * Retrieve Geo...
Should this be a common class in azure-core? Iso8601 seems like a common format to deserialize?
public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { Object obj = defaultDeserializer.deserialize(jp, ctxt); if (jp.currentTokenId() == JsonTokenId.ID_START_OBJECT) { return parseDateType(obj); } else if (jp.currentTokenId() == JsonTokenId.ID_START_ARRAY) { List<?> list = (List) ob...
Object obj = defaultDeserializer.deserialize(jp, ctxt);
public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { Object obj = defaultDeserializer.deserialize(jp, ctxt); if (jp.currentTokenId() == JsonTokenId.ID_START_OBJECT) { return parseDateType(obj); } else if (jp.currentTokenId() == JsonTokenId.ID_START_ARRAY) { List<?> list = (List) ob...
class Iso8601DateDeserializer extends UntypedObjectDeserializer { private static final long serialVersionUID = 1L; private final UntypedObjectDeserializer defaultDeserializer; protected Iso8601DateDeserializer(final UntypedObjectDeserializer defaultDeserializer) { super(null, null); this.defaultDeserializer = defaultDe...
class Iso8601DateDeserializer extends UntypedObjectDeserializer { private static final long serialVersionUID = 1L; private final UntypedObjectDeserializer defaultDeserializer; private static final String ISO8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; protected Iso8601DateDeserializer(final UntypedObjectDeserializer d...
DateTimeSerializer is supposed to deserialize and deserialize this format.. should the fix be in there? https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/core/azure-core/src/main/java/com/azure/core/util/serializer/DateTimeSerializer.java#L18
public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { Object obj = defaultDeserializer.deserialize(jp, ctxt); if (jp.currentTokenId() == JsonTokenId.ID_START_OBJECT) { return parseDateType(obj); } else if (jp.currentTokenId() == JsonTokenId.ID_START_ARRAY) { List<?> list = (List) ob...
Object obj = defaultDeserializer.deserialize(jp, ctxt);
public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { Object obj = defaultDeserializer.deserialize(jp, ctxt); if (jp.currentTokenId() == JsonTokenId.ID_START_OBJECT) { return parseDateType(obj); } else if (jp.currentTokenId() == JsonTokenId.ID_START_ARRAY) { List<?> list = (List) ob...
class Iso8601DateDeserializer extends UntypedObjectDeserializer { private static final long serialVersionUID = 1L; private final UntypedObjectDeserializer defaultDeserializer; protected Iso8601DateDeserializer(final UntypedObjectDeserializer defaultDeserializer) { super(null, null); this.defaultDeserializer = defaultDe...
class Iso8601DateDeserializer extends UntypedObjectDeserializer { private static final long serialVersionUID = 1L; private final UntypedObjectDeserializer defaultDeserializer; private static final String ISO8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; protected Iso8601DateDeserializer(final UntypedObjectDeserializer d...
Search allows to upload user-defined documents with any date classes. The link you have is to support Joda time (OffsetDateTime, LocalDateTime etc). What we are trying to do here is to support old date lib (java.util.Date) We agreed to put serializer to search only, since Search has specific format and time zone requi...
public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { Object obj = defaultDeserializer.deserialize(jp, ctxt); if (jp.currentTokenId() == JsonTokenId.ID_START_OBJECT) { return parseDateType(obj); } else if (jp.currentTokenId() == JsonTokenId.ID_START_ARRAY) { List<?> list = (List) ob...
Object obj = defaultDeserializer.deserialize(jp, ctxt);
public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { Object obj = defaultDeserializer.deserialize(jp, ctxt); if (jp.currentTokenId() == JsonTokenId.ID_START_OBJECT) { return parseDateType(obj); } else if (jp.currentTokenId() == JsonTokenId.ID_START_ARRAY) { List<?> list = (List) ob...
class Iso8601DateDeserializer extends UntypedObjectDeserializer { private static final long serialVersionUID = 1L; private final UntypedObjectDeserializer defaultDeserializer; protected Iso8601DateDeserializer(final UntypedObjectDeserializer defaultDeserializer) { super(null, null); this.defaultDeserializer = defaultDe...
class Iso8601DateDeserializer extends UntypedObjectDeserializer { private static final long serialVersionUID = 1L; private final UntypedObjectDeserializer defaultDeserializer; private static final String ISO8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; protected Iso8601DateDeserializer(final UntypedObjectDeserializer d...
This is needed for every block. Just tried to minimize the code with local var.
public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { Object obj = defaultDeserializer.deserialize(jp, ctxt); if (jp.currentTokenId() == JsonTokenId.ID_START_OBJECT) { return parseDateType(obj); } else if (jp.currentTokenId() == JsonTokenId.ID_START_ARRAY) { List<?> list = (List) ob...
Object obj = defaultDeserializer.deserialize(jp, ctxt);
public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { Object obj = defaultDeserializer.deserialize(jp, ctxt); if (jp.currentTokenId() == JsonTokenId.ID_START_OBJECT) { return parseDateType(obj); } else if (jp.currentTokenId() == JsonTokenId.ID_START_ARRAY) { List<?> list = (List) ob...
class Iso8601DateDeserializer extends UntypedObjectDeserializer { private static final long serialVersionUID = 1L; private final UntypedObjectDeserializer defaultDeserializer; protected Iso8601DateDeserializer(final UntypedObjectDeserializer defaultDeserializer) { super(null, null); this.defaultDeserializer = defaultDe...
class Iso8601DateDeserializer extends UntypedObjectDeserializer { private static final long serialVersionUID = 1L; private final UntypedObjectDeserializer defaultDeserializer; private static final String ISO8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; protected Iso8601DateDeserializer(final UntypedObjectDeserializer d...
SimpleDateFormat has some shortage of converting am/pm. I convert the date value to offsetDateTime to guarantee the accuracy.
public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); format.setTimeZone(TimeZone.getTimeZone("UTC")); String dateString = format.format(dateValue); gen.writeString(dateString); }
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { String dateString = dateValue.toInstant().atOffset(ZoneOffset.UTC) .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); gen.writeString(dateString); }
class Iso8601DateSerializer extends JsonSerializer<Date> { /** * Gets a module wrapping this serializer as an adapter for the Jackson * ObjectMapper. * * @return a simple module to be plugged onto Jackson ObjectMapper. */ public static SimpleModule getModule() { SimpleModule module = new SimpleModule(); module.addSeria...
class Iso8601DateSerializer extends JsonSerializer<Date> { /** * Gets a module wrapping this serializer as an adapter for the Jackson * ObjectMapper. * * @return a simple module to be plugged onto Jackson ObjectMapper. */ public static SimpleModule getModule() { SimpleModule module = new SimpleModule(); module.addSeria...
`Date` is assumed UTC but is that a contractual agreement in the model? Either way this is the best option we have in supporting it so I'm good with it.
public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); format.setTimeZone(TimeZone.getTimeZone("UTC")); String dateString = format.format(dateValue); gen.writeString(dateString); }
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
public void serialize(Date dateValue, JsonGenerator gen, SerializerProvider serializers) throws IOException { String dateString = dateValue.toInstant().atOffset(ZoneOffset.UTC) .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); gen.writeString(dateString); }
class Iso8601DateSerializer extends JsonSerializer<Date> { /** * Gets a module wrapping this serializer as an adapter for the Jackson * ObjectMapper. * * @return a simple module to be plugged onto Jackson ObjectMapper. */ public static SimpleModule getModule() { SimpleModule module = new SimpleModule(); module.addSeria...
class Iso8601DateSerializer extends JsonSerializer<Date> { /** * Gets a module wrapping this serializer as an adapter for the Jackson * ObjectMapper. * * @return a simple module to be plugged onto Jackson ObjectMapper. */ public static SimpleModule getModule() { SimpleModule module = new SimpleModule(); module.addSeria...