Skip to content

Support top-level scalar values in Jackson2Tokenizer [SPR-16166] #20714

@spring-projects-issues

Description

@spring-projects-issues

Julien Hoarau opened SPR-16166 and commented

WebClient failed to convert a json response containing a top level JsonValue (true, false, null, NUMBER ) (Valid Json according to ECMA-404)

Simple code example for demonstration

package com.atlassian.product.fabric.tasksdecisions.rest;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;

@RestController
public class JsonValueResource {
    @GetMapping("/fail")
    public Mono<Boolean> fail() {
        return WebClient.builder().baseUrl("http://localhost:8000")
                .build().get().uri("/")
                .accept(MediaType.APPLICATION_JSON)
                .retrieve()
                .bodyToMono(Boolean.class)
                .switchIfEmpty(Mono.error(new RuntimeException("No response")));
    }

    @GetMapping
    Mono<Boolean> jsonValueBoolean() {
        return Mono.just(true);
    }

}

Jackson2Tokenizer seems to only return tokens if they are in an object or array.


Affects: 5.0.1

Issue Links:

Referenced from: pull request #1602, and commits 8e253a3

1 votes, 3 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions