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 2023/02/22 13:18:36 UTC

[iceberg] branch master updated: Core: Make Iceberg version in EnvironmentContext by default (#6831)

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 98c58f7b95 Core: Make Iceberg version in EnvironmentContext by default (#6831)
98c58f7b95 is described below

commit 98c58f7b9586b98b191cb36b88b33f857514b81b
Author: wangyinsheng <wy...@gmail.com>
AuthorDate: Wed Feb 22 21:18:28 2023 +0800

    Core: Make Iceberg version in EnvironmentContext by default (#6831)
---
 .../org/apache/iceberg/EnvironmentContext.java     |  8 +++---
 .../org/apache/iceberg/TestEnvironmentContext.java | 31 ++++++++++++++++++++++
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/core/src/main/java/org/apache/iceberg/EnvironmentContext.java b/core/src/main/java/org/apache/iceberg/EnvironmentContext.java
index 5a07da1040..1be0ecf231 100644
--- a/core/src/main/java/org/apache/iceberg/EnvironmentContext.java
+++ b/core/src/main/java/org/apache/iceberg/EnvironmentContext.java
@@ -26,12 +26,14 @@ public class EnvironmentContext {
   public static final String ENGINE_NAME = "engine-name";
   public static final String ENGINE_VERSION = "engine-version";
 
-  private EnvironmentContext() {
-    PROPERTIES.put("iceberg-version", IcebergBuild.fullVersion());
-  }
+  private EnvironmentContext() {}
 
   private static final Map<String, String> PROPERTIES = Maps.newConcurrentMap();
 
+  static {
+    PROPERTIES.put("iceberg-version", IcebergBuild.fullVersion());
+  }
+
   /**
    * Returns a {@link Map} of all properties.
    *
diff --git a/core/src/test/java/org/apache/iceberg/TestEnvironmentContext.java b/core/src/test/java/org/apache/iceberg/TestEnvironmentContext.java
new file mode 100644
index 0000000000..f6cb9c699b
--- /dev/null
+++ b/core/src/test/java/org/apache/iceberg/TestEnvironmentContext.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg;
+
+import org.assertj.core.api.Assertions;
+import org.junit.Test;
+
+public class TestEnvironmentContext {
+
+  @Test
+  public void testDefaultValue() {
+    Assertions.assertThat(EnvironmentContext.get().get("iceberg-version"))
+        .isEqualTo(IcebergBuild.fullVersion());
+  }
+}