Repository: quarkusio/quarkus
Issue: Optional not working with @QueryParam in BeanParam

### Describe the bug

When using @QueryParam in conjunction with @BeanParam Optional fields are not working.

I'm using resteasy-reactive

### Expected behavior

We can automatically wrap null in Optional to have a nicer developper experience and have our code behave in BeanParam the same way it does with plain controller

### Actual behavior

We have a null instead of an Optional.empty()

### How to Reproduce?

Reproducer:

1. Create a quarkus project with version 2.7.2.Final
2. Add the reasteasy-reactive and resteasy-reactive-jackson extension
3. Create a controller using a BeanParam and a Bean to receive the params

here the bean:
```java
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@Slf4j
public class PageQuery {
    
    public static final Integer DEFAULT_PAGE = 0;
    public static final Integer DEFAULT_SIZE = 10;
    public static final Integer MAX_SIZE = 10;
    
    @QueryParam("page")
    private Optional<Integer> rawPage;
    @QueryParam("size")
    private Optional<Integer> rawSize;
    @QueryParam("sort")
    private Optional<String> sort;

    /**
     * Transforms the POJO to a Pageable for easy use with Spring repository
     * 
     * @return
     */
    public Pageable toPageable() {
        final var page = rawPage.orElse(DEFAULT_PAGE);
        // we limit the max size here
        final var size = Integer.max(rawPage.orElse(DEFAULT_SIZE), MAX_SIZE);
        log.info("page: " + rawPage + ", size: " + rawSize+ ", " + sort);
        return sort.map(s -> {
            final var r = s.split(",");
            final var column = r[0];
            final var direction = Sort.Direction.fromString(r[1]);
            return PageRequest.of(page, size, Sort.by(direction, column));
        }).orElse(PageRequest.of(page, size));
    }
}

```

4. Use it in a Controller with the @BeanParam annotation

### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

_No response_

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

2.7.2.Final

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

maven

### Additional information

_No response_

Changed files:
independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/scanning/ClassInjectorTransformer.java
independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/simple/SimpleBeanParam.java

diff --git a/independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/scanning/ClassInjectorTransformer.java b/independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/scanning/ClassInjectorTransformer.java
index 13d5a2033bd..0612350b0c8 100644
--- a/independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/scanning/ClassInjectorTransformer.java
+++ b/independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/scanning/ClassInjectorTransformer.java
@@ -356,10 +356,13 @@ private void injectParameterWithConverter(MethodVisitor injectMethod, String met
             }
             // push the parameter value
             loadParameter(injectMethod, methodName, extractor, extraSingleParameter, extraEncodedParam, encoded);
-            Label valueWasNull = new Label();
-            // dup to test it
-            injectMethod.visitInsn(Opcodes.DUP);
-            injectMethod.visitJumpInsn(Opcodes.IFNULL, valueWasNull);
+            Label valueWasNull = null;
+            if (!extractor.isOptional()) {
+                valueWasNull = new Label();
+                // dup to test it
+                injectMethod.visitInsn(Opcodes.DUP);
+                injectMethod.visitJumpInsn(Opcodes.IFNULL, valueWasNull);
+            }
             convertParameter(injectMethod, extractor, fieldInfo);
             // inject this (for the put field) before the injected value
             injectMethod.visitIntInsn(Opcodes.ALOAD, 0);
@@ -377,8 +380,10 @@ private void injectParameterWithConverter(MethodVisitor injectMethod, String met
             Label endLabel = new Label();
             injectMethod.visitJumpInsn(Opcodes.GOTO, endLabel);
 
-            // if the value was null, we don't set it
-            injectMethod.visitLabel(valueWasNull);
+            if (valueWasNull != null) {
+                // if the value was null, we don't set it
+                injectMethod.visitLabel(valueWasNull);
+            }
             // we have a null value for the object we wanted to inject on the stack
             injectMethod.visitInsn(Opcodes.POP);
 
diff --git a/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/simple/SimpleBeanParam.java b/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/simple/SimpleBeanParam.java
index 0e3275bab85..4914d832f7d 100644
--- a/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/simple/SimpleBeanParam.java
+++ b/independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/simple/SimpleBeanParam.java
@@ -1,6 +1,7 @@
 package org.jboss.resteasy.reactive.server.vertx.test.simple;
 
 import java.util.List;
+import java.util.Optional;
 import javax.ws.rs.BeanParam;
 import javax.ws.rs.DefaultValue;
 import javax.ws.rs.HeaderParam;
@@ -62,6 +63,15 @@ public class SimpleBeanParam {
     @QueryParam("query")
     List<MyParameter> myParameterList;
 
+    @QueryParam("missing")
+    Optional<String> missingOptionalString;
+
+    @QueryParam("query")
+    Optional<String> optionalQuery;
+
+    @QueryParam("query")
+    Optional<ParameterWithFromString> optionalParameterWithFromString;
+
     public void check(String path) {
         Assertions.assertEquals("one-query", query);
         Assertions.assertEquals("one-query", privateQuery);
@@ -84,5 +94,8 @@ public void check(String path) {
         Assertions.assertEquals(42, missingPrimitiveParamWithDefaultValue);
         Assertions.assertEquals("one-queryone-query", myParameter.toString());
         Assertions.assertEquals("one-queryone-query", myParameterList.get(0).toString());
+        Assertions.assertTrue(missingOptionalString.isEmpty());
+        Assertions.assertEquals("one-query", optionalQuery.get());
+        Assertions.assertEquals("ParameterWithFromString[val=one-query]", optionalParameterWithFromString.get().toString());
     }
 }