Skip to content

Commit

Permalink
Various minor improvements (Azure#425)
Browse files Browse the repository at this point in the history
* Check for null channel before closeAndRelease

* Remove client-runtime-native

* channel.write() until not writable, then flush

* Add Base64Util for all base64 encoding/decoding

* HttpPipeline.build with Iterable. Fixes Azure#375.

* Extract AddDatePolicyFactory to public class. Fixes Azure#391.

* Require DecodingPolicyFactory for responses with serialized bodies

* Fix NPE when getting the HttpClientInboundHandler from the pipeline

* Refinements to FlowableUtil

* Update README.md and release notes

* Cleanup pom

* Propagate nulls through Base64Util methods

* add Netty config changes to changelog

* Don't log by default in default Azure pipeline

* Use .cache() instead of writing Single.just() to instance variable

* Add delay param to RetryPolicyFactory. Check isDecoded() for custom headers types.

* Use try-with-resources in FlowableUtilTests
  • Loading branch information
RikkiGibson authored Apr 24, 2018
1 parent 6ca8a13 commit 303e566
Show file tree
Hide file tree
Showing 28 changed files with 579 additions and 513 deletions.
6 changes: 6 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
2.0.0-beta2 (2018-04-23)
- Major refinements to HTTP content streaming, in large part thanks to contributions by [David Moten](https://github.com/davidmoten).
- Removed Joda Time in favor of Java 8 DateTime classes
- NettyClient.Factory now accepts a Netty Bootstrap object allowing for more user configuration of channel attributes, such as the receive buffer size and low/high write watermarks. Currently, specifying an EventLoopGroup or `Class<? extends Channel>` is not supported.
- Various other minor improvements

2.0.0-beta1 (2018-03-08)
- First beta featuring Netty and RxJava 2.
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,30 @@ The runtime libraries for [AutoRest](https://github.com/azure/autorest) generate
<version>2.0.0-beta1</version>
</dependency>

<!-- Optional dependency which adds high-performance native libraries -->
<!-- Below are optional high-performance native dependencies -->

<!-- Available on Windows/Mac/Linux x86_64 -->
<dependency>
<groupId>com.microsoft.rest.v2</groupId>
<artifactId>client-runtime-native</artifactId>
<version>2.0.0-SNAPSHOT</version>
<type>pom</type>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>2.0.8.Final</version>
<classifier>${os.detected.classifier}</classifier>
</dependency>

<!-- Only available on Linux -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<version>4.1.23.Final</version>
<classifier>${os.detected.classifier}</classifier>
</dependency>

<!-- Only available on macOS/BSD -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<version>4.1.23.Final</version>
<classifier>${os.detected.classifier}</classifier>
</dependency>
</dependencies>
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@

package com.microsoft.azure.v2.credentials;

import com.google.common.io.BaseEncoding;
import com.microsoft.aad.adal4j.AsymmetricKeyCredential;
import com.microsoft.aad.adal4j.AuthenticationContext;
import com.microsoft.aad.adal4j.AuthenticationException;
import com.microsoft.aad.adal4j.AuthenticationResult;
import com.microsoft.aad.adal4j.ClientCredential;
import com.microsoft.azure.v2.AzureEnvironment;
import com.microsoft.rest.v2.util.Base64Util;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
Expand Down Expand Up @@ -171,7 +172,7 @@ private PrivateKey privateKeyFromPem(String pem) {
.replace("-----END PRIVATE KEY-----", "")
.replace("\n", "")
.replace("\r", "");
byte[] key = BaseEncoding.base64().decode(base64);
byte[] key = Base64Util.decode(base64.getBytes(StandardCharsets.UTF_8));
PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(key);
try {
KeyFactory kf = KeyFactory.getInstance("RSA");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import com.microsoft.rest.v2.policy.CookiePolicyFactory;
import com.microsoft.rest.v2.policy.CredentialsPolicyFactory;
import com.microsoft.rest.v2.policy.DecodingPolicyFactory;
import com.microsoft.rest.v2.policy.HttpLogDetailLevel;
import com.microsoft.rest.v2.policy.HttpLoggingPolicyFactory;
import com.microsoft.rest.v2.policy.RequestPolicyFactory;
import com.microsoft.rest.v2.policy.RetryPolicyFactory;
import com.microsoft.rest.v2.protocol.SerializerAdapter;
Expand Down Expand Up @@ -184,7 +182,6 @@ public static HttpPipeline createDefaultPipeline(Class<?> swaggerInterface, Requ
if (credentialsPolicy != null) {
builder.withRequestPolicy(credentialsPolicy);
}
builder.withRequestPolicy(new HttpLoggingPolicyFactory(HttpLogDetailLevel.HEADERS));
return builder.build();
}

Expand Down
102 changes: 0 additions & 102 deletions client-runtime-native/pom.xml

This file was deleted.

12 changes: 1 addition & 11 deletions client-runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>io.reactivex.rxjava2</groupId>
<artifactId>rxjava</artifactId>
Expand All @@ -87,6 +83,7 @@
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-annotations</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -97,13 +94,6 @@
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.microsoft.rest.v2</groupId>
<artifactId>client-runtime-native</artifactId>
<version>2.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-standalone</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

package com.microsoft.rest.v2;

import com.google.common.io.BaseEncoding;
import com.microsoft.rest.v2.util.Base64Util;

import java.util.Arrays;

Expand Down Expand Up @@ -73,7 +73,7 @@ public static Base64Url encode(byte[] bytes) {
if (bytes == null) {
return new Base64Url((String) null);
} else {
return new Base64Url(BaseEncoding.base64Url().omitPadding().encode(bytes));
return new Base64Url(Base64Util.encodeURLWithoutPadding(bytes));
}
}

Expand All @@ -95,8 +95,8 @@ public byte[] decodedBytes() {
if (this.bytes == null) {
return null;
}
final String bytesString = new String(bytes);
final byte[] decodedBytes = BaseEncoding.base64Url().decode(bytesString);

final byte[] decodedBytes = Base64Util.decodeURL(bytes);
return decodedBytes;
}

Expand Down
Loading

0 comments on commit 303e566

Please sign in to comment.