You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by os...@apache.org on 2026/10/14 00:52:16 UTC
(cloudberry-pxf) branch main updated: PXF3: upgrade Spring Boot to 3.5.16 and Tomcat 10
This is an automated email from the ASF dual-hosted git repository.
ostinru pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry-pxf.git
The following commit(s) were added to refs/heads/main by this push:
new ba6de8df PXF3: upgrade Spring Boot to 3.5.16 and Tomcat 10
ba6de8df is described below
commit ba6de8dfb889ca9b752c1358c02f48d4920d895f
Author: Nikolay Antonov <os...@yandex-team.ru>
AuthorDate: Wed Oct 14 05:52:11 2026 +0500
PXF3: upgrade Spring Boot to 3.5.16 and Tomcat 10
## Summary
- Upgrade the server to Spring Boot 3.5.16, Spring Framework 6.2.19, and Tomcat 10.1.60 on the existing Java 17+.
- Migrate the service to Jakarta Servlet and JAXB APIs. Keep the legacy Servlet API available to the Hive 2 libraries.
- Move PXF HTTP metric tags to Spring's server request observation convention [(migration guide)](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#micrometer-and-metrics-changes).
- Update automation's Spring dependency.
## Migration details
- 3.0.13: Move the PXF web service to Tomcat 10.1 and Jakarta Servlet/JAXB APIs. Replace WebMvcTagsContributor with a server request observation convention while preserving PXF’s `user`, `segment`, `profile`, and `server` metric tags. Update the HTTP header size property and replace the old SLF4J MDC mock with Mockito static mocking. Keep the legacy `javax.servlet` dependency needed by Hive.
- 3.1.12: Remove explicit Mockito and Byte Buddy version overrides so the Spring Boot BOM manages them. Keep Apache HttpClient 4.5.14 explicitly associated with the AWS SDK dependencies.
- 3.2.12: Update the PropertiesLauncher class name used by the packaged service and switch the metrics integration test to `@AutoConfigureObservability`.
- 3.3.13: Update Prometheus assertions for the new scrape format. Adjust JSON error expectations to Jackson’s hardened output [(jackson change)](https://github.com/FasterXML/jackson-core/issues/991).
- 3.4.13: Replace `TaskExecutorBuilder` with `ThreadPoolTaskExecutorBuilder` for PXF’s response streaming executor, and use the new shutdown endpoint access property.
- 3.5.16: Align the PostgreSQL driver and automation’s Spring Beans dependency.
Spring Boot 3.5 upgrades JUnit 5 from 5.11.4 to 5.12.2. Gradle 8.14.4’s bundled test launcher cannot discover tests with the new version, so add junit-platform-launcher to the test runtime classpath. [(gradle best practices)](https://docs.gradle.org/8.14.4/userguide/upgrading_version_8.html).
---
automation/pom.xml | 12 +--
.../hbase/errors/hbaseIsDown/expected/query01.ans | 2 +-
.../json/malformed_record/expected/query01.ans | 68 +---------------
.../expected/query01.ans | 32 +-------
.../errors/incorrectProfile/expected/query01.ans | 2 +-
.../configuring/jdbc-connector/jdbc_cfg.md | 2 +-
pom.xml | 2 +-
server/build.gradle | 28 ++-----
server/gradle.properties | 2 +-
server/pxf-api/build.gradle | 1 -
server/pxf-hive/build.gradle | 2 +-
server/pxf-jdbc/build.gradle | 1 -
server/pxf-service/build.gradle | 3 +-
.../cloudberry/pxf/service/HttpHeaderDecoder.java | 2 +-
.../cloudberry/pxf/service/profile/Profile.java | 14 ++--
.../cloudberry/pxf/service/profile/Profiles.java | 8 +-
.../pxf/service/profile/ProfilesConf.java | 6 +-
.../pxf/service/rest/PxfBaseResource.java | 2 +-
.../pxf/service/rest/PxfLegacyResource.java | 2 +-
.../pxf/service/rest/PxfReadResource.java | 2 +-
.../pxf/service/rest/PxfWriteResource.java | 2 +-
.../pxf/service/spring/PxfConfiguration.java | 8 +-
.../spring/PxfContextMdcLogEnhancerFilter.java | 8 +-
.../pxf/service/spring/PxfExceptionHandler.java | 2 +-
... => PxfServerRequestObservationConvention.java} | 27 +++----
.../spring/PxfTomcatInitializationListener.java | 2 +-
.../src/main/resources/application.properties | 4 +-
.../cloudberry/pxf/service/PxfMetricsIT.java | 14 ++--
.../PxfContextMdcLogEnhancerDecoratorTest.java | 29 +++----
.../spring/PxfContextMdcLogEnhancerFilterTest.java | 92 +++++++++++-----------
.../service/spring/PxfExceptionHandlerTest.java | 2 +-
...PxfServerRequestObservationConventionTest.java} | 50 ++++++------
32 files changed, 151 insertions(+), 282 deletions(-)
diff --git a/automation/pom.xml b/automation/pom.xml
index b5f2ae46..8f3a7ff8 100644
--- a/automation/pom.xml
+++ b/automation/pom.xml
@@ -257,7 +257,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
- <version>42.7.2</version>
+ <version>42.7.13</version>
</dependency>
<dependency>
@@ -293,14 +293,8 @@
<dependency>
<groupId>org.springframework</groupId>
- <artifactId>spring</artifactId>
- <version>2.5.6</version>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- <version>5.3.33</version>
+ <artifactId>spring-beans</artifactId>
+ <version>6.2.19</version>
<scope>provided</scope>
</dependency>
diff --git a/automation/sqlrepo/features/hbase/errors/hbaseIsDown/expected/query01.ans b/automation/sqlrepo/features/hbase/errors/hbaseIsDown/expected/query01.ans
index a3a4c981..7210a349 100644
--- a/automation/sqlrepo/features/hbase/errors/hbaseIsDown/expected/query01.ans
+++ b/automation/sqlrepo/features/hbase/errors/hbaseIsDown/expected/query01.ans
@@ -11,4 +11,4 @@
--
-- end_matchsubs
SELECT * from pxf_not_exists_hbase_table ORDER BY recordkey;
-ERROR: remote component error (500) from 'SOME_IP:SOME_PORT': type Exception report message org.apache.hadoop.hbase.TableNotFoundException: dummy description The server encountered an internal error that prevented it from fulfilling this request. exception javax.servlet.ServletException: org.apache.hadoop.hbase.TableNotFoundException: dummy (libchurl.c:xxx)
+ERROR: remote component error (500) from 'SOME_IP:SOME_PORT': type Exception report message org.apache.hadoop.hbase.TableNotFoundException: dummy description The server encountered an internal error that prevented it from fulfilling this request. exception jakarta.servlet.ServletException: org.apache.hadoop.hbase.TableNotFoundException: dummy (libchurl.c:xxx)
diff --git a/automation/sqlrepo/features/hdfs/readable/json/malformed_record/expected/query01.ans b/automation/sqlrepo/features/hdfs/readable/json/malformed_record/expected/query01.ans
index 6cc611aa..09e3ce77 100644
--- a/automation/sqlrepo/features/hdfs/readable/json/malformed_record/expected/query01.ans
+++ b/automation/sqlrepo/features/hdfs/readable/json/malformed_record/expected/query01.ans
@@ -11,22 +11,7 @@ SELECT *
FROM jsontest_malformed_record
ORDER BY id;
ERROR: error while parsing json record 'Unexpected character (':' (code 58)): was expecting comma to separate Object entries
-
- at [Source: (String)"{
- "record":
- "created_at":"Fri Jun 07 22:45:02 +0000 2013",
- "id":343136547123646465,
- "id_str":"343136547123646465",
- "text":"text2",
- "source":"\u003ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c\/a\u003e",
- "user":{
- "id":102904200,
- "id_str":"102904200",
- "name":"Ardianto",
- "screen_name":"patronusdeadly",
- "location":"Bekasi-Surabaya"
- },
- "[truncated 73 chars]; line: 3, column: 22]'. invalid JSON record
+ at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 3, column: 21]'. invalid JSON record
{
"record":
"created_at":"Fri Jun 07 22:45:02 +0000 2013",
@@ -53,22 +38,7 @@ FROM jsontest_malformed_record
WHERE id IS NULL
ORDER BY id;
ERROR: error while parsing json record 'Unexpected character (':' (code 58)): was expecting comma to separate Object entries
-
- at [Source: (String)"{
- "record":
- "created_at":"Fri Jun 07 22:45:02 +0000 2013",
- "id":343136547123646465,
- "id_str":"343136547123646465",
- "text":"text2",
- "source":"\u003ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c\/a\u003e",
- "user":{
- "id":102904200,
- "id_str":"102904200",
- "name":"Ardianto",
- "screen_name":"patronusdeadly",
- "location":"Bekasi-Surabaya"
- },
- "[truncated 73 chars]; line: 3, column: 22]'. invalid JSON record
+ at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 3, column: 21]'. invalid JSON record
{
"record":
"created_at":"Fri Jun 07 22:45:02 +0000 2013",
@@ -95,22 +65,7 @@ SELECT *
FROM jsontest_malformed_record_filefrag
ORDER BY id;
ERROR: error while parsing json record 'Unexpected character (':' (code 58)): was expecting comma to separate Object entries
-
- at [Source: (String)"{
- "record":
- "created_at":"Fri Jun 07 22:45:02 +0000 2013",
- "id":343136547123646465,
- "id_str":"343136547123646465",
- "text":"text2",
- "source":"\u003ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c\/a\u003e",
- "user":{
- "id":102904200,
- "id_str":"102904200",
- "name":"Ardianto",
- "screen_name":"patronusdeadly",
- "location":"Bekasi-Surabaya"
- },
- "[truncated 73 chars]; line: 3, column: 22]'. invalid JSON record
+ at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 3, column: 21]'. invalid JSON record
{
"record":
"created_at":"Fri Jun 07 22:45:02 +0000 2013",
@@ -137,22 +92,7 @@ FROM jsontest_malformed_record_filefrag
WHERE id IS NULL
ORDER BY id;
ERROR: error while parsing json record 'Unexpected character (':' (code 58)): was expecting comma to separate Object entries
-
- at [Source: (String)"{
- "record":
- "created_at":"Fri Jun 07 22:45:02 +0000 2013",
- "id":343136547123646465,
- "id_str":"343136547123646465",
- "text":"text2",
- "source":"\u003ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c\/a\u003e",
- "user":{
- "id":102904200,
- "id_str":"102904200",
- "name":"Ardianto",
- "screen_name":"patronusdeadly",
- "location":"Bekasi-Surabaya"
- },
- "[truncated 73 chars]; line: 3, column: 22]'. invalid JSON record
+ at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 3, column: 21]'. invalid JSON record
{
"record":
"created_at":"Fri Jun 07 22:45:02 +0000 2013",
diff --git a/automation/sqlrepo/features/hdfs/readable/json/malformed_record_with_reject_limit/expected/query01.ans b/automation/sqlrepo/features/hdfs/readable/json/malformed_record_with_reject_limit/expected/query01.ans
index efbd0181..71916a01 100644
--- a/automation/sqlrepo/features/hdfs/readable/json/malformed_record_with_reject_limit/expected/query01.ans
+++ b/automation/sqlrepo/features/hdfs/readable/json/malformed_record_with_reject_limit/expected/query01.ans
@@ -20,21 +20,7 @@ FROM gp_read_error_log('jsontest_malformed_record_with_reject_limit');
relname | errmsg
---------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------
jsontest_malformed_record_with_reject_limit | error while parsing json record 'Unexpected character (':' (code 58)): was expecting comma to separate Object entries
- : at [Source: (String)"{
- : "record":
- : "created_at":"Fri Jun 07 22:45:02 +0000 2013",
- : "id":343136547123646465,
- : "id_str":"343136547123646465",
- : "text":"text2",
- : "source":"\u003ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c\/a\u003e",
- : "user":{
- : "id":102904200,
- : "id_str":"102904200",
- : "name":"Ardianto",
- : "screen_name":"patronusdeadly",
- : "location":"Bekasi-Surabaya"
- : },
- : "[truncated 73 chars]; line: 3, column: 22]'. invalid JSON record
+ : at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 3, column: 21]'. invalid JSON record
: {
: "record":
: "created_at":"Fri Jun 07 22:45:02 +0000 2013",
@@ -72,21 +58,7 @@ FROM gp_read_error_log('jsontest_malformed_record_with_reject_limit_filefrag');
relname | errmsg
------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------
jsontest_malformed_record_with_reject_limit_filefrag | error while parsing json record 'Unexpected character (':' (code 58)): was expecting comma to separate Object entries +
- | at [Source: (String)"{ +
- | "record": +
- | "created_at":"Fri Jun 07 22:45:02 +0000 2013", +
- | "id":343136547123646465, +
- | "id_str":"343136547123646465", +
- | "text":"text2", +
- | "source":"\u003ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c\/a\u003e",+
- | "user":{ +
- | "id":102904200, +
- | "id_str":"102904200", +
- | "name":"Ardianto", +
- | "screen_name":"patronusdeadly", +
- | "location":"Bekasi-Surabaya" +
- | }, +
- | "[truncated 73 chars]; line: 3, column: 22]'. invalid JSON record +
+ | at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 3, column: 21]'. invalid JSON record
| { +
| "record": +
| "created_at":"Fri Jun 07 22:45:02 +0000 2013", +
diff --git a/automation/sqlrepo/features/hive/errors/incorrectProfile/expected/query01.ans b/automation/sqlrepo/features/hive/errors/incorrectProfile/expected/query01.ans
index bb3e4048..3cefdfe8 100644
--- a/automation/sqlrepo/features/hive/errors/incorrectProfile/expected/query01.ans
+++ b/automation/sqlrepo/features/hive/errors/incorrectProfile/expected/query01.ans
@@ -13,4 +13,4 @@
-- s/DETAIL/GP_IGNORE: DETAIL/
-- end_matchsubs
SELECT * FROM pxf_hive_small_data ORDER BY t1;
-ERROR: remote component error (500) from 'SOME_IP:SOME_PORT': type Exception report message org.apache.hadoop.hbase.TableNotFoundException: hive_small_data description The server encountered an internal error that prevented it from fulfilling this request. exception javax.servlet.ServletException: org.apache.hadoop.hbase.TableNotFoundException: hive_small_data (libchurl.c:xxx)
+ERROR: remote component error (500) from 'SOME_IP:SOME_PORT': type Exception report message org.apache.hadoop.hbase.TableNotFoundException: hive_small_data description The server encountered an internal error that prevented it from fulfilling this request. exception jakarta.servlet.ServletException: org.apache.hadoop.hbase.TableNotFoundException: hive_small_data (libchurl.c:xxx)
diff --git a/docs/administering/configuring/jdbc-connector/jdbc_cfg.md b/docs/administering/configuring/jdbc-connector/jdbc_cfg.md
index 36e966e9..cc17d247 100644
--- a/docs/administering/configuring/jdbc-connector/jdbc_cfg.md
+++ b/docs/administering/configuring/jdbc-connector/jdbc_cfg.md
@@ -19,7 +19,7 @@ You can supply the JDBC driver class name, database URL, and client credentials
## JDBC Driver JAR Registration
-PXF is bundled with the `postgresql-42.7.2.jar` JAR file. If you require a different JDBC driver, ensure that you install the JDBC driver JAR file for the external SQL database in the `$PXF_BASE/lib` directory on each Apache Cloudberry host. Be sure to install JDBC driver JAR files that are compatible with your JRE version. See [Registering PXF Library Dependencies](../../../administering/reg_jar_depend.md) for additional information.
+PXF is bundled with the `postgresql-42.7.8.jar` JAR file. If you require a different JDBC driver, ensure that you install the JDBC driver JAR file for the external SQL database in the `$PXF_BASE/lib` directory on each Apache Cloudberry host. Be sure to install JDBC driver JAR files that are compatible with your JRE version. See [Registering PXF Library Dependencies](../../../administering/reg_jar_depend.md) for additional information.
## JDBC Server Configuration
diff --git a/pom.xml b/pom.xml
index d5c111b6..21b797e0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -244,7 +244,7 @@
<exclude>server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfThreadPoolTaskExecutor.java</exclude>
<exclude>server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfTomcatCustomizer.java</exclude>
<exclude>server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfTomcatInitializationListener.java</exclude>
- <exclude>server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfWebMvcTagsContributor.java</exclude>
+ <exclude>server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfServerRequestObservationConvention.java</exclude>
<exclude>server/doc/dependency_decisions.yml</exclude>
<exclude>server/doc/README.md</exclude>
<exclude>server/pxf-hdfs/build.gradle</exclude>
diff --git a/server/build.gradle b/server/build.gradle
index cd0cc0b7..f893fd68 100644
--- a/server/build.gradle
+++ b/server/build.gradle
@@ -29,10 +29,7 @@ plugins {
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}
-// override Spring Framework version to pick the Spring MVC 5.3.33 with the async race condition fix
-// https://github.com/spring-projects/spring-framework/issues/32342
-ext['spring-framework.version'] = '5.3.33'
-ext['tomcat.version'] = '9.0.118'
+ext['tomcat.version'] = '10.1.60'
def javaProjects = subprojects.findAll {
it.name.startsWith("pxf-")
@@ -118,14 +115,8 @@ configure(javaProjects) {
dependency("org.mortbay.jetty:jetty-util:6.1.26")
dependency("org.objenesis:objenesis:2.1")
- // revert once springboot provided postgresql is upgraded to bundle postgresql:42.7.2+
- dependency("org.postgresql:postgresql:42.7.2")
+ dependency("org.postgresql:postgresql:42.7.13")
- dependency("org.apache.tomcat.embed:tomcat-embed-core:9.0.118")
- dependency("org.apache.tomcat.embed:tomcat-embed-el:9.0.118")
- dependency("org.apache.tomcat.embed:tomcat-embed-websocket:9.0.118")
-
- dependency("org.simplify4u:slf4j-mock:2.3.0")
dependency("org.threeten:threeten-extra:1.5.0")
dependency("org.tukaani:xz:1.8")
dependency("org.wildfly.openssl:wildfly-openssl:1.0.7.Final")
@@ -235,21 +226,16 @@ configure(javaProjects) {
entry("aws-java-sdk-kms")
entry("aws-java-sdk-s3")
}
+ dependency("org.apache.httpcomponents:httpclient:4.5.14") // Used by AWS SDK
dependency("org.apache.logging.log4j:log4j-spring-boot:2.25.4")
-
- // JAVA 21 support
- dependencySet(group:"org.mockito", version:"4.11.0") {
- entry("mockito-core")
- entry("mockito-inline")
- }
- dependencySet(group:"net.bytebuddy", version:"1.14.19") {
- entry("byte-buddy")
- entry("byte-buddy-agent")
- }
}
}
+ dependencies {
+ testRuntimeOnly("org.junit.platform:junit-platform-launcher")
+ }
+
task removeIdeaOutDirectory(type: Delete) {
file("${projectDir}/out").deleteDir()
}
diff --git a/server/gradle.properties b/server/gradle.properties
index 9b3df9dd..27fc7f69 100644
--- a/server/gradle.properties
+++ b/server/gradle.properties
@@ -25,7 +25,7 @@ hbaseVersion=2.5.15
junitVersion=4.11
parquetVersion=1.15.2
awsJavaSdk=1.12.261
-springBootVersion=2.7.18
+springBootVersion=3.5.16
org.gradle.daemon=true
org.gradle.parallel=true
orcVersion=1.7.11
diff --git a/server/pxf-api/build.gradle b/server/pxf-api/build.gradle
index e4800084..aa830f23 100644
--- a/server/pxf-api/build.gradle
+++ b/server/pxf-api/build.gradle
@@ -52,7 +52,6 @@ dependencies {
testCompileOnly("org.apache.hadoop:hadoop-annotations")
testImplementation("com.esotericsoftware:minlog")
testImplementation("com.esotericsoftware:reflectasm")
- testImplementation('org.mockito:mockito-inline')
testImplementation('org.springframework.boot:spring-boot-starter-test')
}
diff --git a/server/pxf-hive/build.gradle b/server/pxf-hive/build.gradle
index 4f2ec65c..3e295381 100644
--- a/server/pxf-hive/build.gradle
+++ b/server/pxf-hive/build.gradle
@@ -29,6 +29,7 @@ dependencies {
implementation("org.apache.hive:hive-exec:${hiveVersion}:core") { transitive = false }
implementation("org.apache.hive:hive-metastore") { transitive = false }
implementation("org.apache.hive:hive-serde") { transitive = false }
+ implementation("javax.servlet:javax.servlet-api:4.0.1") { transitive = false }
implementation("com.esotericsoftware:kryo") { transitive = false }
/*******************************
@@ -69,7 +70,6 @@ dependencies {
*******************************/
testImplementation('org.springframework.boot:spring-boot-starter-test')
- testImplementation('org.mockito:mockito-inline')
}
test {
diff --git a/server/pxf-jdbc/build.gradle b/server/pxf-jdbc/build.gradle
index 9d050cf2..ce44148f 100644
--- a/server/pxf-jdbc/build.gradle
+++ b/server/pxf-jdbc/build.gradle
@@ -45,7 +45,6 @@ dependencies {
testImplementation("org.apache.parquet:parquet-pig")
testImplementation('org.springframework.boot:spring-boot-starter-test')
- testImplementation('org.mockito:mockito-inline')
}
test {
diff --git a/server/pxf-service/build.gradle b/server/pxf-service/build.gradle
index 69101bd2..97f7b08b 100644
--- a/server/pxf-service/build.gradle
+++ b/server/pxf-service/build.gradle
@@ -62,7 +62,6 @@ dependencies {
testCompileOnly("org.apache.hadoop:hadoop-annotations")
testImplementation("com.esotericsoftware:kryo")
testImplementation("commons-io:commons-io")
- testImplementation("org.simplify4u:slf4j-mock") // for MDC mocking
developmentOnly('org.springframework.boot:spring-boot-devtools')
testImplementation('org.springframework.boot:spring-boot-starter-test')
@@ -76,7 +75,7 @@ bootJar {
manifest {
attributes("Implementation-Title": project.name)
attributes("Implementation-Version": project.version)
- attributes('Main-Class': 'org.springframework.boot.loader.PropertiesLauncher')
+ attributes('Main-Class': 'org.springframework.boot.loader.launch.PropertiesLauncher')
}
}
diff --git a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/HttpHeaderDecoder.java b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/HttpHeaderDecoder.java
index a3d89319..50755236 100644
--- a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/HttpHeaderDecoder.java
+++ b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/HttpHeaderDecoder.java
@@ -5,7 +5,7 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
diff --git a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/profile/Profile.java b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/profile/Profile.java
index 637967ed..effdbf7b 100644
--- a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/profile/Profile.java
+++ b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/profile/Profile.java
@@ -2,13 +2,13 @@ package org.apache.cloudberry.pxf.service.profile;
import org.apache.commons.lang.StringUtils;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
+import jakarta.xml.bind.annotation.XmlAccessType;
+import jakarta.xml.bind.annotation.XmlAccessorType;
+import jakarta.xml.bind.annotation.XmlAttribute;
+import jakarta.xml.bind.annotation.XmlElement;
+import jakarta.xml.bind.annotation.XmlElementWrapper;
+import jakarta.xml.bind.annotation.XmlRootElement;
+import jakarta.xml.bind.annotation.XmlTransient;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
diff --git a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/profile/Profiles.java b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/profile/Profiles.java
index d4a9f4c4..55415622 100644
--- a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/profile/Profiles.java
+++ b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/profile/Profiles.java
@@ -1,9 +1,9 @@
package org.apache.cloudberry.pxf.service.profile;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
+import jakarta.xml.bind.annotation.XmlAccessType;
+import jakarta.xml.bind.annotation.XmlAccessorType;
+import jakarta.xml.bind.annotation.XmlElement;
+import jakarta.xml.bind.annotation.XmlRootElement;
import java.util.List;
/**
diff --git a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/profile/ProfilesConf.java b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/profile/ProfilesConf.java
index 2d3da97b..cf717dd0 100644
--- a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/profile/ProfilesConf.java
+++ b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/profile/ProfilesConf.java
@@ -28,9 +28,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
+import jakarta.xml.bind.JAXBContext;
+import jakarta.xml.bind.JAXBException;
+import jakarta.xml.bind.Unmarshaller;
import java.net.URL;
import java.util.List;
import java.util.Map;
diff --git a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfBaseResource.java b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfBaseResource.java
index 209b34dc..763fe19a 100644
--- a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfBaseResource.java
+++ b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfBaseResource.java
@@ -8,7 +8,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
/**
* Base class for PXF REST resources that provides unified error logging and wrapping.
diff --git a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfLegacyResource.java b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfLegacyResource.java
index 29d9daf6..e797d281 100644
--- a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfLegacyResource.java
+++ b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfLegacyResource.java
@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
/**
* Legacy PXF REST endpoint mapped to /pxf/v15 path
diff --git a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfReadResource.java b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfReadResource.java
index 80a17179..9e356a6c 100644
--- a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfReadResource.java
+++ b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfReadResource.java
@@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
/**
* PXF REST endpoint for read data requests.
diff --git a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfWriteResource.java b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfWriteResource.java
index 94fcb430..e4773601 100644
--- a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfWriteResource.java
+++ b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/rest/PxfWriteResource.java
@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
/**
* PXF REST endpoint for write data requests.
diff --git a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfConfiguration.java b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfConfiguration.java
index 357f4315..d52b74f1 100644
--- a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfConfiguration.java
+++ b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfConfiguration.java
@@ -7,8 +7,8 @@ import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.task.TaskExecutionProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.boot.task.TaskExecutorBuilder;
-import org.springframework.boot.task.TaskExecutorCustomizer;
+import org.springframework.boot.task.ThreadPoolTaskExecutorBuilder;
+import org.springframework.boot.task.ThreadPoolTaskExecutorCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncTaskExecutor;
@@ -64,12 +64,12 @@ public class PxfConfiguration implements WebMvcConfigurer {
@Bean(name = {PXF_RESPONSE_STREAM_TASK_EXECUTOR,
AsyncAnnotationBeanPostProcessor.DEFAULT_TASK_EXECUTOR_BEAN_NAME})
public ThreadPoolTaskExecutor pxfApplicationTaskExecutor(PxfServerProperties pxfServerProperties,
- ObjectProvider<TaskExecutorCustomizer> taskExecutorCustomizers,
+ ObjectProvider<ThreadPoolTaskExecutorCustomizer> taskExecutorCustomizers,
ObjectProvider<TaskDecorator> taskDecorator) {
TaskExecutionProperties properties = pxfServerProperties.getTask();
TaskExecutionProperties.Pool pool = properties.getPool();
- TaskExecutorBuilder builder = new TaskExecutorBuilder();
+ ThreadPoolTaskExecutorBuilder builder = new ThreadPoolTaskExecutorBuilder();
builder = builder.queueCapacity(pool.getQueueCapacity());
builder = builder.corePoolSize(pool.getCoreSize());
builder = builder.maxPoolSize(pool.getMaxSize());
diff --git a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfContextMdcLogEnhancerFilter.java b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfContextMdcLogEnhancerFilter.java
index a8d93050..9513868f 100644
--- a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfContextMdcLogEnhancerFilter.java
+++ b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfContextMdcLogEnhancerFilter.java
@@ -7,10 +7,10 @@ import org.slf4j.MDC;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
diff --git a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfExceptionHandler.java b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfExceptionHandler.java
index 84659b95..c6abf20f 100644
--- a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfExceptionHandler.java
+++ b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfExceptionHandler.java
@@ -5,7 +5,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
diff --git a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfWebMvcTagsContributor.java b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfServerRequestObservationConvention.java
similarity index 61%
rename from server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfWebMvcTagsContributor.java
rename to server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfServerRequestObservationConvention.java
index 3bcd5ea0..2b270eee 100644
--- a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfWebMvcTagsContributor.java
+++ b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfServerRequestObservationConvention.java
@@ -1,47 +1,40 @@
package org.apache.cloudberry.pxf.service.spring;
-import io.micrometer.core.instrument.Tag;
-import io.micrometer.core.instrument.Tags;
+import io.micrometer.common.KeyValues;
import org.apache.commons.lang.StringUtils;
import org.apache.cloudberry.pxf.service.HttpHeaderDecoder;
-import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsContributor;
+import org.springframework.http.server.observation.DefaultServerRequestObservationConvention;
+import org.springframework.http.server.observation.ServerRequestObservationContext;
import org.springframework.stereotype.Component;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
/**
- * Custom {@link WebMvcTagsContributor} that adds PXF specific tags to metrics for Spring MVC (REST endpoints)
- *
- * @return the {@link WebMvcTagsContributor} instance
+ * Adds PXF specific tags to HTTP server observations.
*/
@Component
-public class PxfWebMvcTagsContributor implements WebMvcTagsContributor {
+public class PxfServerRequestObservationConvention extends DefaultServerRequestObservationConvention {
private static final String UNKNOWN_VALUE = "unknown";
private final HttpHeaderDecoder decoder;
- public PxfWebMvcTagsContributor(HttpHeaderDecoder decoder) {
+ public PxfServerRequestObservationConvention(HttpHeaderDecoder decoder) {
this.decoder = decoder;
}
@Override
- public Iterable<Tag> getTags(HttpServletRequest request, HttpServletResponse response, Object handler, Throwable exception) {
+ public KeyValues getLowCardinalityKeyValues(ServerRequestObservationContext context) {
+ HttpServletRequest request = context.getCarrier();
// default server tag value to "default" if the request is from a PXF Client
// if request is not from PXF client, apply the same tags wth the value "unknown"
// because the Prometheus Metrics Registry requires a metric to have a consistent set of tags
boolean encoded = decoder.areHeadersEncoded(request);
String defaultServer = StringUtils.isNotBlank(request.getHeader("X-GP-USER")) ? "default" : UNKNOWN_VALUE;
- return Tags.empty()
+ return super.getLowCardinalityKeyValues(context)
.and("user", StringUtils.defaultIfBlank(decoder.getHeaderValue("X-GP-USER", request, encoded), UNKNOWN_VALUE))
.and("segment", StringUtils.defaultIfBlank(decoder.getHeaderValue("X-GP-SEGMENT-ID", request, encoded), UNKNOWN_VALUE))
.and("profile", StringUtils.defaultIfBlank(decoder.getHeaderValue("X-GP-OPTIONS-PROFILE", request, encoded), UNKNOWN_VALUE))
.and("server", StringUtils.defaultIfBlank(decoder.getHeaderValue("X-GP-OPTIONS-SERVER", request, encoded), defaultServer));
}
- @Override
- public Iterable<Tag> getLongRequestTags(HttpServletRequest request, Object handler) {
- return Tags.empty();
- }
-
}
diff --git a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfTomcatInitializationListener.java b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfTomcatInitializationListener.java
index c34ecd5d..4bc4f240 100644
--- a/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfTomcatInitializationListener.java
+++ b/server/pxf-service/src/main/java/org/apache/cloudberry/pxf/service/spring/PxfTomcatInitializationListener.java
@@ -40,7 +40,7 @@ public class PxfTomcatInitializationListener implements ApplicationListener<Serv
log.info(" - disableUploadTmeout ={}", nioHandler.getDisableUploadTimeout());
log.info(" - connectionUploadTmeout={}", nioHandler.getConnectionUploadTimeout());
log.info(" - maxHeaderCount ={}", nioHandler.getMaxHeaderCount());
- log.info(" - maxHttpHeaderSize ={}", nioHandler.getMaxHttpHeaderSize());
+ log.info(" - maxHttpRequestHeaderSize={}", nioHandler.getMaxHttpRequestHeaderSize());
log.info(" - maxThreads ={}", nioHandler.getMaxThreads());
log.info(" - minSpareThreads ={}", nioHandler.getMinSpareThreads());
}
diff --git a/server/pxf-service/src/main/resources/application.properties b/server/pxf-service/src/main/resources/application.properties
index 44e6a6b5..ddd56d5b 100644
--- a/server/pxf-service/src/main/resources/application.properties
+++ b/server/pxf-service/src/main/resources/application.properties
@@ -5,7 +5,7 @@
# 4. metrics: shows ‘metrics’ information for the application
# 5. prometheus: exposes metrics in a format that can be scraped by a Prometheus server
management.endpoints.web.exposure.include=health,info,shutdown,metrics,prometheus
-management.endpoint.shutdown.enabled=true
+management.endpoint.shutdown.access=unrestricted
management.endpoint.health.probes.enabled=true
# common tags applied to all metrics
@@ -32,7 +32,7 @@ server.error.include-stacktrace=on_param
server.error.include-exception=false
server.server-header=PXF Server
-server.max-http-header-size=${pxf.tomcat.max-header-size:1048576}
+server.max-http-request-header-size=${pxf.tomcat.max-header-size:1048576}
# tomcat specific
server.tomcat.threads.max=${pxf.max.threads:200}
diff --git a/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/PxfMetricsIT.java b/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/PxfMetricsIT.java
index 7c3f5484..2a5c8196 100644
--- a/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/PxfMetricsIT.java
+++ b/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/PxfMetricsIT.java
@@ -6,10 +6,9 @@ import org.apache.cloudberry.pxf.service.controller.ReadService;
import org.apache.cloudberry.pxf.service.controller.WriteService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledOnOs;
import org.mockito.Mock;
import org.mockito.stubbing.Answer;
-import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigureMetrics;
+import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.web.server.LocalServerPort;
@@ -20,7 +19,6 @@ import java.io.OutputStream;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.condition.OS.MAC;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.same;
@@ -28,9 +26,7 @@ import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.when;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = PxfServiceApplication.class)
-@AutoConfigureMetrics
-// on MacOS with Intel chip (and JDK 8) this test crashes the JVM. Commenting out for now to not run on Mac.
-@DisabledOnOs(MAC)
+@AutoConfigureObservability
public class PxfMetricsIT {
@LocalServerPort
@@ -119,9 +115,9 @@ public class PxfMetricsIT {
.expectStatus().isOk()
.expectBody(String.class).returnResult().getResponseBody();
assertNotNull(prometheusResponse);
- assertTrue(prometheusResponse.contains("http_server_requests_seconds_count{application=\"pxf-service\",exception=\"None\",method=\"GET\",outcome=\"SUCCESS\",profile=\"profile:test\",segment=\"77\",server=\"speedy\",status=\"200\",uri=\"/pxf/read\",user=\"reader\",} 1.0\n"));
- assertTrue(prometheusResponse.contains("http_server_requests_seconds_count{application=\"pxf-service\",exception=\"None\",method=\"POST\",outcome=\"SUCCESS\",profile=\"profile:test\",segment=\"77\",server=\"speedy\",status=\"200\",uri=\"/pxf/write\",user=\"writer\",} 1.0\n"));
- assertTrue(prometheusResponse.contains("http_server_requests_seconds_count{application=\"pxf-service\",exception=\"None\",method=\"GET\",outcome=\"SUCCESS\",profile=\"unknown\",segment=\"unknown\",server=\"unknown\",status=\"200\",uri=\"/actuator/health\",user=\"unknown\",} 1.0\n"));
+ assertTrue(prometheusResponse.contains("http_server_requests_seconds_count{application=\"pxf-service\",error=\"none\",exception=\"none\",method=\"GET\",outcome=\"SUCCESS\",profile=\"profile:test\",segment=\"77\",server=\"speedy\",status=\"200\",uri=\"/pxf/read\",user=\"reader\"} 1\n"));
+ assertTrue(prometheusResponse.contains("http_server_requests_seconds_count{application=\"pxf-service\",error=\"none\",exception=\"none\",method=\"POST\",outcome=\"SUCCESS\",profile=\"profile:test\",segment=\"77\",server=\"speedy\",status=\"200\",uri=\"/pxf/write\",user=\"writer\"} 1\n"));
+ assertTrue(prometheusResponse.contains("http_server_requests_seconds_count{application=\"pxf-service\",error=\"none\",exception=\"none\",method=\"GET\",outcome=\"SUCCESS\",profile=\"unknown\",segment=\"unknown\",server=\"unknown\",status=\"200\",uri=\"/actuator/health\",user=\"unknown\"} 1\n"));
}
private void mockServices() throws Exception {
diff --git a/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfContextMdcLogEnhancerDecoratorTest.java b/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfContextMdcLogEnhancerDecoratorTest.java
index 9103cda3..01655e47 100644
--- a/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfContextMdcLogEnhancerDecoratorTest.java
+++ b/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfContextMdcLogEnhancerDecoratorTest.java
@@ -4,24 +4,21 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
+import org.mockito.MockedStatic;
import org.mockito.junit.jupiter.MockitoExtension;
-import org.slf4j.spi.MDCAdapter;
+import org.slf4j.MDC;
import org.springframework.core.task.TaskDecorator;
import java.util.HashMap;
import java.util.Map;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
-
@ExtendWith(MockitoExtension.class)
class PxfContextMdcLogEnhancerDecoratorTest {
TaskDecorator decorator;
@Mock
- MDCAdapter mdcMock;
+ MockedStatic<MDC> mdcMock;
@BeforeEach
void setup() {
@@ -32,15 +29,15 @@ class PxfContextMdcLogEnhancerDecoratorTest {
void testDecorateWithoutContext() throws InterruptedException {
Map<String, String> contextMap = new HashMap<>();
- when(mdcMock.getCopyOfContextMap()).thenReturn(contextMap);
+ mdcMock.when(MDC::getCopyOfContextMap).thenReturn(contextMap);
Thread thread = new Thread(() -> System.out.println("Run"));
decorator.decorate(thread).run();
thread.join();
- verify(mdcMock).getCopyOfContextMap();
- verify(mdcMock).setContextMap(contextMap);
- verify(mdcMock).clear();
- verifyNoMoreInteractions(mdcMock);
+ mdcMock.verify(MDC::getCopyOfContextMap);
+ mdcMock.verify(() -> MDC.setContextMap(contextMap));
+ mdcMock.verify(MDC::clear);
+ mdcMock.verifyNoMoreInteractions();
}
@Test
@@ -48,14 +45,14 @@ class PxfContextMdcLogEnhancerDecoratorTest {
Map<String, String> contextMap = new HashMap<>();
contextMap.put("foo", "bar");
- when(mdcMock.getCopyOfContextMap()).thenReturn(contextMap);
+ mdcMock.when(MDC::getCopyOfContextMap).thenReturn(contextMap);
Thread thread = new Thread(() -> System.out.println("Run"));
decorator.decorate(thread).run();
thread.join();
- verify(mdcMock).getCopyOfContextMap();
- verify(mdcMock).setContextMap(contextMap);
- verify(mdcMock).clear();
- verifyNoMoreInteractions(mdcMock);
+ mdcMock.verify(MDC::getCopyOfContextMap);
+ mdcMock.verify(() -> MDC.setContextMap(contextMap));
+ mdcMock.verify(MDC::clear);
+ mdcMock.verifyNoMoreInteractions();
}
}
\ No newline at end of file
diff --git a/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfContextMdcLogEnhancerFilterTest.java b/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfContextMdcLogEnhancerFilterTest.java
index 18230611..faa48ce4 100644
--- a/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfContextMdcLogEnhancerFilterTest.java
+++ b/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfContextMdcLogEnhancerFilterTest.java
@@ -5,18 +5,16 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
+import org.mockito.MockedStatic;
import org.mockito.junit.jupiter.MockitoExtension;
-import org.slf4j.spi.MDCAdapter;
+import org.slf4j.MDC;
import org.springframework.mock.web.MockFilterChain;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
-import javax.servlet.ServletException;
+import jakarta.servlet.ServletException;
import java.io.IOException;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
@ExtendWith(MockitoExtension.class)
class PxfContextMdcLogEnhancerFilterTest {
@@ -26,7 +24,7 @@ class PxfContextMdcLogEnhancerFilterTest {
MockFilterChain mockFilterChain;
@Mock
- MDCAdapter mdcMock;
+ MockedStatic<MDC> mdcMock;
@BeforeEach
void setup() {
@@ -40,11 +38,11 @@ class PxfContextMdcLogEnhancerFilterTest {
void testNonPxfContextRequest() throws ServletException, IOException {
filter.doFilter(mockRequest, mockResponse, mockFilterChain);
// always removes
- verify(mdcMock).remove("segmentId");
- verify(mdcMock).remove("sessionId");
- verify(mdcMock).remove("ssid");
- verify(mdcMock).remove("ccnt");
- verifyNoMoreInteractions(mdcMock);
+ mdcMock.verify(() -> MDC.remove("segmentId"));
+ mdcMock.verify(() -> MDC.remove("sessionId"));
+ mdcMock.verify(() -> MDC.remove("ssid"));
+ mdcMock.verify(() -> MDC.remove("ccnt"));
+ mdcMock.verifyNoMoreInteractions();
}
@Test
@@ -54,16 +52,16 @@ class PxfContextMdcLogEnhancerFilterTest {
mockRequest.addHeader("X-GP-SEGMENT-ID", "5");
filter.doFilter(mockRequest, mockResponse, mockFilterChain);
- verify(mdcMock).put("sessionId", "transaction:id:default");
- verify(mdcMock).put("segmentId", "5");
- verify(mdcMock).put("ssid", null);
- verify(mdcMock).put("ccnt", null);
+ mdcMock.verify(() -> MDC.put("sessionId", "transaction:id:default"));
+ mdcMock.verify(() -> MDC.put("segmentId", "5"));
+ mdcMock.verify(() -> MDC.put("ssid", null));
+ mdcMock.verify(() -> MDC.put("ccnt", null));
- verify(mdcMock).remove("segmentId");
- verify(mdcMock).remove("sessionId");
- verify(mdcMock).remove("ssid");
- verify(mdcMock).remove("ccnt");
- verifyNoMoreInteractions(mdcMock);
+ mdcMock.verify(() -> MDC.remove("segmentId"));
+ mdcMock.verify(() -> MDC.remove("sessionId"));
+ mdcMock.verify(() -> MDC.remove("ssid"));
+ mdcMock.verify(() -> MDC.remove("ccnt"));
+ mdcMock.verifyNoMoreInteractions();
}
@Test
@@ -74,16 +72,16 @@ class PxfContextMdcLogEnhancerFilterTest {
mockRequest.addHeader("X-GP-SEGMENT-ID", "5");
filter.doFilter(mockRequest, mockResponse, mockFilterChain);
- verify(mdcMock).put("sessionId", "transaction:id:s3");
- verify(mdcMock).put("segmentId", "5");
- verify(mdcMock).put("ssid", null);
- verify(mdcMock).put("ccnt", null);
+ mdcMock.verify(() -> MDC.put("sessionId", "transaction:id:s3"));
+ mdcMock.verify(() -> MDC.put("segmentId", "5"));
+ mdcMock.verify(() -> MDC.put("ssid", null));
+ mdcMock.verify(() -> MDC.put("ccnt", null));
- verify(mdcMock).remove("segmentId");
- verify(mdcMock).remove("sessionId");
- verify(mdcMock).remove("ssid");
- verify(mdcMock).remove("ccnt");
- verifyNoMoreInteractions(mdcMock);
+ mdcMock.verify(() -> MDC.remove("segmentId"));
+ mdcMock.verify(() -> MDC.remove("sessionId"));
+ mdcMock.verify(() -> MDC.remove("ssid"));
+ mdcMock.verify(() -> MDC.remove("ccnt"));
+ mdcMock.verifyNoMoreInteractions();
}
@Test
@@ -95,16 +93,16 @@ class PxfContextMdcLogEnhancerFilterTest {
mockRequest.addHeader("X-GP-COMMAND-COUNT", "7");
filter.doFilter(mockRequest, mockResponse, mockFilterChain);
- verify(mdcMock).put("sessionId", "transaction:id:default");
- verify(mdcMock).put("segmentId", "5");
- verify(mdcMock).put("ssid", "12345");
- verify(mdcMock).put("ccnt", "7");
+ mdcMock.verify(() -> MDC.put("sessionId", "transaction:id:default"));
+ mdcMock.verify(() -> MDC.put("segmentId", "5"));
+ mdcMock.verify(() -> MDC.put("ssid", "12345"));
+ mdcMock.verify(() -> MDC.put("ccnt", "7"));
- verify(mdcMock).remove("segmentId");
- verify(mdcMock).remove("sessionId");
- verify(mdcMock).remove("ssid");
- verify(mdcMock).remove("ccnt");
- verifyNoMoreInteractions(mdcMock);
+ mdcMock.verify(() -> MDC.remove("segmentId"));
+ mdcMock.verify(() -> MDC.remove("sessionId"));
+ mdcMock.verify(() -> MDC.remove("ssid"));
+ mdcMock.verify(() -> MDC.remove("ccnt"));
+ mdcMock.verifyNoMoreInteractions();
}
@Test
@@ -115,15 +113,15 @@ class PxfContextMdcLogEnhancerFilterTest {
mockRequest.addHeader("X-GP-SEGMENT-ID", "5");
filter.doFilter(mockRequest, mockResponse, mockFilterChain);
- verify(mdcMock).put("sessionId", "transaction:id:default");
- verify(mdcMock).put("segmentId", "5");
- verify(mdcMock).put("ssid", null);
- verify(mdcMock).put("ccnt", null);
+ mdcMock.verify(() -> MDC.put("sessionId", "transaction:id:default"));
+ mdcMock.verify(() -> MDC.put("segmentId", "5"));
+ mdcMock.verify(() -> MDC.put("ssid", null));
+ mdcMock.verify(() -> MDC.put("ccnt", null));
- verify(mdcMock).remove("segmentId");
- verify(mdcMock).remove("sessionId");
- verify(mdcMock).remove("ssid");
- verify(mdcMock).remove("ccnt");
- verifyNoMoreInteractions(mdcMock);
+ mdcMock.verify(() -> MDC.remove("segmentId"));
+ mdcMock.verify(() -> MDC.remove("sessionId"));
+ mdcMock.verify(() -> MDC.remove("ssid"));
+ mdcMock.verify(() -> MDC.remove("ccnt"));
+ mdcMock.verifyNoMoreInteractions();
}
}
\ No newline at end of file
diff --git a/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfExceptionHandlerTest.java b/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfExceptionHandlerTest.java
index 42f0fe61..ee2661b3 100644
--- a/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfExceptionHandlerTest.java
+++ b/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfExceptionHandlerTest.java
@@ -7,7 +7,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertEquals;
diff --git a/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfWebMvcTagsContributorTest.java b/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfServerRequestObservationConventionTest.java
similarity index 53%
rename from server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfWebMvcTagsContributorTest.java
rename to server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfServerRequestObservationConventionTest.java
index 501e2d9c..d0225e13 100644
--- a/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfWebMvcTagsContributorTest.java
+++ b/server/pxf-service/src/test/java/org/apache/cloudberry/pxf/service/spring/PxfServerRequestObservationConventionTest.java
@@ -1,28 +1,28 @@
package org.apache.cloudberry.pxf.service.spring;
-import io.micrometer.core.instrument.Tag;
-import io.micrometer.core.instrument.Tags;
-import org.apache.commons.collections.CollectionUtils;
+import io.micrometer.common.KeyValue;
+import io.micrometer.common.KeyValues;
import org.apache.cloudberry.pxf.service.HttpHeaderDecoder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.springframework.http.server.observation.ServerRequestObservationContext;
import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
-import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
-public class PxfWebMvcTagsContributorTest {
+public class PxfServerRequestObservationConventionTest {
- private PxfWebMvcTagsContributor contributor;
+ private PxfServerRequestObservationConvention contributor;
private MockHttpServletRequest mockRequest;
@BeforeEach
public void setup() {
- contributor = new PxfWebMvcTagsContributor(new HttpHeaderDecoder());
+ contributor = new PxfServerRequestObservationConvention(new HttpHeaderDecoder());
mockRequest = new MockHttpServletRequest();
}
@@ -33,17 +33,16 @@ public class PxfWebMvcTagsContributorTest {
mockRequest.addHeader("X-GP-OPTIONS-PROFILE", "test:text");
mockRequest.addHeader("X-GP-OPTIONS-SERVER", "test_server");
- List<Tag> expectedTags = Tags.of("user", "Alex")
+ List<KeyValue> expectedTags = KeyValues.of("user", "Alex")
.and("segment", "5")
.and("profile", "test:text")
.and("server", "test_server")
.stream().collect(Collectors.toList());
- Iterable<Tag> tagsIterable = contributor.getTags(mockRequest, null, null, null);
- List<Tag> tags = StreamSupport.stream(tagsIterable.spliterator(), false).collect(Collectors.toList());
+ Iterable<KeyValue> tagsIterable = contributor.getLowCardinalityKeyValues(new ServerRequestObservationContext(mockRequest, new MockHttpServletResponse()));
+ List<KeyValue> tags = StreamSupport.stream(tagsIterable.spliterator(), false).collect(Collectors.toList());
- assertTrue(CollectionUtils.isEqualCollection(expectedTags, tags));
- assertFalse(contributor.getLongRequestTags(mockRequest, null).iterator().hasNext());
+ assertTrue(tags.containsAll(expectedTags));
}
@Test
@@ -52,17 +51,16 @@ public class PxfWebMvcTagsContributorTest {
mockRequest.addHeader("X-GP-SEGMENT-ID", "5");
mockRequest.addHeader("X-GP-OPTIONS-PROFILE", "test:text");
- List<Tag> expectedTags = Tags.of("user", "Alex")
+ List<KeyValue> expectedTags = KeyValues.of("user", "Alex")
.and("segment", "5")
.and("profile", "test:text")
.and("server", "default")
.stream().collect(Collectors.toList());
- Iterable<Tag> tagsIterable = contributor.getTags(mockRequest, null, null, null);
- List<Tag> tags = StreamSupport.stream(tagsIterable.spliterator(), false).collect(Collectors.toList());
+ Iterable<KeyValue> tagsIterable = contributor.getLowCardinalityKeyValues(new ServerRequestObservationContext(mockRequest, new MockHttpServletResponse()));
+ List<KeyValue> tags = StreamSupport.stream(tagsIterable.spliterator(), false).collect(Collectors.toList());
- assertTrue(CollectionUtils.isEqualCollection(expectedTags, tags));
- assertFalse(contributor.getLongRequestTags(mockRequest, null).iterator().hasNext());
+ assertTrue(tags.containsAll(expectedTags));
}
@Test
@@ -73,32 +71,30 @@ public class PxfWebMvcTagsContributorTest {
mockRequest.addHeader("X-GP-OPTIONS-PROFILE", "test%3Atext");
mockRequest.addHeader("X-GP-OPTIONS-SERVER", "test_server");
- List<Tag> expectedTags = Tags.of("user", "Alex")
+ List<KeyValue> expectedTags = KeyValues.of("user", "Alex")
.and("segment", "5")
.and("profile", "test:text")
.and("server", "test_server")
.stream().collect(Collectors.toList());
- Iterable<Tag> tagsIterable = contributor.getTags(mockRequest, null, null, null);
- List<Tag> tags = StreamSupport.stream(tagsIterable.spliterator(), false).collect(Collectors.toList());
+ Iterable<KeyValue> tagsIterable = contributor.getLowCardinalityKeyValues(new ServerRequestObservationContext(mockRequest, new MockHttpServletResponse()));
+ List<KeyValue> tags = StreamSupport.stream(tagsIterable.spliterator(), false).collect(Collectors.toList());
- assertTrue(CollectionUtils.isEqualCollection(expectedTags, tags));
- assertFalse(contributor.getLongRequestTags(mockRequest, null).iterator().hasNext());
+ assertTrue(tags.containsAll(expectedTags));
}
@Test
public void testPxfWebMvcTagsContributor_nonPxfEndpoint() {
- List<Tag> expectedTags = Tags.of("user", "unknown")
+ List<KeyValue> expectedTags = KeyValues.of("user", "unknown")
.and("segment", "unknown")
.and("profile", "unknown")
.and("server", "unknown")
.stream().collect(Collectors.toList());
- Iterable<Tag> tagsIterable = contributor.getTags(mockRequest, null, null, null);
- List<Tag> tags = StreamSupport.stream(tagsIterable.spliterator(), false).collect(Collectors.toList());
+ Iterable<KeyValue> tagsIterable = contributor.getLowCardinalityKeyValues(new ServerRequestObservationContext(mockRequest, new MockHttpServletResponse()));
+ List<KeyValue> tags = StreamSupport.stream(tagsIterable.spliterator(), false).collect(Collectors.toList());
- assertTrue(CollectionUtils.isEqualCollection(expectedTags, tags));
- assertFalse(contributor.getLongRequestTags(mockRequest, null).iterator().hasNext());
+ assertTrue(tags.containsAll(expectedTags));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org