[
https://issues.apache.org/jira/browse/AVRO-3486?focusedWorklogId=788864&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-788864
]
ASF GitHub Bot logged work on AVRO-3486:
----------------------------------------
Author: ASF GitHub Bot
Created on: 08/Jul/22 07:19
Start Date: 08/Jul/22 07:19
Worklog Time Spent: 10m
Work Description: KalleOlaviNiemitalo commented on code in PR #1637:
URL: https://github.com/apache/avro/pull/1637#discussion_r916532228
##########
lang/java/avro/src/main/java/org/apache/avro/Protocol.java:
##########
@@ -275,15 +274,29 @@ public Protocol(Protocol p) {
public Protocol(String name, String doc, String namespace) {
super(PROTOCOL_RESERVED);
- this.name = name;
+ setName(name, namespace);
this.doc = doc;
- this.namespace = namespace;
}
public Protocol(String name, String namespace) {
this(name, null, namespace);
}
+ private void setName(String name, String namespace) {
+ int lastDot = name.lastIndexOf('.');
+ if (lastDot < 0) {
+ this.name = name;
+ this.namespace = namespace;
+ } else {
Review Comment:
If a protocol has namespace "java" and name "lang.String", then its fullname
should be "lang.String" for sure (not "java.lang.String"). But it is not clear
from the spec whether types defined in this protocol should then inherit the
"java" namespace (as declared) or the "lang" namespace (based on the fullname
of the protocol). I don't see any justification for making nested types inherit
the "java.lang" namespace.
Relevant parts of the spec:
<https://github.com/apache/avro/blob/4e1fefca493029ace961b7ef8889a3722458565a/doc/src/content/xdocs/spec.xml#L296-L316>
<https://github.com/apache/avro/blob/4e1fefca493029ace961b7ef8889a3722458565a/doc/src/content/xdocs/spec.xml#L850-L851>
In particular:
> For example, if `"name": "X"` is specified, and this occurs within a field
of the record definition of `org.foo.Y`, then the fullname is `org.foo.X`.
If that is intended to apply only when there is a `"namespace":"org.foo"`
property in the record definition or in some outer definition, and not when the
record definition has `"name":"org.foo.Y", "namespace":"something_else"`, then
the specification should say so.
Issue Time Tracking
-------------------
Worklog Id: (was: 788864)
Time Spent: 0.5h (was: 20m)
> Protocol namespace not parsed correctly if protocol is defined by full name
> ---------------------------------------------------------------------------
>
> Key: AVRO-3486
> URL: https://issues.apache.org/jira/browse/AVRO-3486
> Project: Apache Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.11.1
> Reporter: Oscar Westra van Holthe - Kind
> Priority: Minor
> Labels: pull-request-available
> Fix For: 1.12.0
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> When parsing a protocol with a full name (but no namespace), the namespace is
> not parsed correctly.
> The spec for [Protocol
> Declaration|https://avro.apache.org/docs/current/spec.html#Protocol+Declaration]
> says:
> {quote}The name and namespace qualification rules defined for schema objects
> apply to protocols as well.
> {quote}
> However, a protocol namespace can only be specified using the {{namespace}}
> attribute, not by using a full name like {{qualified.Name}} as protocol name.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)