Repository: primefaces/primefaces (java)

Issue:
MetadataTransformerExecutor: removeMetadataTransformer is not working
### Describe the bug

The Method removeMetadataTransformer() throws an UnsupportedOperationException, because remove() is called directly on an Iterator of a CopyOnWriteArrayList (COWIterator)


### Reproducer

_No response_

### Expected behavior

_No response_

### PrimeFaces edition

None

### PrimeFaces version

13.0.0 +

### Theme

_No response_

### JSF implementation

All

### JSF version

2.3

### Java version

11

### Browser(s)

_No response_

Pull request:
Fix #13542: 15.0.2 MetadataTransformer fix remove handling
Fix #13542: 15.0.2 MetadataTransformer fix remove handling

Patch:
diff --git a/pom.xml b/pom.xml
index af14fe1bc6..ae8de831d5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
     <groupId>org.primefaces</groupId>
     <artifactId>primefaces-parent</artifactId>
     <packaging>pom</packaging>
-    <version>15.0.1</version>
+    <version>15.0.2-SNAPSHOT</version>
 
     <name>PrimeFaces Parent</name>
     <url>https://www.primefaces.org</url>
diff --git a/primefaces-cli/pom.xml b/primefaces-cli/pom.xml
index 51581feb76..06724a8094 100644
--- a/primefaces-cli/pom.xml
+++ b/primefaces-cli/pom.xml
@@ -7,7 +7,7 @@
     <parent>
         <groupId>org.primefaces</groupId>
         <artifactId>primefaces-parent</artifactId>
-        <version>15.0.1</version>
+        <version>15.0.2-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/primefaces-coverage/pom.xml b/primefaces-coverage/pom.xml
index 1f7a58ef58..6faedfbbfb 100644
--- a/primefaces-coverage/pom.xml
+++ b/primefaces-coverage/pom.xml
@@ -7,7 +7,7 @@
     <parent>
         <groupId>org.primefaces</groupId>
         <artifactId>primefaces-parent</artifactId>
-        <version>15.0.1</version>
+        <version>15.0.2-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/primefaces-selenium/pom.xml b/primefaces-selenium/pom.xml
index e06c0477f9..a3e0ff3004 100644
--- a/primefaces-selenium/pom.xml
+++ b/primefaces-selenium/pom.xml
@@ -7,7 +7,7 @@
     <parent>
         <groupId>org.primefaces</groupId>
         <artifactId>primefaces-parent</artifactId>
-        <version>15.0.1</version>
+        <version>15.0.2-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/primefaces-selenium/primefaces-selenium-components/pom.xml b/primefaces-selenium/primefaces-selenium-components/pom.xml
index 79bd0076ab..ebdf4c7bcd 100644
--- a/primefaces-selenium/primefaces-selenium-components/pom.xml
+++ b/primefaces-selenium/primefaces-selenium-components/pom.xml
@@ -7,7 +7,7 @@
     <parent>
         <groupId>org.primefaces</groupId>
         <artifactId>primefaces-selenium</artifactId>
-        <version>15.0.1</version>
+        <version>15.0.2-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/primefaces-selenium/primefaces-selenium-core/pom.xml b/primefaces-selenium/primefaces-selenium-core/pom.xml
index 9ec1a0a4d8..aa2fe2541f 100644
--- a/primefaces-selenium/primefaces-selenium-core/pom.xml
+++ b/primefaces-selenium/primefaces-selenium-core/pom.xml
@@ -7,7 +7,7 @@
     <parent>
         <groupId>org.primefaces</groupId>
         <artifactId>primefaces-selenium</artifactId>
-        <version>15.0.1</version>
+        <version>15.0.2-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/primefaces-showcase/pom.xml b/primefaces-showcase/pom.xml
index cf67d938d9..e8a6587214 100644
--- a/primefaces-showcase/pom.xml
+++ b/primefaces-showcase/pom.xml
@@ -7,7 +7,7 @@
     <parent>
         <groupId>org.primefaces</groupId>
         <artifactId>primefaces-parent</artifactId>
