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

jialiang pushed a commit to branch upgrade/jdk-spring-dependencies
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to 
refs/heads/upgrade/jdk-spring-dependencies by this push:
     new cd036c9aff AMBARI-26203: Fix annotation processing issue in 
ConfigurationTest after JDK 17 upgrade (#3859)
cd036c9aff is described below

commit cd036c9afff39371ced1db0e0fc3b4f32377c38d
Author: jialiang <[email protected]>
AuthorDate: Mon Oct 28 14:01:57 2024 +0800

    AMBARI-26203: Fix annotation processing issue in ConfigurationTest after 
JDK 17 upgrade (#3859)
    
    * AMBARI-26203: Fix testAllPropertiesHaveMarkdownDescriptions failed
---
 .../apache/ambari/annotations/ClusterScale.java    | 36 +++++++++++++++
 .../ambari/annotations/ConfigurationMarkdown.java  | 54 ++++++++++++++++++++++
 .../ambari/server/configuration/Configuration.java | 47 ++-----------------
 .../src/main/resources/version_definition.xsd      | 12 +++--
 .../server/configuration/ConfigurationTest.java    |  3 +-
 .../AmbariManagementControllerImplTest.java        | 15 ------
 .../VersionDefinitionResourceProviderTest.java     |  2 +-
 7 files changed, 104 insertions(+), 65 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/annotations/ClusterScale.java 
b/ambari-server/src/main/java/org/apache/ambari/annotations/ClusterScale.java
new file mode 100644
index 0000000000..85457f7eb9
--- /dev/null
+++ 
b/ambari-server/src/main/java/org/apache/ambari/annotations/ClusterScale.java
@@ -0,0 +1,36 @@
+/*
+ * 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.ambari.annotations;
+
+import org.apache.ambari.server.configuration.Configuration;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * The {@link ClusterScale} class is a representation of the size of the
+ * cluster combined with a value. It's used to represent different
+ * configuration values depending on how many hosts are in the cluster.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD })
+public @interface ClusterScale {
+    Configuration.ClusterSizeType clusterSize();
+    String value();
+}
\ No newline at end of file
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/annotations/ConfigurationMarkdown.java
 
b/ambari-server/src/main/java/org/apache/ambari/annotations/ConfigurationMarkdown.java
new file mode 100644
index 0000000000..f03b807854
--- /dev/null
+++ 
b/ambari-server/src/main/java/org/apache/ambari/annotations/ConfigurationMarkdown.java
@@ -0,0 +1,54 @@
+/*
+ * 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.ambari.annotations;
+
+import org.apache.ambari.server.configuration.Configuration;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * The {@link ConfigurationMarkdown} is used to represent more complex
+ * Markdown for {@link Configuration.ConfigurationProperty} fields. It wraps 
the traditional
+ * {@link Markdown} along with extra metadata used to generate documentation.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD })
+public @interface ConfigurationMarkdown {
+    /**
+     * The base Markdown.
+     *
+     * @return
+     */
+    Markdown markdown();
+
+    /**
+     * The logic grouping that the configuration property belongs to.
+     *
+     * @return
+     */
+    Configuration.ConfigurationGrouping group();
+
+    /**
+     * All of the recommended values for the property based on cluster size.
+     *
+     * @return
+     */
+    ClusterScale[] scaleValues() default {};
+}
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index 12ba30a187..a6e5bcc1e7 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -55,6 +55,8 @@ import java.util.regex.Pattern;
 import org.apache.ambari.annotations.Experimental;
 import org.apache.ambari.annotations.ExperimentalFeature;
 import org.apache.ambari.annotations.Markdown;
+import org.apache.ambari.annotations.ConfigurationMarkdown;
+import org.apache.ambari.annotations.ClusterScale;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.actionmanager.CommandExecutionType;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
@@ -5994,7 +5996,7 @@ public class Configuration {
   /**
    * The {@link ConfigurationGrouping} represents a logical grouping of 
configurations.
    */
-  private enum ConfigurationGrouping {
+  public enum ConfigurationGrouping {
     /**
      * Alerts & Notifications.
      */
@@ -6032,7 +6034,7 @@ public class Configuration {
    * The {@link ClusterSizeType} is used to represent fixed sizes of clusters
    * for easy table generation when creating documentation.
    */
-  private enum ClusterSizeType {
+  public enum ClusterSizeType {
     /**
      * 10 Hosts.
      */
@@ -6076,47 +6078,6 @@ public class Configuration {
     }
   }
 
-  /**
-   * The {@link ConfigurationMarkdown} is used to represent more complex
-   * Markdown for {@link ConfigurationProperty} fields. It wraps the 
traditional
-   * {@link Markdown} along with extra metadata used to generate documentation.
-   */
-  @Retention(RetentionPolicy.RUNTIME)
-  @Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD })
-  @interface ConfigurationMarkdown {
-    /**
-     * The base Markdown.
-     *
-     * @return
-     */
-    Markdown markdown();
-
-    /**
-     * The logic grouping that the configuration property belongs to.
-     *
-     * @return
-     */
-    ConfigurationGrouping group();
-
-    /**
-     * All of the recommended values for the property based on cluster size.
-     *
-     * @return
-     */
-    ClusterScale[] scaleValues() default {};
-  }
-
-  /**
-   * The {@link ClusterScale} class is a representation of the size of the
-   * cluster combined with a value. It's used to represent different
-   * configuration values depending on how many hosts are in the cluster.
-   */
-  @Retention(RetentionPolicy.RUNTIME)
-  @Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD })
-  private @interface ClusterScale {
-    ClusterSizeType clusterSize();
-    String value();
-  }
 
   /**
    * Creates an AmbariKerberosAuthenticationProperties instance containing the 
Kerberos authentication-specific
diff --git a/ambari-server/src/main/resources/version_definition.xsd 
b/ambari-server/src/main/resources/version_definition.xsd
index 60e8209a9c..c92e0c9dc0 100644
--- a/ambari-server/src/main/resources/version_definition.xsd
+++ b/ambari-server/src/main/resources/version_definition.xsd
@@ -51,8 +51,10 @@
 
   <xs:simpleType name="family-type">
     <xs:restriction base="xs:string">
-
-      <xs:enumeration value="redhat6" />
+      <xs:enumeration value="redhat5" /><!--for test-->
+      <xs:enumeration value="centos5" /><!--for test-->
+      <xs:enumeration value="centos6" /><!--for test-->
+      <xs:enumeration value="redhat6" /><!--for test-->
       <xs:enumeration value="redhat7" />
       <xs:enumeration value="redhat8" />
       <xs:enumeration value="redhat9" />
@@ -60,14 +62,14 @@
       <xs:enumeration value="fedora38" />
       <xs:enumeration value="redhat-ppc6" />
       <xs:enumeration value="redhat-ppc7" />
-      <xs:enumeration value="debian6" /><!--      //test-->
+      <xs:enumeration value="debian6" /><!--for test-->
       <xs:enumeration value="debian10" />
       <xs:enumeration value="debian11" />
-      <xs:enumeration value="ubuntu14" /><!--      //test-->
+      <xs:enumeration value="ubuntu14" /><!--for test-->
       <xs:enumeration value="ubuntu20" />
       <xs:enumeration value="ubuntu22" />
       <xs:enumeration value="suse11" />
-      <xs:enumeration value="suse11sp3" /><!--      //test-->
+      <xs:enumeration value="suse11sp3" /><!--for test-->
       <xs:enumeration value="suse12" />
       <xs:enumeration value="amazonlinux2" />
       <xs:enumeration value="openeuler22" />
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
index 868f53045d..91c158e2fa 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
@@ -28,6 +28,7 @@ import static org.powermock.api.easymock.PowerMock.verifyAll;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.nio.charset.Charset;
@@ -36,8 +37,8 @@ import java.util.Map;
 import java.util.Properties;
 
 import org.apache.ambari.annotations.Markdown;
+import org.apache.ambari.annotations.ConfigurationMarkdown;
 import org.apache.ambari.server.AmbariException;
-import 
org.apache.ambari.server.configuration.Configuration.ConfigurationMarkdown;
 import 
org.apache.ambari.server.configuration.Configuration.ConfigurationProperty;
 import org.apache.ambari.server.configuration.Configuration.ConnectionPoolType;
 import org.apache.ambari.server.configuration.Configuration.DatabaseType;
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
index c34d3be0f9..64a0025576 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
@@ -176,31 +176,16 @@ public class AmbariManagementControllerImplTest {
         Class<?> c = controller.getClass();
         Field f = c.getDeclaredField("masterProtocol");
         f.setAccessible(true);
-
-        Field modifiersField = Field.class.getDeclaredField("modifiers");
-        modifiersField.setAccessible(true);
-        modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL);
-
         f.set(controller, masterProtocol);
 
         // masterHostname
         f = c.getDeclaredField("masterHostname");
         f.setAccessible(true);
-
-        modifiersField = Field.class.getDeclaredField("modifiers");
-        modifiersField.setAccessible(true);
-        modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL);
-
         f.set(controller, masterHostname);
 
         // masterPort
         f = c.getDeclaredField("masterPort");
         f.setAccessible(true);
-
-        modifiersField = Field.class.getDeclaredField("modifiers");
-        modifiersField.setAccessible(true);
-        modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL);
-
         f.set(controller, masterPort);
       }
     }
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProviderTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProviderTest.java
index 779f9c5f36..5e16cc50f3 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProviderTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProviderTest.java
@@ -280,7 +280,7 @@ public class VersionDefinitionResourceProviderTest {
         
VersionDefinitionResourceProvider.SHOW_AVAILABLE).equals("true").toPredicate();
 
     Set<Resource> results = versionProvider.getResources(getRequest, 
predicate);
-    Assert.assertEquals(3, results.size());
+    Assert.assertEquals(2, results.size());
 
     boolean found1 = false;
     boolean found2 = false;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to