google / google/gson

Remove final modifier from com.google.gson.TypeAdapter.nullSafe()

Open
#1,561 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
24.2k
Forks
4.5k
Avg merge
6d 4h
Merged PRs (30d)
12

Description

`TypeAdapter.nullSafe()` is now used when a `TypeAdapter` is configured via `@JsonAdapter` and `@JsonAdapter.nullSafe` wasn't set to false.

Existing `TypeAdapter` implementations may already have handled the null-case - the wrapper introduced by calling `TypeAdapter.nullSafe()` is then at best unnecessary or may even break existing code. Clients are therefore forced to review any use of `@JsonAdapter` and set `@JsonAdapter.nullSafe` accordingly - which is an error prone process.

But if `TypeAdapter.nullSafe()` would not be final a `TypeAdapter` implementation which is already nullSafe could simply override the method and return `this`. This especially holds true for the wrapper implementation returned by `TypeAdapter.nullSafe()`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.