Repository: quarkusio/quarkus
Issue: Media type `text/xml` not working with REST Client Reactive

### Describe the bug

I tried updating our project to use the REST Client Reactive from RESTEasy Reactive, however I can't get it to work with one of our REST Clients that uses `text/xml`. It does work fine for others that use JSON for example.

### Expected behavior

The XML in the body of the response gets successfully processed with both media type `text/xml` and `application/xml`.

### Actual behavior

The REST client fails with an exception when using `text/xml`

```
javax.ws.rs.ProcessingException: Response could not be mapped to type class org.acme.SimpleJaxbTest$Dto

	at org.jboss.resteasy.reactive.client.impl.ClientReaderInterceptorContextImpl.proceed(ClientReaderInterceptorContextImpl.java:62)
	at org.jboss.resteasy.reactive.client.impl.ClientSerialisers.invokeClientReader(ClientSerialisers.java:146)
	at org.jboss.resteasy.reactive.client.impl.RestClientRequestContext.readEntity(RestClientRequestContext.java:182)
	at org.jboss.resteasy.reactive.client.handlers.ClientResponseCompleteRestHandler.mapToResponse(ClientResponseCompleteRestHandler.java:101)
	at org.jboss.resteasy.reactive.client.handlers.ClientResponseCompleteRestHandler.handle(ClientResponseCompleteRestHandler.java:32)
	at org.jboss.resteasy.reactive.client.handlers.ClientResponseCompleteRestHandler.handle(ClientResponseCompleteRestHandler.java:28)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.invokeHandler(AbstractResteasyReactiveContext.java:219)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:141)
	at org.jboss.resteasy.reactive.client.impl.RestClientRequestContext$1.lambda$execute$0(RestClientRequestContext.java:276)
	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:63)
	at io.vertx.core.impl.EventLoopContext.lambda$runOnContext$0(EventLoopContext.java:38)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:833)
```

It does work fine when you create an endpoint that uses `application/xml` or when you switch back to the REST Client from RESTEasy Classic with JAXB.

### How to Reproduce?

Based on the tests I found here: https://github.com/quarkusio/quarkus/blob/main/extensions/resteasy-reactive/rest-client-reactive-jaxb/deployment/src/test/java/io/quarkus/rest/client/reactive/jaxb/test/SimpleJaxbTest.java
I made a small reproducer:

```java
package org.acme;

import io.quarkus.test.common.http.TestHTTPResource;
import io.quarkus.test.junit.QuarkusTest;
import org.eclipse.microprofile.rest.client.RestClientBuilder;
import org.junit.jupiter.api.Test;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.xml.bind.annotation.XmlRootElement;
import java.net.URI;
import java.util.Objects;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

@QuarkusTest
public class SimpleJaxbTest {

    @TestHTTPResource
    URI uri;

    @Test
    void shouldConsumeXMLEntity() {
        var dto = RestClientBuilder.newBuilder().baseUri(uri).build(XmlClient.class).dto();
        assertThat(dto, equalTo(new Dto("foo", "bar")));
    }

    @Path("/xml")
    public interface XmlClient {

        @GET
        @Path("/dto")
        @Produces(MediaType.TEXT_XML)
        Dto dto();
    }

    @Path("/xml")
    public static class XmlResource {

        @GET
        @Produces(MediaType.TEXT_XML)
        @Path("/dto")
        public Dto dto() {
            return new Dto("foo", "bar");
        }
    }

    @XmlRootElement(name = "Dto")
    public static class Dto {
        public String name;
        public String value;

        public Dto(String name, String value) {
            this.name = name;
            this.value = value;
        }

        public Dto() {
        }

        @Override
        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            Dto dto = (Dto) o;
            return Objects.equals(name, dto.name) && Objects.equals(value, dto.value);
        }

        @Override
        public int hashCode() {
            return Objects.hash(name, value);
        }
    }
}
```

Extensions used:
```xml
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-rest-client-reactive-jaxb</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy-reactive-jaxb</artifactId>
    </dependency>
```

