Java 3rd Party dependency conflict between Azure Function and Azure SDK for Java · Issue #365 · Azure/azure-functions-java-worker (original) (raw)
Technical Details
When using Azure Function and Azure SDK for Java simultaneously. It causes a dependency conflict.
For example, using Azure Function with App Configuration SDK for Java as dependencies in an independent app,
Expected behavior: running the application successfully.
Actual behavior: application crashed with unhandled exception,
[2/21/2020 9:42:14 PM] Executed 'Functions.hello' (Failed, Id=24c8735c-df65-45ea-a857-8ac83005b7fa)
[2/21/2020 9:42:14 PM] System.Private.CoreLib: Exception while executing function: Functions.hello. System.Private.CoreLib: Result: Failure
Exception: NoSuchMethodError: io.netty.handler.ssl.SslProvider.isAlpnSupported(Lio/netty/handler/ssl/SslProvider;)Z
Stack: java.lang.reflect.InvocationTargetException
[2/21/2020 9:42:14 PM] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2/21/2020 9:42:14 PM] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[2/21/2020 9:42:14 PM] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2/21/2020 9:42:14 PM] at java.lang.reflect.Method.invoke(Method.java:498)
[2/21/2020 9:42:14 PM] at com.microsoft.azure.functions.worker.broker.JavaMethodInvokeInfo.invoke(JavaMethodInvokeInfo.java:22)
[2/21/2020 9:42:14 PM] at com.microsoft.azure.functions.worker.broker.JavaMethodExecutor.execute(JavaMethodExecutor.java:54)
[2/21/2020 9:42:14 PM] at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:53)
[2/21/2020 9:42:14 PM] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:33)
[2/21/2020 9:42:14 PM] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10)
[2/21/2020 9:42:14 PM] at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:45)
[2/21/2020 9:42:14 PM] at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:92)
[2/21/2020 9:42:14 PM] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[2/21/2020 9:42:14 PM] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[2/21/2020 9:42:14 PM] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[2/21/2020 9:42:14 PM] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[2/21/2020 9:42:14 PM] at java.lang.Thread.run(Thread.java:748)
[2/21/2020 9:42:14 PM] Caused by: java.lang.NoSuchMethodError: io.netty.handler.ssl.SslProvider.isAlpnSupported(Lio/netty/handler/ssl/SslProvider;)Z
[2/21/2020 9:42:14 PM] at reactor.netty.http.client.HttpClientSecure.<clinit>(HttpClientSecure.java:79)
More details of the exception can redirect to the Azure SDK for Java issue: Azure/azure-sdk-for-java#8392
Investigation
Azure Function
is using GRPC-netty 1.20.0 which using Netty 4.1.34.Final
. The latest version of GRPC-Netty is 1.28.0 which using version 4.1.45.Final
for both artifacts, netty-codec-http2
and netty-handler-proxy
in the io.netty group.
Azure SDK for Java
is using Netty 4.1.44.Final
. (I am from Azure SDK for Java team, we are going to upgrade to Netty 4.1.45.Final
for above two artifacts, netty-codec-http2
and netty-handler-proxy
in the 2020 April release, which is in the first week of April. See section Dependencies
for more details on other artifacts of io.netty and version that we are going to use.).
Proposal
Upgrade GRPC-netty 1.20.0 to latest version 1.28.0 will make Azure Function
and Azure SDK for Java
dependency consistency because both SDKs are using the same Netty version 4.1.45
then.
Dependencies
AZURE FUNCTION dependency tree:
com.microsoft.azure.functions:azure-functions-java-worker:jar:1.5.2
[INFO] +- com.microsoft.azure.functions:azure-functions-java-library:jar:1.3.1-SNAPSHOT:compile
[INFO] +- com.google.protobuf:protobuf-java:jar:3.7.1:compile
[INFO] +- io.grpc:grpc-protobuf:jar:1.20.0:compile
[INFO] | +- io.grpc:grpc-core:jar:1.20.0:compile
[INFO] | | +- io.grpc:grpc-context:jar:1.20.0:compile
[INFO] | | +- com.google.code.gson:gson:jar:2.8.5:compile
[INFO] | | +- com.google.errorprone:error_prone_annotations:jar:2.3.2:compile
[INFO] | | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] | | +- com.google.android:annotations:jar:4.1.1.4:compile
[INFO] | | +- org.codehaus.mojo:animal-sniffer-annotations:jar:1.17:compile
[INFO] | | +- io.opencensus:opencensus-api:jar:0.19.2:compile
[INFO] | | \- io.opencensus:opencensus-contrib-grpc-metrics:jar:0.19.2:compile
[INFO] | +- com.google.guava:guava:jar:26.0-jre:compile
[INFO] | | +- org.checkerframework:checker-qual:jar:2.5.2:compile
[INFO] | | \- com.google.j2objc:j2objc-annotations:jar:1.1:compile
[INFO] | +- com.google.api.grpc:proto-google-common-protos:jar:1.12.0:compile
[INFO] | \- io.grpc:grpc-protobuf-lite:jar:1.20.0:compile
[INFO] +- io.grpc:grpc-stub:jar:1.20.0:compile
[INFO] +- io.grpc:grpc-netty:jar:1.20.0:compile
[INFO] | +- io.netty:netty-codec-http2:jar:4.1.34.Final:compile (version selected from constraint [4.1.34.Final,4.1.34.Final])
[INFO] | | +- io.netty:netty-common:jar:4.1.34.Final:compile
[INFO] | | +- io.netty:netty-buffer:jar:4.1.34.Final:compile
[INFO] | | +- io.netty:netty-transport:jar:4.1.30.Final:compile
[INFO] | | | \- io.netty:netty-resolver:jar:4.1.30.Final:compile
[INFO] | | +- io.netty:netty-codec:jar:4.1.34.Final:compile
[INFO] | | +- io.netty:netty-handler:jar:4.1.30.Final:compile
[INFO] | | \- io.netty:netty-codec-http:jar:4.1.30.Final:compile
[INFO] | \- io.netty:netty-handler-proxy:jar:4.1.30.Final:compile
[INFO] | \- io.netty:netty-codec-socks:jar:4.1.30.Final:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.9:compile
[INFO] +- commons-cli:commons-cli:jar:1.4:compile
[INFO] +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] \- net.java.dev.jna:jna-platform:jar:5.3.0:compile
[INFO] \- net.java.dev.jna:jna:jar:5.3.0:compile
Azure SDK for Java dependency tree and the maven io.netty dependencies will be used in the upcoming April release.:
// Current Azure SDK's io.netty dependency version
com.azure:azure-core-http-netty:jar:1.4.0:compile
[INFO] | +- io.netty:netty-handler:jar:4.1.44.Final:compile
[INFO] | | +- io.netty:netty-common:jar:4.1.44.Final:compile
[INFO] | | +- io.netty:netty-transport:jar:4.1.44.Final:compile
[INFO] | | | \- io.netty:netty-resolver:jar:4.1.44.Final:compile
[INFO] | | \- io.netty:netty-codec:jar:4.1.44.Final:compile
[INFO] | +- io.netty:netty-handler-proxy:jar:4.1.44.Final:compile
[INFO] | | \- io.netty:netty-codec-socks:jar:4.1.44.Final:compile
[INFO] | +- io.netty:netty-buffer:jar:4.1.44.Final:compile
[INFO] | +- io.netty:netty-codec-http:jar:4.1.44.Final:compile
[INFO] | +- io.netty:netty-codec-http2:jar:4.1.44.Final:compile
[INFO] | +- io.netty:netty-transport-native-unix-common:jar:4.1.44.Final:compile
[INFO] | +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.44.Final:compile
[INFO] | \- io.projectreactor.netty:reactor-netty:jar:0.9.4.RELEASE:compile
// Upcoming Azure SDK's io.netty dependency version
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>4.1.45.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler-proxy</artifactId>
<version>4.1.45.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<version>4.1.45.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
<version>4.1.45.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http2</artifactId>
<version>4.1.45.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<version>4.1.45.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<version>4.1.45.Final</version>
<classifier>linux-x86_64</classifier>
</dependency>
cc: @mrm9084