Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-1549

Overlapping protocol names result in overwritten classes.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • java
    • None

    Description

      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).

      Example:

      test1.avdl:

      @namespace("my.example")
      protocol example
      {
      void test();
      }

      test2.avdl:

      @namespace("my.example")
      protocol example
      {
      void testOverwrite();
      }

      Generates a Java class example.java:

      package my.example;

      @SuppressWarnings("all")
      @org.apache.avro.specific.AvroGenerated
      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;

      @SuppressWarnings("all")
      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 java.io.IOException; }

      }

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jimux James Smyth
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: