[Scala] Native mode rebuilds IntMap, LongMap, BitSet, mutable.LongMap and StringBuilder as a different collection class
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 68/100
Línea de trabajo
Start with ScalaCollectionSerializer, ScalaSeqSerializer and ScalaSortedSetSerializer in CollectionSerializer.scala, plus ScalaMapSerializer in MapSerializer.scala. Review the tests being added for #4100 and reproduce the listed collection cases across the affected modes. Done means round trips preserve each concrete collection type and ArraySeq representation without ClassCastException in typed fields.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Search before asking
- I had searched in the issues and found no similar issues.
Version
main (1.8.0-SNAPSHOT), Scala 2.13.18 and 3.3.8
Component(s)
Scala
Minimal reproduce step
import org.apache.fory.scala.ForyScala
import scala.collection.immutable
case class Holder(m: immutable.IntMap[String])
val fory = ForyScala.builder()
.withXlang(false)
.withRefTracking(true)
.requireClassRegistration(false)
.build()
fory.deserialize(fory.serialize(Holder(immutable.IntMap(1 -> "a"))))
// DeserializationException caused by
// ClassCastException: scala.collection.immutable.Map$Map1 cannot be cast to scala.collection.immutable.IntMap
What did you expect to see?
A native-mode round trip should rebuild the same collection class, as it already does for List, Vector, HashMap, TreeMap, LinkedHashMap and others.
What did you see instead?
The native Scala collection serializers write the value's generic factory, iterableFactory, mapFactory or sortedIterableFactory. For these specialised kinds that factory builds a different class. The same happens in compatible and schema-consistent modes:
| Written | Read back as | As a declared case class field |
|---|---|---|
immutable.IntMap |
immutable.Map$Map1 / Map |
ClassCastException |
immutable.LongMap |
immutable.Map$Map1 / Map |
ClassCastException |
mutable.BitSet |
mutable.TreeSet |
ClassCastException |
mutable.LongMap |
mutable.HashMap |
ClassCastException |
mutable.StringBuilder |
mutable.ArrayBuffer[Char] |
ClassCastException |
immutable.ArraySeq[Int] (ArraySeq$ofInt) |
ArraySeq$ofRef (boxed) |
works, but loses the unboxed representation |
As a root value, the decoded collection compares equal to the original, so the change goes unnoticed until a typed field or a pattern match depends on the concrete class.
Anything Else?
The factories are chosen in ScalaCollectionSerializer, ScalaSeqSerializer, ScalaSortedSetSerializer and ScalaMapSerializer (CollectionSerializer.scala and MapSerializer.scala). These kinds probably need their specific factory or a dedicated serializer, for example IntMap/LongMap factories, BitSet from its bitmask, StringBuilder as a string, and ArraySeq keeping its element ClassTag.
Related: #4101 covers the registration gap for several of the same types. Found while adding tests in #4100.
Are you willing to submit a PR?
- I'm willing to submit a PR!
- Lenguaje dominante
- Java
- Estrellas
- 4.6k
- Forks
- 470
- Merge medio
- 9 h 28 min
- PR fusionados (30 d)
- 33
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/fory
-
[Python] Compatible xlang read silently drops fields when the peer writes camelCase/PascalCase namesAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
[Build] Add ASF license headers to config files that allow commentsQuizá libre de nuevo @Swatantra-66 la tomó hace 27 días y no hay ningún pull request abierto. Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/fory#4124 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
xlang: the snake_case conversion of field names is not specified, and the runtimes do not agreeQuizá libre de nuevo @dhruv-dagar la tomó hace 15 días y no hay ningún pull request abierto. Abiertobug
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
apache/fory#4187 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[Rust] Add an option to use Rust native enumPosiblemente ocupada @BaldDemian la tomó hace 19 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
apache/fory#4177 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Untyped read collapses a number literal that does not fit a doublePosiblemente ocupada @mohitjoshi-hey la tomó hace 21 días. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
apache/fory#4170 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/fory
Issues similares
-
5.0.x backport enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
spring-cloud/spring-cloud-function#1507 ·
Los mantenedores suelen responder en 1 día
-
ai-driven-fuzzing bug claude Minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
linagora/twake-calendar-side-service#1417 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
line/armeria#7109 · 3 reacciones ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
a2aproject/a2a-java#1275 ·
Los mantenedores suelen responder en 1 día
-
module/ftp Type/Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ballerina-platform/ballerina-library#9476 ·
Los mantenedores suelen responder en 1 día