From 1f2057cfb771b881e7b29e2949aa4d5e84339ca7 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme Date: Mon, 19 Feb 2024 20:55:56 -0500 Subject: [PATCH 01/17] Refactor to use virtual threads --- .../v3/core/filter/SpecFilterTest.java | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java index 6f32a71c09..fc1873e1b8 100644 --- a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java +++ b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java @@ -170,47 +170,46 @@ private void validateParameters(Operation operation) { } } } - + @Test(description = "it should clone everything concurrently") public void cloneEverythingConcurrent() throws IOException { + int numThreads = 10; + final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH); - ThreadGroup tg = new ThreadGroup("SpecFilterTest" + "|" + System.currentTimeMillis()); final Map filteredMap = new ConcurrentHashMap<>(); + + Thread[] threads = new Thread[numThreads]; + for (int i = 0; i < numThreads; i++) { final int id = i; - new Thread(tg, "SpecFilterTest") { - public void run() { - try { - filteredMap.put("filtered " + id, new SpecFilter().filter(openAPI, new NoOpOperationsFilter(), null, null, null)); - } catch (Exception e) { - e.printStackTrace(); - } + threads[i] = Thread.ofVirtual().start(() -> { + try { + filteredMap.put("filtered " + id, new SpecFilter().filter(openAPI, new NoOpOperationsFilter(), null, null, null)); + } catch (Exception e) { + e.printStackTrace(); } - }.start(); + }); } - - new Thread(new FailureHandler(tg, filteredMap, openAPI)).start(); + Thread.ofVirtual().start(new FailureHandler(threads, filteredMap, openAPI)); } class FailureHandler implements Runnable { - ThreadGroup tg; + Thread[] threads; Map filteredMap; private OpenAPI openAPI; - private FailureHandler(ThreadGroup tg, Map filteredMap, OpenAPI openAPI) { - this.tg = tg; - this.filteredMap = filteredMap; + private FailureHandler(Thread[] threads, Map filteredMap, OpenAPI openAPI) { + this.threads = threads; + this.filteredMap = filteredMap; this.openAPI = openAPI; } @Override public void run() { try { - Thread[] thds = new Thread[tg.activeCount()]; - tg.enumerate(thds); - for (Thread t : thds) { + for (Thread t : threads) { if (t != null) { t.join(10000); } From cc087b5bf7f1e95a59bcc9e56f3e074a6482b73b Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Mon, 19 Feb 2024 21:04:20 -0500 Subject: [PATCH 02/17] Update maven-pulls.yml --- .github/workflows/maven-pulls.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven-pulls.yml b/.github/workflows/maven-pulls.yml index baf951c679..d6fec76298 100644 --- a/.github/workflows/maven-pulls.yml +++ b/.github/workflows/maven-pulls.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [ 11, 14, 17 ] + java: [ 21 ] steps: - uses: actions/checkout@v2 From 7b7a738b0b365b59708df8423dc93f9ca379f26c Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Tue, 20 Feb 2024 17:16:16 -0500 Subject: [PATCH 03/17] Update build.gradle --- modules/swagger-gradle-plugin/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-gradle-plugin/build.gradle b/modules/swagger-gradle-plugin/build.gradle index 6f5ff46769..7d7d2420ed 100644 --- a/modules/swagger-gradle-plugin/build.gradle +++ b/modules/swagger-gradle-plugin/build.gradle @@ -19,7 +19,7 @@ repositories { } compileJava { - options.release = 8 + options.release = 21 } dependencies { From 7a57fc5f29b38ba4066b0039fb46a1c3b4bb8f65 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Tue, 20 Feb 2024 17:48:28 -0500 Subject: [PATCH 04/17] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bfb5c7978d..978921ce22 100644 --- a/pom.xml +++ b/pom.xml @@ -627,7 +627,7 @@ - 8 + 21 2.2.3 2.12.5 2.2 From 41653a93c3fa29061ff655c27ea11d36a8fbd3c1 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Tue, 20 Feb 2024 22:28:24 -0500 Subject: [PATCH 05/17] Update pom.xml --- modules/swagger-maven-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-maven-plugin/pom.xml b/modules/swagger-maven-plugin/pom.xml index af7252d3b8..7afa0b4dd1 100644 --- a/modules/swagger-maven-plugin/pom.xml +++ b/modules/swagger-maven-plugin/pom.xml @@ -29,7 +29,7 @@ org.apache.maven.plugins maven-plugin-plugin - 3.7.0 + 3.11.0 io.swagger.core.v3 From 2d6f5fbc6f9b88fc47ad01b0b704c9c8e9762f98 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Tue, 20 Feb 2024 22:36:00 -0500 Subject: [PATCH 06/17] Update pom.xml --- modules/swagger-eclipse-transformer-maven-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-eclipse-transformer-maven-plugin/pom.xml b/modules/swagger-eclipse-transformer-maven-plugin/pom.xml index 8fc5d3bd3a..7c8a9e51ac 100644 --- a/modules/swagger-eclipse-transformer-maven-plugin/pom.xml +++ b/modules/swagger-eclipse-transformer-maven-plugin/pom.xml @@ -39,7 +39,7 @@ org.apache.maven.plugins maven-plugin-plugin - 3.6.4 + 3.11.0 transform From fce6a364b23420d7afbcbf575c6ff04e9285859d Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Tue, 20 Feb 2024 22:44:26 -0500 Subject: [PATCH 07/17] Update pom.xml --- modules/swagger-maven-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-maven-plugin/pom.xml b/modules/swagger-maven-plugin/pom.xml index 7afa0b4dd1..0501bcd5be 100644 --- a/modules/swagger-maven-plugin/pom.xml +++ b/modules/swagger-maven-plugin/pom.xml @@ -17,7 +17,7 @@ org.codehaus.plexus plexus-component-metadata - 2.0.0 + 2.2.0 From 3b7f861595e82e25c6bf8482509109f4e6e1bd21 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Tue, 20 Feb 2024 22:49:59 -0500 Subject: [PATCH 08/17] Update pom.xml --- .../modules/swagger-maven-plugin-jakarta/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-project-jakarta/modules/swagger-maven-plugin-jakarta/pom.xml b/modules/swagger-project-jakarta/modules/swagger-maven-plugin-jakarta/pom.xml index 2f1ab9219b..1656c04153 100644 --- a/modules/swagger-project-jakarta/modules/swagger-maven-plugin-jakarta/pom.xml +++ b/modules/swagger-project-jakarta/modules/swagger-maven-plugin-jakarta/pom.xml @@ -88,7 +88,7 @@ org.apache.maven.plugins maven-plugin-plugin - 3.7.0 + 3.11.0 true From 9e8068c3e9cafe7ee36ae7070b1fe3d9f97ad3f6 Mon Sep 17 00:00:00 2001 From: Benjamin Prud'homme <139664105+bgprudhomme@users.noreply.github.com> Date: Tue, 20 Feb 2024 23:01:37 -0500 Subject: [PATCH 09/17] Update pom.xml --- .../modules/swagger-maven-plugin-jakarta/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/swagger-project-jakarta/modules/swagger-maven-plugin-jakarta/pom.xml b/modules/swagger-project-jakarta/modules/swagger-maven-plugin-jakarta/pom.xml index 1656c04153..ca2661d812 100644 --- a/modules/swagger-project-jakarta/modules/swagger-maven-plugin-jakarta/pom.xml +++ b/modules/swagger-project-jakarta/modules/swagger-maven-plugin-jakarta/pom.xml @@ -92,6 +92,7 @@ true + descriptor From 8b9215e77c4cad4ae784ff1b9b58db4ce1230e06 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 21 Feb 2024 09:34:51 -0500 Subject: [PATCH 10/17] Remove whitespace errors. --- .../io/swagger/v3/core/filter/SpecFilterTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java index fc1873e1b8..651fa42558 100644 --- a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java +++ b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java @@ -170,18 +170,18 @@ private void validateParameters(Operation operation) { } } } - + @Test(description = "it should clone everything concurrently") public void cloneEverythingConcurrent() throws IOException { - + int numThreads = 10; - + final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH); final Map filteredMap = new ConcurrentHashMap<>(); - + Thread[] threads = new Thread[numThreads]; - + for (int i = 0; i < numThreads; i++) { final int id = i; threads[i] = Thread.ofVirtual().start(() -> { @@ -192,7 +192,7 @@ public void cloneEverythingConcurrent() throws IOException { } }); } - Thread.ofVirtual().start(new FailureHandler(threads, filteredMap, openAPI)); + Thread.ofVirtual().start(new FailureHandler(threads, filteredMap, openAPI)); } class FailureHandler implements Runnable { From 784ef90feb64b9111559d5af7d12980680d73c4c Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 21 Feb 2024 09:35:38 -0500 Subject: [PATCH 11/17] Remove added whitespace. Let's keep the changes focused. --- .../src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java index 651fa42558..145ce9e9cf 100644 --- a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java +++ b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java @@ -173,9 +173,7 @@ private void validateParameters(Operation operation) { @Test(description = "it should clone everything concurrently") public void cloneEverythingConcurrent() throws IOException { - int numThreads = 10; - final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH); final Map filteredMap = new ConcurrentHashMap<>(); From aee79306ae31d98a9dce0f75b5c3df52b7c63898 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 21 Feb 2024 09:36:25 -0500 Subject: [PATCH 12/17] Minimalize the changes. --- .../test/java/io/swagger/v3/core/filter/SpecFilterTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java index 145ce9e9cf..212d85b781 100644 --- a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java +++ b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java @@ -176,9 +176,8 @@ public void cloneEverythingConcurrent() throws IOException { int numThreads = 10; final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH); - final Map filteredMap = new ConcurrentHashMap<>(); - Thread[] threads = new Thread[numThreads]; + final Map filteredMap = new ConcurrentHashMap<>(); for (int i = 0; i < numThreads; i++) { final int id = i; From e02b451a575caf526e3d801b4e4e0a36347fc3a8 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 21 Feb 2024 09:44:52 -0500 Subject: [PATCH 13/17] Keep the thread name. --- .../src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java index 212d85b781..f38c4b61c7 100644 --- a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java +++ b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java @@ -181,7 +181,7 @@ public void cloneEverythingConcurrent() throws IOException { for (int i = 0; i < numThreads; i++) { final int id = i; - threads[i] = Thread.ofVirtual().start(() -> { + threads[i] = Thread.ofVirtual().name("SpecFilterTest").start(() -> { try { filteredMap.put("filtered " + id, new SpecFilter().filter(openAPI, new NoOpOperationsFilter(), null, null, null)); } catch (Exception e) { From 80c539c992902ece9ae7c01efb04e8f573cf93fa Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 21 Feb 2024 15:44:09 -0500 Subject: [PATCH 14/17] Fix formatting. --- .../test/java/io/swagger/v3/core/filter/SpecFilterTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java index f1c46524ea..6119e14ff6 100644 --- a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java +++ b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java @@ -194,13 +194,14 @@ public void cloneEverythingConcurrent() throws IOException { for (int i = 0; i < numThreads; i++) { final int id = i; threads[i] = Thread.ofVirtual().name("SpecFilterTest").start(() -> { - try { + try { filteredMap.put("filtered " + id, new SpecFilter().filter(openAPI, new NoOpOperationsFilter(), null, null, null)); } catch (Exception e) { e.printStackTrace(); } }); } + Thread.ofVirtual().start(new FailureHandler(threads, filteredMap, openAPI)); } @@ -211,7 +212,7 @@ class FailureHandler implements Runnable { private FailureHandler(Thread[] threads, Map filteredMap, OpenAPI openAPI) { this.threads = threads; - this.filteredMap = filteredMap; + this.filteredMap = filteredMap; this.openAPI = openAPI; } From 8ec3bb8e646a4e5a1b25c604f3eca9f662c13fe6 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Wed, 21 Feb 2024 15:45:16 -0500 Subject: [PATCH 15/17] Fix formatting. --- .../test/java/io/swagger/v3/core/filter/SpecFilterTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java index 6119e14ff6..3d8c8121ad 100644 --- a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java +++ b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java @@ -177,8 +177,8 @@ private void validateParameters(Operation operation) { @Setup(Level.Trial) public void setUp() throws IOException { - // RK: Move I/O outside the benchmark to reduce variability. - openAPI = getOpenAPI(RESOURCE_PATH); + // RK: Move I/O outside the benchmark to reduce variability. + openAPI = getOpenAPI(RESOURCE_PATH); } // @Param({"10", "100", "1000"}) @@ -206,7 +206,7 @@ public void cloneEverythingConcurrent() throws IOException { } class FailureHandler implements Runnable { - Thread[] threads; + Thread[] threads; Map filteredMap; private OpenAPI openAPI; From 68270ffded7649dbdcb3bea2b0aaf63ed0ef0402 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Tue, 12 Nov 2024 15:17:16 -0500 Subject: [PATCH 16/17] Remove whitespace. --- .../src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java index fd9bbd673d..0dc9dd8e02 100644 --- a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java +++ b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java @@ -189,7 +189,6 @@ public void setUp() throws IOException { public void cloneEverythingConcurrent() throws IOException { Thread[] threads = new Thread[numThreads]; final Map filteredMap = new ConcurrentHashMap<>(); - for (int i = 0; i < numThreads; i++) { final int id = i; threads[i] = Thread.ofVirtual().name("SpecFilterTest").start(() -> { From ca849452f6da9409812cff8b8f05a5727e1db434 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Tue, 12 Nov 2024 15:33:26 -0500 Subject: [PATCH 17/17] Revert "Update SpecFilterTest.java" This reverts commit 6a8c9db489d78db9fc6bc96a804cd768f139e511. --- .../test/java/io/swagger/v3/core/filter/SpecFilterTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java index 0dc9dd8e02..1232c15e6f 100644 --- a/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java +++ b/modules/swagger-core/src/test/java/io/swagger/v3/core/filter/SpecFilterTest.java @@ -181,7 +181,8 @@ public void setUp() throws IOException { openAPI = getOpenAPI(RESOURCE_PATH); } - @Param({"10", "100", "1000", "5000", "10000"}) + // @Param({"10", "100", "1000"}) + @Param({"10"}) private int numThreads; @Test(description = "it should clone everything concurrently")