Skip to content

The Deep java agent can break applications that depend on grpc-netty-shaded #127

@LMarkie

Description

@LMarkie

Describe the bug
When using grpc-netty-shaded as a maven dependency, at the same time as using the Deep java agent, the dependency can attempt to load services defined in the Deep jar (META-INF/services/).

To Reproduce
Steps to reproduce the behavior:

  1. Create a project which uses the grpc-netty-shaded dependency

Maven - pom.xml

<dependencies>
    <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-netty-shaded</artifactId>
        <version>1.36.1</version>
    </dependency>
</dependencies>

Java - Main.java

import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder;
import java.net.URI;
import java.net.URISyntaxException;

public class Main {
    public static void main( String[] args ) throws URISyntaxException {
        final String authority = new URI( "http://localhost:8888" ).getAuthority();
        NettyChannelBuilder.forTarget( authority );
    }
}
  1. Run with the Deep java agent attached: -javaagent:{path_to_deep_jar}
  2. You will see an Exception printed out:
Exception in thread "main" java.util.ServiceConfigurationError: io.grpc.NameResolverProvider: Provider io.grpc.netty.UdsNameResolverProvider not found
	at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:593)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1219)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1228)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1273)
	at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309)
	at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393)
	at io.grpc.ServiceProviders.loadAll(ServiceProviders.java:67)
	at io.grpc.NameResolverRegistry.getDefaultRegistry(NameResolverRegistry.java:101)
	at io.grpc.internal.ManagedChannelImplBuilder.<init>(ManagedChannelImplBuilder.java:108)
	at io.grpc.internal.ManagedChannelImplBuilder.<init>(ManagedChannelImplBuilder.java:231)
	at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder.<init>(NettyChannelBuilder.java:184)
	at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder.forTarget(NettyChannelBuilder.java:152)
	at Main.main(Main.java:10)

Screenshots
Deep java agent services
deep

grpc-netty dependency services
netty

Additional context
Using the latest version of the Deep java agent on Java 16 and 17.0.8.
Error first found when using the FusionReactor java agent.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions