gnodet-bot commented on code in PR #30590:
URL: https://github.com/apache/camel/pull/30590#discussion_r4657493255
##########
components/camel-protobuf-schema/src/main/java/org/apache/camel/dataformat/protobuf/schema/WireProtobufSchemaParser.java:
##########
@@ -123,7 +125,15 @@ private static Loader loader(ProtoFile file, Loader core) {
return new Loader() {
@Override
public ProtoFile load(String path) {
- return FILE_NAME.equals(path) ? file : core.load(path);
+ if (FILE_NAME.equals(path)) {
+ return file;
+ }
+ try {
+ return core.load(path);
+ } catch (RuntimeException e) {
Review Comment:
Wire's loader throws `IllegalStateException` for unresolvable paths.
Catching `RuntimeException` here risks repackaging Wire internal bugs (NPE,
etc.) as a misleading unsupported-import error. Narrow this to
`IllegalStateException`:
```suggestion
} catch (IllegalStateException e) {
```
##########
components/camel-protobuf-schema/src/main/java/org/apache/camel/dataformat/protobuf/schema/WireProtobufSchemaParser.java:
##########
@@ -56,6 +56,8 @@
public class WireProtobufSchemaParser implements ProtobufSchemaParser {
private static final String FILE_NAME = "camel-schema.proto";
+ private static final String WELL_KNOWN_TYPES = "any.proto,
descriptor.proto, duration.proto, empty.proto,"
+ + " struct.proto,
timestamp.proto and wrappers.proto";
Review Comment:
`field_mask.proto` is handled by `wellKnownType()` (line 187) but is not
listed here. Users who successfully import it will get a misleading error
message saying it isn't supported. Add it to the constant (alphabetically,
between `empty.proto` and `struct.proto`):
```suggestion
private static final String WELL_KNOWN_TYPES = "any.proto,
descriptor.proto, duration.proto, empty.proto, field_mask.proto,"
+ " struct.proto,
timestamp.proto and wrappers.proto";
```
##########
components/camel-protobuf-schema/src/main/docs/protobuf-schema.adoc:
##########
@@ -52,7 +52,7 @@ A YAML route that turns JSON text into a Protobuf message of
the type `Order`, a
== Supported schemas
-`proto2` and `proto3` files with nested messages, enums, maps, `oneof` and
repeated fields. A schema may import these well-known types of
`google/protobuf`, which are read in their JSON form (a `Timestamp` as RFC 3339
text): `any.proto`, `descriptor.proto`, `duration.proto`, `empty.proto`,
`struct.proto`, `timestamp.proto` and `wrappers.proto`. Other imports are not
supported, including `api.proto`, `source_context.proto` and `type.proto`.
+`proto2` and `proto3` files with nested messages, enums, maps, `oneof` and
repeated fields. A schema may import these well-known types of
`google/protobuf`, which are read in their JSON form (a `Timestamp` as RFC 3339
text): `any.proto`, `descriptor.proto`, `duration.proto`, `empty.proto`,
`struct.proto`, `timestamp.proto` and `wrappers.proto`. Other imports are not
supported, including `api.proto`, `source_context.proto` and `type.proto`: the
schema is one file, and a schema that imports another file (such as `import
"shop/common.proto";`) fails with a message that names the import. Put the
types of the imported file in the schema itself.
Review Comment:
`field_mask.proto` is supported (handled in `wellKnownType()`) but is absent
from this list. Add it after `empty.proto`:
```suggestion
`proto2` and `proto3` files with nested messages, enums, maps, `oneof` and
repeated fields. A schema may import these well-known types of
`google/protobuf`, which are read in their JSON form (a `Timestamp` as RFC 3339
text): `any.proto`, `descriptor.proto`, `duration.proto`, `empty.proto`,
`field_mask.proto`, `struct.proto`, `timestamp.proto` and `wrappers.proto`.
Other imports are not supported, including `api.proto`, `source_context.proto`
and `type.proto`: the schema is one file, and a schema that imports another
file (such as `import "shop/common.proto";`) fails with a message that names
the import. Put the types of the imported file in the schema itself.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]