Skip to content

Polish AbstractJackson2Decoder#decodeToMono #34581

@ShenFeng312

Description

@ShenFeng312
	@Override
	public Mono<Object> decodeToMono(Publisher<DataBuffer> input, ResolvableType elementType,
			@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {

		return Mono.deferContextual(contextView -> {

			Map<String, Object> hintsToUse = contextView.isEmpty() ? hints :
					Hints.merge(hints, ContextView.class.getName(), contextView);

			return DataBufferUtils.join(input, this.maxInMemorySize).flatMap(dataBuffer ->
					Mono.justOrEmpty(decode(dataBuffer, elementType, mimeType, hintsToUse)));
		});
	}

In decodeToMono, it seems that all DataBuffers need to be awaited before deserialization can proceed. This implies higher memory overhead. Why not use NonBlockingJsonParser instead like decode? It seems that this could save memory and avoid blocking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions