[ 
https://issues.apache.org/jira/browse/AVRO-2930?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Diógenes Oliveira updated AVRO-2930:
------------------------------------
    Description: 
The relevant field in the schema is:

{code:json}
{
  "name": "server_time",
  "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}

  was:
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}


> 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.10.0, 1.9.1, 1.9.2
>            Reporter: Diógenes Oliveira
>            Priority: Major
>
> The relevant field in the schema is:
> {code:json}
> {
>   "name": "server_time",
>   "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)

Reply via email to