-        <version>15.0.1</version>
+        <version>15.0.2-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/primefaces-themes/pom.xml b/primefaces-themes/pom.xml
index 4ce1342310..334bf3d645 100644
--- a/primefaces-themes/pom.xml
+++ b/primefaces-themes/pom.xml
@@ -4,7 +4,7 @@
     <parent>
         <groupId>org.primefaces</groupId>
         <artifactId>primefaces-parent</artifactId>
-        <version>15.0.1</version>
+        <version>15.0.2-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <artifactId>primefaces-themes</artifactId>
diff --git a/primefaces/pom.xml b/primefaces/pom.xml
index 2ad723ea11..fb25427027 100644
--- a/primefaces/pom.xml
+++ b/primefaces/pom.xml
@@ -7,7 +7,7 @@
     <parent>
         <groupId>org.primefaces</groupId>
         <artifactId>primefaces-parent</artifactId>
-        <version>15.0.1</version>
+        <version>15.0.2-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/primefaces/src/main/java/org/primefaces/metadata/transformer/MetadataTransformerExecutor.java b/primefaces/src/main/java/org/primefaces/metadata/transformer/MetadataTransformerExecutor.java
index fce48cc022..11e5b299f1 100644
--- a/primefaces/src/main/java/org/primefaces/metadata/transformer/MetadataTransformerExecutor.java
+++ b/primefaces/src/main/java/org/primefaces/metadata/transformer/MetadataTransformerExecutor.java
@@ -27,7 +27,7 @@ import org.primefaces.context.PrimeApplicationContext;
 import org.primefaces.metadata.transformer.impl.BeanValidationInputMetadataTransformer;
 
 import java.io.IOException;
-import java.util.Iterator;
+import java.util.List;
 
 import javax.faces.FacesException;
 import javax.faces.component.UIComponent;
@@ -84,16 +84,15 @@ public class MetadataTransformerExecutor implements SystemEventListener {
     }
 
     public static MetadataTransformer removeMetadataTransformer(final Class<? extends MetadataTransformer> clazz) {
-        Iterator<MetadataTransformer> iterator = PrimeApplicationContext.getCurrentInstance(FacesContext.getCurrentInstance())
-                .getMetadataTransformers().iterator();
-        while (iterator.hasNext()) {
-            MetadataTransformer metadataTransformer = iterator.next();
-            if (metadataTransformer.getClass().equals(clazz)) {
-                iterator.remove();
-                return metadataTransformer;
-            }
+        List<MetadataTransformer> transformers = PrimeApplicationContext.getCurrentInstance(FacesContext.getCurrentInstance())
+                .getMetadataTransformers();
+        MetadataTransformer transformer = transformers.stream()
+                .filter(t -> t.getClass().equals(clazz))
+                .findFirst()
+                .orElse(null);
+        if (transformer != null) {
+            transformers.remove(transformer);
         }
-
-        return null;
+        return transformer;
     }
 }


Test patch:
diff --git a/primefaces-integration-tests-jakarta/pom.xml b/primefaces-integration-tests-jakarta/pom.xml
index 281a474ae6..9932a079fe 100644
--- a/primefaces-integration-tests-jakarta/pom.xml
+++ b/primefaces-integration-tests-jakarta/pom.xml
@@ -7,7 +7,7 @@
     <parent>
         <groupId>org.primefaces</groupId>
         <artifactId>primefaces-parent</artifactId>
-        <version>15.0.1</version>
+        <version>15.0.2-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/primefaces-integration-tests/pom.xml b/primefaces-integration-tests/pom.xml
index 7a95039703..6793ef988f 100644
--- a/primefaces-integration-tests/pom.xml
+++ b/primefaces-integration-tests/pom.xml
@@ -7,7 +7,7 @@
     <parent>
         <groupId>org.primefaces</groupId>
         <artifactId>primefaces-parent</artifactId>
-        <version>15.0.1</version>
+        <version>15.0.2-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>