Skip to content

Commit 13890f8

Browse files
author
waterWang
committed
Add getExtensionRegistry() getter to ProtoLiteUtils and ProtoUtils (#3836)
The ProtoLiteUtils.setExtensionRegistry() setter was added in gRPC 1.0.0, but there was no corresponding getter. This made it impossible for the reflection service or other components to discover the extensions that were registered via the global ExtensionRegistry. Add getExtensionRegistry() to both ProtoLiteUtils (returns ExtensionRegistryLite) and ProtoUtils (returns ExtensionRegistry with a cast) so that the global registry can be read back. Issue: #3836
1 parent d54c8c9 commit 13890f8

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

protobuf-lite/src/main/java/io/grpc/protobuf/lite/ProtoLiteUtils.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ public static void setExtensionRegistry(ExtensionRegistryLite newRegistry) {
7777
globalRegistry = checkNotNull(newRegistry, "newRegistry");
7878
}
7979

80+
/**
81+
* Returns the global extension registry.
82+
*
83+
* @since 1.62.0
84+
*/
85+
public static ExtensionRegistryLite getExtensionRegistry() {
86+
return globalRegistry;
87+
}
88+
8089
/**
8190
* Creates a {@link Marshaller} for protos of the same type as {@code defaultInstance}.
8291
*

protobuf/src/main/java/io/grpc/protobuf/ProtoUtils.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ public static void setExtensionRegistry(ExtensionRegistry registry) {
4646
ProtoLiteUtils.setExtensionRegistry(registry);
4747
}
4848

49+
/**
50+
* Returns the global extension registry.
51+
*
52+
* @since 1.62.0
53+
*/
54+
public static ExtensionRegistry getExtensionRegistry() {
55+
return (ExtensionRegistry) ProtoLiteUtils.getExtensionRegistry();
56+
}
57+
4958
/**
5059
* Create a {@link Marshaller} for protos of the same type as {@code defaultInstance}.
5160
*

0 commit comments

Comments
 (0)