Skip to content
6 changes: 5 additions & 1 deletion android/src/main/java/io/grpc/android/UdsChannelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.grpc.ExperimentalApi;
import io.grpc.InsecureChannelCredentials;
import io.grpc.ManagedChannelBuilder;
import io.grpc.internal.GrpcUtil;
import java.lang.reflect.InvocationTargetException;
import javax.annotation.Nullable;
import javax.net.SocketFactory;
Expand Down Expand Up @@ -81,7 +82,10 @@ public static ManagedChannelBuilder<?> forPath(String path, Namespace namespace)
OKHTTP_CHANNEL_BUILDER_CLASS
.getMethod("socketFactory", SocketFactory.class)
.invoke(builder, new UdsSocketFactory(path, namespace));
return builder;
if (builder == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this check for builder == null. There is no need for this check.

Copy link
Contributor Author

@vimanikag vimanikag Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kannanjgithub for the review. I've added a null check to resolve the following warnings and satisfy the code quality check:

Warning:(85, 22) Method invocation 'proxyDetector' may produce 'NullPointerException'

The warnings will be resolved with 'assert builder != null' or a 'null check'. Could you please confirm if it's okay for me to ignore these warnings and remove the null check?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can suppress the warnings. NPE will happen for reflected methods when the requested method name or class name is not available but that cannot happen here since we know they are definitely available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestions @kannanjgithub , I have addressed the review comments and please review it once You get some bandwidth.

throw new NullPointerException("No builder found");
}
return builder.proxyDetector(GrpcUtil.NOOP_PROXY_DETECTOR);
} catch (IllegalAccessException e) {
throw new RuntimeException("Failed to create OkHttpChannelBuilder", e);
} catch (NoSuchMethodException e) {
Expand Down
Loading