You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Diógenes Oliveira (Jira)" <ji...@apache.org> on 2020/09/20 03:00:06 UTC

[jira] [Created] (AVRO-2930) Java maven plugin code generation is ignoring the logical type timestamp-millis

Diógenes Oliveira created AVRO-2930:
---------------------------------------

             Summary: Java maven plugin code generation is ignoring the logical type timestamp-millis
                 Key: AVRO-2930
                 URL: https://issues.apache.org/jira/browse/AVRO-2930
             Project: Apache Avro
          Issue Type: Bug
          Components: java
    Affects Versions: 1.9.2, 1.9.1, 1.10.0
            Reporter: Diógenes Oliveira


The relevant field in the schema is:

{code:json}
{
  "name": "server_time",
  "doc": "Time at which the request was processed in the server",
  "logicalType": "timestamp-millis",
  "type": "long"
}
{code}

The plugin section in the pom.xml is as follows:

{code:xml}
<plugin>
    <groupId>org.apache.avro</groupId>
    <artifactId>avro-maven-plugin</artifactId>
    <version>${avro.version}</version>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>schema</goal>
            </goals>
            <configuration>
                <sourceDirectory>${project.basedir}/src/main/resources/avro/</sourceDirectory>
                <outputDirectory>${project.basedir}/src/main/java/</outputDirectory>
                <stringType>String</stringType>
            </configuration>
        </execution>
    </executions>
</plugin>
{code}

The generated source does seem to recognize the existence of the conversion:

{code:java}
  private static SpecificData MODEL$ = new SpecificData();
static {
    MODEL$.addLogicalTypeConversion(new org.apache.avro.data.TimeConversions.TimestampMillisConversion());
  }
{code}

But the getters and setters still refer to a Java Long instead of an Instant:

{code:java}
  public long getServerTime() {
    return server_time;
  }

  public void setServerTime(long value) {
    this.server_time = value;
  }
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)