You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by fo...@apache.org on 2022/11/25 08:07:40 UTC

[iceberg] branch master updated: API: Fix ErrorProne warning around Immutable Enums (#6264)

This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new c4f9337a61 API: Fix ErrorProne warning around Immutable Enums (#6264)
c4f9337a61 is described below

commit c4f9337a61bf9f4e80f058e3f77b9cb8f617522e
Author: Eduard Tudenhöfner <et...@gmail.com>
AuthorDate: Fri Nov 25 09:07:35 2022 +0100

    API: Fix ErrorProne warning around Immutable Enums (#6264)
    
    This should fix the ErrorProne warning
    ```
    > Task :iceberg-api:compileJava
    /home/nastra/Development/workspace/iceberg/api/src/main/java/org/apache/iceberg/transforms/Timestamps.java:69: warning: [ImmutableEnumChecker] enums should be immutable: 'Timestamps' has field 'apply' of type 'org.apache.iceberg.util.SerializableFunction<java.lang.Long,java.lang.Integer>', the declaration of type 'org.apache.iceberg.util.SerializableFunction<java.lang.Long,java.lang.Integer>' is not annotated with @com.google.errorprone.annotations.Immutable
      private final SerializableFunction<Long, Integer> apply;
                                                        ^
        (see https://errorprone.info/bugpattern/ImmutableEnumChecker)
    /home/nastra/Development/workspace/iceberg/api/src/main/java/org/apache/iceberg/transforms/Dates.java:66: warning: [ImmutableEnumChecker] enums should be immutable: 'Dates' has field 'apply' of type 'org.apache.iceberg.transforms.Dates.Apply', the declaration of type 'org.apache.iceberg.transforms.Dates.Apply' is not annotated with @com.google.errorprone.annotations.Immutable
      private final Apply apply;
                          ^
        (see https://errorprone.info/bugpattern/ImmutableEnumChecker)
    ```
---
 api/src/main/java/org/apache/iceberg/transforms/Dates.java      | 2 ++
 api/src/main/java/org/apache/iceberg/transforms/Timestamps.java | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/api/src/main/java/org/apache/iceberg/transforms/Dates.java b/api/src/main/java/org/apache/iceberg/transforms/Dates.java
index 9128f6c53f..3d26b542be 100644
--- a/api/src/main/java/org/apache/iceberg/transforms/Dates.java
+++ b/api/src/main/java/org/apache/iceberg/transforms/Dates.java
@@ -18,6 +18,7 @@
  */
 package org.apache.iceberg.transforms;
 
+import com.google.errorprone.annotations.Immutable;
 import java.time.temporal.ChronoUnit;
 import org.apache.iceberg.expressions.BoundPredicate;
 import org.apache.iceberg.expressions.BoundTransform;
@@ -35,6 +36,7 @@ enum Dates implements Transform<Integer, Integer> {
   MONTH(ChronoUnit.MONTHS, "month"),
   DAY(ChronoUnit.DAYS, "day");
 
+  @Immutable
   static class Apply implements SerializableFunction<Integer, Integer> {
     private final ChronoUnit granularity;
 
diff --git a/api/src/main/java/org/apache/iceberg/transforms/Timestamps.java b/api/src/main/java/org/apache/iceberg/transforms/Timestamps.java
index b148c23a5a..b5b50e9d42 100644
--- a/api/src/main/java/org/apache/iceberg/transforms/Timestamps.java
+++ b/api/src/main/java/org/apache/iceberg/transforms/Timestamps.java
@@ -18,6 +18,7 @@
  */
 package org.apache.iceberg.transforms;
 
+import com.google.errorprone.annotations.Immutable;
 import java.time.temporal.ChronoUnit;
 import org.apache.iceberg.expressions.BoundPredicate;
 import org.apache.iceberg.expressions.BoundTransform;
@@ -36,6 +37,7 @@ enum Timestamps implements Transform<Long, Integer> {
   DAY(ChronoUnit.DAYS, "day"),
   HOUR(ChronoUnit.HOURS, "hour");
 
+  @Immutable
   static class Apply implements SerializableFunction<Long, Integer> {
     private final ChronoUnit granularity;
 
@@ -66,7 +68,7 @@ enum Timestamps implements Transform<Long, Integer> {
 
   private final ChronoUnit granularity;
   private final String name;
-  private final SerializableFunction<Long, Integer> apply;
+  private final Apply apply;
 
   Timestamps(ChronoUnit granularity, String name) {
     this.granularity = granularity;