Skip to content

Commit

Permalink
Fix primitive class handling in Serialisers
Browse files Browse the repository at this point in the history
Fixes: ##37776
  • Loading branch information
geoand committed Dec 16, 2023
1 parent 7cf3e4e commit 7f3dfb8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,28 @@ public List<MessageBodyWriter<?>> findWriters(ConfigurationImpl configuration, C
return findWriters(configuration, entityType, resolvedMediaType, null);
}

protected Class<?> lookupPrimitiveWrapper(Class<?> entityType) {
protected final Class<?> lookupPrimitiveWrapper(final Class<?> entityType) {
if (!entityType.isPrimitive()) {
return entityType;
}
if (entityType == boolean.class) {
return Boolean.class;
} else if (entityType == char.class) {
return Character.class;
} else if (entityType == byte.class) {
return Byte.class;
} else if (entityType == short.class) {
return Short.class;
} else if (entityType == int.class) {
return Integer.class;
} else if (entityType == long.class) {
return Long.class;
} else if (entityType == float.class) {
return Float.class;
} else if (entityType == double.class) {
return Double.class;
}
// this shouldn't really happen, but better be safe than sorry
return entityType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,32 +178,6 @@ public List<ResourceWriter> apply(Class<?> aClass) {
}
};

@Override
protected final Class<?> lookupPrimitiveWrapper(final Class<?> entityType) {
if (!entityType.isPrimitive()) {
return entityType;
}
if (entityType == boolean.class) {
return Boolean.class;
} else if (entityType == char.class) {
return Character.class;
} else if (entityType == byte.class) {
return Byte.class;
} else if (entityType == short.class) {
return Short.class;
} else if (entityType == int.class) {
return Integer.class;
} else if (entityType == long.class) {
return Long.class;
} else if (entityType == float.class) {
return Float.class;
} else if (entityType == double.class) {
return Double.class;
}
// this shouldn't really happen, but better be safe than sorry
return entityType;
}

public static boolean invokeWriter(ResteasyReactiveRequestContext context, Object entity, MessageBodyWriter writer,
ServerSerialisers serialisers)
throws IOException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jboss.resteasy.reactive.server.vertx.test.resource.basic;

import static org.junit.jupiter.api.Assertions.*;

import java.util.function.Supplier;

import jakarta.ws.rs.client.Client;
Expand All @@ -13,7 +15,6 @@
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -55,7 +56,8 @@ public JavaArchive get() {
private void basicTest(String path) {
WebTarget base = client.target(PortProviderUtil.generateURL(path, ReponseInfoTest.class.getSimpleName()));
Response response = base.request().get();
Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(true, response.readEntity(boolean.class));
response.close();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ResponseInfoResource {

@Path("/simple")
@GET
public String get(@QueryParam("abs") String abs) {
public boolean get(@QueryParam("abs") String abs) {
LOG.debug("abs query: " + abs);
URI base;
if (abs == null) {
Expand All @@ -30,6 +30,6 @@ public String get(@QueryParam("abs") String abs) {
URI uri = (URI) response.getMetadata().getFirst(HttpHeaders.LOCATION);
LOG.debug("Location uri: " + uri);
Assertions.assertEquals(base.getPath(), uri.getPath());
return "CONTENT";
return true;
}
}

0 comments on commit 7f3dfb8

Please sign in to comment.