Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resteasy-reactive produces invalid json for Multi #18043

Closed
fedinskiy opened this issue Jun 21, 2021 · 5 comments · Fixed by #27719
Closed

Resteasy-reactive produces invalid json for Multi #18043

fedinskiy opened this issue Jun 21, 2021 · 5 comments · Fixed by #27719
Assignees
Labels
area/rest kind/bug Something isn't working
Milestone

Comments

@fedinskiy
Copy link
Contributor

Describe the bug

While using Multi as a return value for a method annotated with @Produces(MediaType.APPLICATION_JSON), the returned json looks like an array(it uses square brackets around the results), but lacks quotation marks around the strings inside e.g. [Hello,Hola] instead of ["Hello","Hola"]. Adding quarkus-resteasy-reactive-jackson to a classpath does not solve the problem.

Expected behaviour

Any of the following:
Returning of valid json array (["Hello","Hola"])
Returning values one-by-one
Compilation error

Actual behavior

Invalid json array([Hello,Hola])

To Reproduce

Link to a reproducer:

git clone [email protected]:fedinskiy/reproducer.git -b multi-jackson

Steps to reproduce the behavior:

  1. mvn clean quarkus:dev
  2. curl -w'\n' localhost:8080/hello/multi
    Or:
  3. mvn clean test

Environment (please complete the following information):

Output of uname -a or ver

Linux localhost.localdomain 5.12.10-300.fc34.x86_64 #1 SMP Thu Jun 10 14:21:36 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment GraalVM CE 20.3.2 (build 11.0.11+8-jvmci-20.3-b15)
OpenJDK 64-Bit Server VM GraalVM CE 20.3.2 (build 11.0.11+8-jvmci-20.3-b15, mixed mode, sharing)

Quarkus version or git rev

2.0.0.CR3
OR
1.13.7.Final

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

Apache Maven 3.6.3

May be somehow connected to #14183

@fedinskiy fedinskiy added the kind/bug Something isn't working label Jun 21, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 21, 2021

/cc @FroMage, @geoand, @stuartwdouglas

@oliver-brm
Copy link

oliver-brm commented Jun 30, 2021

The items in the Multi<String> hit a condition in JacksonMessageBodyWriterUtil:

if (o instanceof String) { // YUK: done in order to avoid adding extra quotes...
    entityStream.write(((String) o).getBytes());
} else {
    ...

Removing the condition would fix this issue but I'm not sure if it would raise other issues.

@geoand
Copy link
Contributor

geoand commented Jun 30, 2021

Removing the condition would fix this issue but I'm not sure if it would raise other issues.

Unfortunately it would

@StephenOTT
Copy link

Is there a workaround for this?

@StephenOTT
Copy link

The workaround for me was to just wrap the strings in another object

@geoand geoand self-assigned this Sep 5, 2022
geoand added a commit to geoand/quarkus that referenced this issue Sep 5, 2022
geoand added a commit to geoand/quarkus that referenced this issue Sep 5, 2022
geoand added a commit to geoand/quarkus that referenced this issue Sep 5, 2022
@quarkus-bot quarkus-bot bot added this to the 2.13 - main milestone Sep 5, 2022
evanchooly pushed a commit to nenros/quarkus that referenced this issue Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest kind/bug Something isn't working
Projects
None yet
4 participants