Tiemen Schut created AVRO-4188:
----------------------------------

             Summary: [java] Schema with a field named "java" generates invalid 
code
                 Key: AVRO-4188
                 URL: https://issues.apache.org/jira/browse/AVRO-4188
             Project: Apache Avro
          Issue Type: Bug
          Components: java
    Affects Versions: 1.12.1
            Reporter: Tiemen Schut


Note: this didn't cause issues in 1.12.0.

With a schema like this:
{code:json}
{
    "name": "TopLevel",
    "type": "record",
    "fields": [
        {
            "name": "java",
            "type": "null"
        }
    ]
}{code}

The generated code contains:
{code:java}
@org.apache.avro.specific.AvroGenerated
public class TopLevel extends org.apache.avro.specific.SpecificRecordBase 
implements org.apache.avro.specific.SpecificRecord {

  [...]

  private java.lang.Void java;

  [...]

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (!(o instanceof TopLevel)) {
      return false;
    }
    TopLevel other = (TopLevel) o;
    if (!java.util.Objects.equals(this.java, other.java)) {
      return false;
    }
    return true;
  }
{code}

The equals method is trying to use `Objects::equals` from the `java.util` 
package, but this conflicts with the variable named `java`.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to