Skip to content

Wrong gson deserialization of list of integers #18397

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

Closed
tgodzik opened this issue Aug 14, 2023 · 2 comments
Closed

Wrong gson deserialization of list of integers #18397

tgodzik opened this issue Aug 14, 2023 · 2 comments
Assignees
Milestone

Comments

@tgodzik
Copy link
Contributor

tgodzik commented Aug 14, 2023

Compiler version

3.3.0

Minimized code

//> using dep com.google.code.gson:gson:2.10.1
//> using scala 3.3.0

import com.google.gson.Gson
import scala.jdk.CollectionConverters._

case class HasArray(
    argIndices: java.util.List[Integer]
)

object Main {

  def main(args: Array[String]): Unit = {
    val gson = new Gson();
    val arr =
      gson.fromJson[HasArray]("{ \"argIndices\" : [1,2,3]}", classOf[HasArray])
    println(arr.argIndices)
  }
}

Output

[1.0, 2.0, 3.0]

the elements in the list are actually Doubles.

Expectation

[1, 2, 3]

This worked ok in the previous Scala versions 2.13.x.

@tgodzik tgodzik added itype:bug compat:java stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 14, 2023
@Kordyjan Kordyjan removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Aug 14, 2023
@SethTisue SethTisue added this to the 3.4.0 milestone Feb 10, 2025
@SethTisue
Copy link
Member

SethTisue commented Feb 10, 2025

fixed in 3.4.0, but 3.3.6-RC1-bin-20250128-c189755-NIGHTLY still shows the old behavior

I did not attempt to identify the responsible PR

@som-snytt
Copy link
Contributor

@SethTisue fixed by #19207 which could be backport-nominated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants