avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Smyth (JIRA)" <j...@apache.org>
Subject [jira] [Created] (AVRO-1549) Overlapping protocol names result in overwritten classes.
Date Tue, 22 Jul 2014 21:32:40 GMT
James Smyth created AVRO-1549:

             Summary: Overlapping protocol names result in overwritten classes.
                 Key: AVRO-1549
                 URL: https://issues.apache.org/jira/browse/AVRO-1549
             Project: Avro
          Issue Type: Bug
          Components: java
            Reporter: James Smyth
            Priority: Minor

If two .avdl files have the same 'protocol' name specified at the top, Java code generation
will only produce one of them, and ignore the other (or, I would speculate, generates one,
then overwrites it with the second one).



protocol example
    void test();


protocol example
    void testOverwrite();

Generates a Java class example.java:

package my.example;

public interface example {
  public static final org.apache.avro.Protocol PROTOCOL = org.apache.avro.Protocol.parse("{\"protocol\":\"example\",\"namespace\":\"my.example\",\"types\":[],\"messages\":{\"testOverwrite\":{\"request\":[],\"response\":\"null\"}}}");
  java.lang.Void testOverwrite() throws org.apache.avro.AvroRemoteException;

  public interface Callback extends example {
    public static final org.apache.avro.Protocol PROTOCOL = my.example.example.PROTOCOL;
    void testOverwrite(org.apache.avro.ipc.Callback<java.lang.Void> callback) throws

While the error may be clear here, I ran into an issue on my project born out of this. We
had an avdl file populated with methods that was importing another avdl that was populated
with common objects used by a number of other avdl files. The included file had the same protocol
name as the file that was including it. This resulted in a Java class with no methods in it.

Being new to Avro, it took me quite a while to narrow down the cause, though now it seems
obvious. It would have been helpful if the code generation had noticed the duplicate protocol
name and thrown an error or least a warning.

This message was sent by Atlassian JIRA

View raw message