Reproducer:  [Archive.zip](https://github.com/quarkusio/quarkus/files/8805564/Archive.zip)



### Output of `uname -a` or `ver`

```
Darwin Willems-MBP.i.btp34.nl 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64
```

### Output of `java -version`

```
openjdk version "17.0.3" 2022-04-19 OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7) OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)
```

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

`2.9.2.Final`

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

```
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: /Users/wjglerum/.m2/wrapper/dists/apache-maven-3.8.4-bin/52ccbt68d252mdldqsfsn03jlf/apache-maven-3.8.4 Java version: 17.0.3, vendor: Eclipse Adoptium, runtime: /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home Default locale: en_NL, platform encoding: US-ASCII OS name: "mac os x", version: "12.4", arch: "x86_64", family: "mac"
```

### Additional information

Did I miss any documentation here? Or is there something else needed to make this work?

Changed files:
extensions/resteasy-reactive/quarkus-resteasy-reactive-jaxb-common/deployment/src/main/java/io/quarkus/resteasy/reactive/jaxb/common/deployment/ResteasyReactiveJaxbCommonProcessor.java
extensions/resteasy-reactive/rest-client-reactive-jaxb/deployment/src/test/java/io/quarkus/rest/client/reactive/jaxb/test/SimpleJaxbTest.java
extensions/resteasy-reactive/quarkus-resteasy-reactive-jaxb-common/runtime/src/main/java/io/quarkus/resteasy/reactive/jaxb/common/runtime/serialisers/JaxbMessageBodyReader.java
extensions/hibernate-validator/runtime/src/main/java/io/quarkus/hibernate/validator/runtime/jaxrs/ValidatorMediaTypeUtil.java

diff --git a/extensions/hibernate-validator/runtime/src/main/java/io/quarkus/hibernate/validator/runtime/jaxrs/ValidatorMediaTypeUtil.java b/extensions/hibernate-validator/runtime/src/main/java/io/quarkus/hibernate/validator/runtime/jaxrs/ValidatorMediaTypeUtil.java
index 63b90e93270..8eeede84b21 100644
--- a/extensions/hibernate-validator/runtime/src/main/java/io/quarkus/hibernate/validator/runtime/jaxrs/ValidatorMediaTypeUtil.java
+++ b/extensions/hibernate-validator/runtime/src/main/java/io/quarkus/hibernate/validator/runtime/jaxrs/ValidatorMediaTypeUtil.java
@@ -10,8 +10,10 @@
  */
 public final class ValidatorMediaTypeUtil {
 
-    private static final List<MediaType> SUPPORTED_MEDIA_TYPES = Arrays.asList(MediaType.APPLICATION_JSON_TYPE,
+    private static final List<MediaType> SUPPORTED_MEDIA_TYPES = Arrays.asList(
+            MediaType.APPLICATION_JSON_TYPE,
             MediaType.APPLICATION_XML_TYPE,
+            MediaType.TEXT_XML_TYPE,
             MediaType.TEXT_PLAIN_TYPE);
 
     private ValidatorMediaTypeUtil() {
diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jaxb-common/deployment/src/main/java/io/quarkus/resteasy/reactive/jaxb/common/deployment/ResteasyReactiveJaxbCommonProcessor.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jaxb-common/deployment/src/main/java/io/quarkus/resteasy/reactive/jaxb/common/deployment/ResteasyReactiveJaxbCommonProcessor.java
index 4d9d1311fb9..1f73e94c562 100644
--- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jaxb-common/deployment/src/main/java/io/quarkus/resteasy/reactive/jaxb/common/deployment/ResteasyReactiveJaxbCommonProcessor.java
+++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jaxb-common/deployment/src/main/java/io/quarkus/resteasy/reactive/jaxb/common/deployment/ResteasyReactiveJaxbCommonProcessor.java
@@ -1,6 +1,6 @@
 package io.quarkus.resteasy.reactive.jaxb.common.deployment;
 
-import java.util.Collections;
+import java.util.List;
 
 import javax.ws.rs.core.MediaType;
 
@@ -25,8 +25,8 @@ void additionalProviders(BuildProducer<AdditionalBeanBuildItem> additionalBean,
                 .setUnremovable().build());
 
         additionalReaders.produce(new MessageBodyReaderBuildItem(JaxbMessageBodyReader.class.getName(), Object.class.getName(),
-                Collections.singletonList(MediaType.APPLICATION_XML)));
+                List.of(MediaType.APPLICATION_XML, MediaType.TEXT_XML)));
         additionalWriters.produce(new MessageBodyWriterBuildItem(JaxbMessageBodyWriter.class.getName(), Object.class.getName(),
-                Collections.singletonList(MediaType.APPLICATION_XML)));
+                List.of(MediaType.APPLICATION_XML, MediaType.TEXT_XML)));
     }
 }
diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jaxb-common/runtime/src/main/java/io/quarkus/resteasy/reactive/jaxb/common/runtime/serialisers/JaxbMessageBodyReader.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jaxb-common/runtime/src/main/java/io/quarkus/resteasy/reactive/jaxb/common/runtime/serialisers/JaxbMessageBodyReader.java
index cfcf2102893..f78d995fb46 100644
--- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jaxb-common/runtime/src/main/java/io/quarkus/resteasy/reactive/jaxb/common/runtime/serialisers/JaxbMessageBodyReader.java
+++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jaxb-common/runtime/src/main/java/io/quarkus/resteasy/reactive/jaxb/common/runtime/serialisers/JaxbMessageBodyReader.java
@@ -47,9 +47,9 @@ protected boolean isReadable(MediaType mediaType, Class<?> type) {
             return false;
         }
         String subtype = mediaType.getSubtype();
-        boolean isApplicationMediaType = "application".equals(mediaType.getType());
-        return (isApplicationMediaType && "xml".equalsIgnoreCase(subtype) || subtype.endsWith("+xml"))
-                || (mediaType.isWildcardSubtype() && (mediaType.isWildcardType() || isApplicationMediaType));
+        boolean isCorrectMediaType = "application".equals(mediaType.getType()) || "text".equals(mediaType.getType());
+        return (isCorrectMediaType && "xml".equalsIgnoreCase(subtype) || subtype.endsWith("+xml"))
+                || (mediaType.isWildcardSubtype() && (mediaType.isWildcardType() || isCorrectMediaType));
     }
 
     private Object doReadFrom(Class<Object> type, Type genericType, InputStream entityStream) throws IOException {
diff --git a/extensions/resteasy-reactive/rest-client-reactive-jaxb/deployment/src/test/java/io/quarkus/rest/client/reactive/jaxb/test/SimpleJaxbTest.java b/extensions/resteasy-reactive/rest-client-reactive-jaxb/deployment/src/test/java/io/quarkus/rest/client/reactive/jaxb/test/SimpleJaxbTest.java
index 54bd22dd372..5f1b32e2a05 100644
--- a/extensions/resteasy-reactive/rest-client-reactive-jaxb/deployment/src/test/java/io/quarkus/rest/client/reactive/jaxb/test/SimpleJaxbTest.java
+++ b/extensions/resteasy-reactive/rest-client-reactive-jaxb/deployment/src/test/java/io/quarkus/rest/client/reactive/jaxb/test/SimpleJaxbTest.java
@@ -9,6 +9,7 @@
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
+import javax.xml.bind.annotation.XmlRootElement;
 
 import org.eclipse.microprofile.rest.client.RestClientBuilder;
 import org.junit.jupiter.api.Test;
@@ -26,12 +27,19 @@ public class SimpleJaxbTest {
     URI uri;
 
     @Test
-    void shouldConsumeJsonEntity() {
+    void shouldConsumeXMLEntity() {
         var dto = RestClientBuilder.newBuilder().baseUri(uri).build(XmlClient.class)
                 .dto();
         assertThat(dto).isEqualTo(new Dto("foo", "bar"));
     }
 
+    @Test
+    void shouldConsumePlainXMLEntity() {
+        var dto = RestClientBuilder.newBuilder().baseUri(uri).build(XmlClient.class)
+                .plain();
+        assertThat(dto).isEqualTo(new Dto("foo", "bar"));
+    }
+
     @Path("/xml")
     public interface XmlClient {
 
@@ -39,6 +47,11 @@ public interface XmlClient {
         @Path("/dto")
         @Produces(MediaType.APPLICATION_XML)
         Dto dto();
+
+        @GET
+        @Path("/plain")
+        @Produces(MediaType.TEXT_XML)
+        Dto plain();
     }
 
     @Path("/xml")
@@ -50,8 +63,16 @@ public static class XmlResource {
         public Dto dto() {
             return new Dto("foo", "bar");
         }
+
+        @GET
+        @Produces(MediaType.TEXT_XML)
+        @Path("/plain")
+        public Dto plain() {
+            return new Dto("foo", "bar");
+        }
     }
 
+    @XmlRootElement(name = "Dto")
     public static class Dto {
         public String name;
         public String value;