Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from Azure:master #106

Merged
merged 10 commits into from
Aug 16, 2019
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Each service might have a number of libraries available from each of the followi
* [Management](#Management)

### Client: July 2019 Preview
New wave of packages that we are currently releasing in **preview**. These libraries follow the [Azure SDK Design Guidelines for Java](https://azuresdkspecs.z5.web.core.windows.net/JavaSpec.html) and share a number of core features such as HTTP retries, logging, transport protocols, authentication protocols, etc., so that once you learn how to use these features in one client library, you will know how to use them in other client libraries. You can learn about these shared features [here](core).
New wave of packages that we are currently releasing in **preview**. These libraries follow the [Azure SDK Design Guidelines for Java](https://azure.github.io/azure-sdk/java/guidelines/) and share a number of core features such as HTTP retries, logging, transport protocols, authentication protocols, etc., so that once you learn how to use these features in one client library, you will know how to use them in other client libraries. You can learn about these shared features [here](core).

These preview libraries can be easily identified by their folder, package, and namespaces names starting with `azure-`, e.g. `azure-keyvault`.

Expand Down
3 changes: 3 additions & 0 deletions eng/.docsettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ known_content_issues:
- ['sdk/cosmos/changelog/README.md', '#3113']
- ['sdk/cosmos/microsoft-azure-cosmos-benchmark/README.md', '#3113']
- ['sdk/cosmos/README.md', '#3113']
- ['sdk/storage/azure-storage-blob/swagger/README.md', '#3113']
- ['sdk/storage/azure-storage-queue/swagger/README.md', '#3113']
- ['sdk/storage/azure-storage-file/swagger/README.md', '#3113']
package_indexing_exclusion_list:
- azure-loganalytics-sample
- azure-applicationinsights-query-sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Licensed under the MIT License.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.tools.checkstyle.checks;

Expand All @@ -19,8 +19,8 @@
*/
public class OnlyFinalFieldsForImmutableClassCheck extends AbstractCheck {
private static final String IMMUTABLE_NOTATION = "Immutable";
private static final String ERROR_MSG = "The variable field ''%s'' should be final." +
"Classes annotated with @Immutable are supposed to be immutable.";
private static final String ERROR_MSG = "The variable field ''%s'' should be final."
+ "Classes annotated with @Immutable are supposed to be immutable.";

private boolean hasImmutableAnnotation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void visitToken(DetailAST token) {
// method name has prefix 'build' but not 'build*Client' or 'build*AsyncClient'
if (!methodName.endsWith("Client")) {
log(token, String.format(
"@ServiceClientBuilder class should not have a method name, ''%s'' starting with ''build'' but not ending with ''Client''." , methodName));
"@ServiceClientBuilder class should not have a method name, ''%s'' starting with ''build'' but not ending with ''Client''.", methodName));
}
break;
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.tools.checkstyle.checks;

import com.puppycrawl.tools.checkstyle.api.DetailAST;
Expand Down Expand Up @@ -39,7 +42,7 @@ protected static boolean hasIllegalCombination(DetailAST modifiers) {
Optional<DetailAST> illegalCombination = TokenUtil.findFirstTokenByPredicate(modifiers, (node) -> {
final int type = node.getType();
return INVALID_FINAL_COMBINATION.contains(node.getType()) || (TokenTypes.ANNOTATION == type
&& INVALID_FINAL_ANNOTATIONS.contains(node.findFirstToken(TokenTypes.IDENT).getText()));
&& INVALID_FINAL_ANNOTATIONS.contains(node.findFirstToken(TokenTypes.IDENT).getText()));
});

return illegalCombination.isPresent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@
<suppress checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposedCheck" files=".*[/\\]samples[/\\].*\.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.HttpPipelinePolicyCheck" files=".*[/\\]samples[/\\].*\.java"/>

<!-- Don't apply custom Checkstyle rules to files under checkstyle package. -->
<suppress checks="com\.azure\.tools\.checkstyle\.checks\..+" files=".*[/\\]tools[/\\]checkstyle[/\\].*"/>

<!-- JavaPackage suppression -->
<suppress checks="JavadocPackage" files=".*[/\\]samples[/\\].*\.java"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
<Or>
<Class name="com.microsoft.azure.keyvault.authentication.KeyVaultCredentials"/>
<Class name="com.azure.storage.blob.implementation.AzureBlobStorageBuilder"/>
<Class name="com.azure.storage.file.implementation.AzureFileStorageBuilder"/>
<Class name="com.azure.storage.queue.implementation.AzureQueueStorageBuilder"/>
</Or>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
</Match>
Expand Down
19 changes: 11 additions & 8 deletions pom.client.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.azure</groupId>
<artifactId>azure-client-sdk-parent</artifactId>
Expand Down Expand Up @@ -164,12 +164,13 @@
</dependency>
</dependencies>
<configuration>
<effort>Max</effort>
<effort>max</effort>
<threshold>Low</threshold>
<xmlOutput>true</xmlOutput>
<spotbugsXmlOutputDirectory>${project.build.directory}/spotbugs</spotbugsXmlOutputDirectory>
<excludeFilterFile>spotbugs/spotbugs-exclude.xml</excludeFilterFile>
<failOnError>true</failOnError>
<fork>false</fork>
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -341,7 +342,6 @@
</footer>
<linksource>false</linksource>
<excludePackageNames>
com.microsoft.azure.template:
*.impl*:
*.implementation*:
com.azure.tools.checkstyle*
Expand Down Expand Up @@ -442,12 +442,13 @@
</dependency>
</dependencies>
<configuration>
<effort>Max</effort>
<effort>max</effort>
<threshold>Low</threshold>
<xmlOutput>true</xmlOutput>
<spotbugsXmlOutputDirectory>${project.build.directory}/spotbugs</spotbugsXmlOutputDirectory>
<excludeFilterFile>spotbugs/spotbugs-exclude.xml</excludeFilterFile>
<failOnError>true</failOnError>
<fork>false</fork>
</configuration>
</plugin>

Expand Down Expand Up @@ -515,12 +516,13 @@
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs.maven.version}</version>
<configuration>
<effort>Max</effort>
<effort>max</effort>
<threshold>Low</threshold>
<xmlOutput>true</xmlOutput>
<spotbugsXmlOutputDirectory>${project.build.directory}/spotbugs</spotbugsXmlOutputDirectory>
<excludeFilterFile>eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml</excludeFilterFile>
<failOnError>true</failOnError>
<fork>false</fork>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -728,12 +730,13 @@
<module>./eng/jacoco-test-coverage</module>
</modules>
</profile>

<profile>
<id>template-module</id>
<activation>
<property>
<name>include-template</name>
<name>env.ENABLETEMPLATEDOCS</name>
<value>true</value>
</property>
</activation>
<modules>
Expand Down
2 changes: 1 addition & 1 deletion pom.data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@
<module>./sdk/cosmos</module>
<module>./sdk/eventhubs/pom.data.xml</module>
<module>./sdk/keyvault/pom.data.xml</module>
<module>./sdk/servicebus/azure-servicebus</module>
<module>./sdk/servicebus/microsoft-azure-servicebus</module>
<module>./sdk/storage/microsoft-azure-storage-blob</module>
</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

package com.azure.core.http.rest;

import com.azure.core.util.IterableStream;

import java.util.stream.Stream;

/**
Expand All @@ -20,11 +22,11 @@
*
* {@codesnippet com.azure.core.http.rest.pagedIterable.iterableByPage.while}
*
* @param <T> The type of value contained in this {@link IterableResponse}.
* @param <T> The type of value contained in this {@link IterableStream}.
* @see PagedResponse
* @see IterableResponse
* @see IterableStream
*/
public class PagedIterable<T> extends IterableResponse<T> {
public class PagedIterable<T> extends IterableStream<T> {
private final PagedFlux<T> pagedFlux;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.core.http.rest;
package com.azure.core.util;

import reactor.core.publisher.Flux;

import java.util.Iterator;
import java.util.stream.Stream;

/**
* This class provides utility to iterate over values. All the values are preserved even if they are traversed multiple times.
* This class provides utility to iterate over values using standard 'for-each' style loops, or to convert them into a
* Stream and operate in that fashion. All the values are preserved even if they are traversed multiple times.
*
* <p><strong>Code sample using Stream</strong></p>
*
* {@codesnippet com.azure.core.http.rest.iterableResponse.stream}
* {@codesnippet com.azure.core.util.iterableStream.stream}
*
* <p><strong>Code sample using Iterator</strong></p>
*
* {@codesnippet com.azure.core.http.rest.iterableResponse.iterator.while}
* {@codesnippet com.azure.core.util.iterableStream.iterator.while}
*
* <p><strong>Code sample using Stream and filter</strong></p>
*
* {@codesnippet com.azure.core.http.rest.iterableResponse.stream.filter}
* {@codesnippet com.azure.core.util.iterableStream.stream.filter}
*
* @param <T> The type of value in this {@link Iterable}.
* @see Iterable
*/
public class IterableResponse<T> implements Iterable<T> {
public class IterableStream<T> implements Iterable<T> {
private final Flux<T> flux;

/**
* Creates instance given {@link Flux}.
* @param flux to iterate over
*/
public IterableResponse(Flux<T> flux) {
public IterableStream(Flux<T> flux) {
this.flux = flux;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.core.http.rest;
package com.azure.core.util;

import com.azure.core.http.HttpHeaders;
import com.azure.core.http.HttpMethod;
Expand All @@ -18,9 +18,9 @@
import java.util.stream.IntStream;

/**
* Code snippets for {@link IterableResponse}
* Code snippets for {@link IterableStream}
*/
public class IterableResponseJavaDocCodeSnippets {
public class IterableStreamJavaDocCodeSnippets {

/**
* Iterate over {@link java.util.stream.Stream}
Expand All @@ -33,20 +33,20 @@ public void streamSnippet() throws MalformedURLException {

String deserializedHeaders = "header1,value1,header2,value2";

IterableResponse<PagedResponseBase<String, Integer>> myIterableResponse =
new IterableResponse<>(Flux.just(createPagedResponse(httpRequest, httpHeaders, deserializedHeaders, 1, 3)));
IterableStream<PagedResponseBase<String, Integer>> myIterableStream =
new IterableStream<>(Flux.just(createPagedResponse(httpRequest, httpHeaders, deserializedHeaders, 1, 3)));

// BEGIN: com.azure.core.http.rest.iterableResponse.stream
// BEGIN: com.azure.core.util.iterableStream.stream
// process the stream
myIterableResponse.stream().forEach(resp -> {
myIterableStream.stream().forEach(resp -> {
if (resp.statusCode() == HttpURLConnection.HTTP_OK) {
System.out.printf("Response headers are %s. Url %s%n", resp.deserializedHeaders(), resp.request().url());
resp.items().forEach(value -> {
System.out.printf("Response value is %d%n", value);
});
}
});
// END: com.azure.core.http.rest.iterableResponse.stream
// END: com.azure.core.util.iterableStream.stream
}

/**
Expand All @@ -60,12 +60,12 @@ public void iteratorwhileSnippet() throws MalformedURLException {

String deserializedHeaders = "header1,value1,header2,value2";

IterableResponse<PagedResponseBase<String, Integer>> myIterableResponse =
new IterableResponse<>(Flux.just(createPagedResponse(httpRequest, httpHeaders, deserializedHeaders, 1, 3)));
IterableStream<PagedResponseBase<String, Integer>> myIterableStream =
new IterableStream<>(Flux.just(createPagedResponse(httpRequest, httpHeaders, deserializedHeaders, 1, 3)));

// BEGIN: com.azure.core.http.rest.iterableResponse.iterator.while
// BEGIN: com.azure.core.util.iterableStream.iterator.while
// Iterate over iterator
Iterator<PagedResponseBase<String, Integer>> ite = myIterableResponse.iterator();
Iterator<PagedResponseBase<String, Integer>> ite = myIterableStream.iterator();
while (ite.hasNext()) {
PagedResponseBase<String, Integer> resp = ite.next();
if (resp.statusCode() == HttpURLConnection.HTTP_OK) {
Expand All @@ -75,7 +75,7 @@ public void iteratorwhileSnippet() throws MalformedURLException {
});
}
}
// END: com.azure.core.http.rest.iterableResponse.iterator.while
// END: com.azure.core.util.iterableStream.iterator.while
}

/**
Expand All @@ -89,20 +89,20 @@ public void iteratorStreamFilterSnippet() throws MalformedURLException {

String deserializedHeaders = "header1,value1,header2,value2";

IterableResponse<PagedResponseBase<String, Integer>> myIterableResponse =
new IterableResponse<>(Flux.just(createPagedResponse(httpRequest, httpHeaders, deserializedHeaders, 1, 3)));
IterableStream<PagedResponseBase<String, Integer>> myIterableStream =
new IterableStream<>(Flux.just(createPagedResponse(httpRequest, httpHeaders, deserializedHeaders, 1, 3)));

// BEGIN: com.azure.core.http.rest.iterableResponse.stream.filter
// BEGIN: com.azure.core.util.iterableStream.stream.filter
// process the stream
myIterableResponse.stream().filter(resp -> resp.statusCode() == HttpURLConnection.HTTP_OK)
myIterableStream.stream().filter(resp -> resp.statusCode() == HttpURLConnection.HTTP_OK)
.limit(10)
.forEach(resp -> {
System.out.printf("Response headers are %s. Url %s%n", resp.deserializedHeaders(), resp.request().url());
resp.items().forEach(value -> {
System.out.printf("Response value is %d%n", value);
});
});
// END: com.azure.core.http.rest.iterableResponse.stream.filter
// END: com.azure.core.util.iterableStream.stream.filter
}

private PagedResponseBase<String, Integer> createPagedResponse(HttpRequest httpRequest, HttpHeaders httpHeaders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.List;
import java.util.stream.Collectors;

import com.azure.core.util.IterableStream;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
Expand All @@ -30,7 +31,7 @@ public void setup() {
/*Ensure that if we call stream multiple times, it always returns same values and they are same as original list of values.*/
@Test
public void testIterableResponseStreamFromStart() {
IterableResponse<Integer> iterableResponse = getIntegerIterableResponse(2, 5);
IterableStream<Integer> iterableResponse = getIntegerIterableResponse(2, 5);
Assert.assertEquals(iterableResponse.stream().collect(Collectors.toList()).size(), iterableResponse.stream().collect(Collectors.toList()).size());

// ensure original list of values are same after calling iterator()
Expand All @@ -41,7 +42,7 @@ public void testIterableResponseStreamFromStart() {
/*Ensure that if we call iterator multiple times, it always returns same values and they are same as original list of values.*/
@Test
public void testIterableResponseIteratorFromStart() {
IterableResponse<Integer> iterableResponse = getIntegerIterableResponse(2, 5);
IterableStream<Integer> iterableResponse = getIntegerIterableResponse(2, 5);
List<Integer> actualNumberValues1 = new ArrayList<>();
List<Integer> actualNumberValues2 = new ArrayList<>();
iterableResponse.iterator().forEachRemaining(number -> actualNumberValues1.add(number));
Expand All @@ -53,8 +54,8 @@ public void testIterableResponseIteratorFromStart() {
iterableResponse.iterator().forEachRemaining(number -> Assert.assertTrue(originalIntegerList.contains(number)));
}

private IterableResponse<Integer> getIntegerIterableResponse(int startNumber, int noOfValues) {
private IterableStream<Integer> getIntegerIterableResponse(int startNumber, int noOfValues) {
Flux<Integer> integerFlux = Flux.range(startNumber, noOfValues);
return new IterableResponse<>(integerFlux);
return new IterableStream<>(integerFlux);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package com.azure.messaging.eventhubs;

import com.azure.core.amqp.RetryOptions;
import com.azure.core.http.rest.IterableResponse;
import com.azure.core.util.IterableStream;
import com.azure.core.implementation.annotation.ReturnType;
import com.azure.core.implementation.annotation.ServiceClient;
import com.azure.core.implementation.annotation.ServiceMethod;
Expand Down Expand Up @@ -67,8 +67,8 @@ public EventHubProperties getProperties() {
* @return The identifiers for all partitions of an Event Hub.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public IterableResponse<String> getPartitionIds() {
return new IterableResponse<>(client.getPartitionIds());
public IterableStream<String> getPartitionIds() {
return new IterableStream<>(client.getPartitionIds());
}

/**
Expand Down
Loading