[Scala] Common Scala types fail with requireClassRegistration(true) because ForyScala does not pre-register them
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 52/100
Direzione di ricerca
Start in ScalaSerializers.registerSerializers and inspect CollectionKindsTest, along with the supported types listed in docs/object-serialization/scala/native.md. Determine how native registrations and xlang Option handling should cover the listed Scala types without destabilizing existing type IDs. Done means the affected values round trip with requireClassRegistration(true), and the relevant kinds can move from the unregistered tests in #4100.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
val fory = ForyScala.builder()
.withXlang(false)
.withRefTracking(true)
.requireClassRegistration(true) // the default
.build()
fory.deserialize(fory.serialize(Some(1)))
// InsecureException: class scala.Some is not registered ...
requireClassRegistration(true) is the builder default. The Scala security guide also recommends it. So the Option and Either examples in docs/object-serialization/scala/native.md fail as written.
What did you expect to see?
The Scala types that docs/object-serialization/scala/native.md lists as supported should round trip with class registration enabled, without the application registering Scala library classes. Collection kinds should be registered too, including their internal node and factory classes.
What did you see instead?
In native mode, compatible and schema-consistent, InsecureException: class ... is not registered is thrown for the types below. The class named is the first unregistered class reached:
| Value | Unregistered class |
|---|---|
Some(1) / None |
scala.Some / scala.None$ |
Right(1) / Left("a") |
scala.util.Right / scala.util.Left |
(1, 2) |
scala.Tuple2$mcII$sp (specialised tuples) |
Duration(1, "s") |
scala.concurrent.duration.FiniteDuration |
Duration.Inf |
scala.concurrent.duration.Duration$$anon$2 |
Vector.empty |
scala.collection.immutable.Vector0$ |
immutable.ArraySeq(1, 2) / ArraySeq("a") |
ArraySeq$ofInt / ArraySeq$ofRef |
mutable.ArraySeq("a") |
scala.collection.mutable.ArraySeq$ofRef |
immutable.ListSet(1) |
scala.collection.immutable.ListSet$Node |
immutable.ListMap(1 -> 1) |
scala.collection.immutable.ListMap$Node |
immutable.IntMap(1 -> "a") / LongMap(1L -> "a") |
IntMap$Tip / LongMap$Tip |
TreeSet, mutable.TreeSet, mutable.BitSet |
scala.collection.EvidenceIterableFactory$ToFactory |
TreeMap, mutable.TreeMap |
scala.collection.SortedMapFactory$ToFactory |
mutable.LongMap(1L -> 1) |
scala.collection.mutable.Map$ |
new mutable.StringBuilder("x") |
scala.collection.mutable.IndexedSeq$ |
Sorted collections also write their Ordering by reference, so the ordering classes, for example scala.math.Ordering$Int$, probably need registering as well.
In xlang mode, a reflective (non-macro) case class with an Option[T] field fails the same way: ClassUnregisteredException: Class scala.Some is not registered, thrown from the generated codec's writeClassAndObject. Turning off requireClassRegistration does not help in xlang mode.
These types all round trip with requireClassRegistration(false). Separately, some of them come back as a different class; that will be raised as its own issue.
Anything Else?
The fix most likely belongs in ScalaSerializers.registerSerializers, which already registers many Scala collection classes. Points to settle:
- Type IDs: adding registrations assigns new internal type IDs in native mode. Where should new entries go so that IDs of existing registrations, and of classes the user registers afterwards, stay stable? Or is an ID change acceptable for native mode?
- Scala versions: some internal classes (
Vector0–Vector6,ListSet$Node,IntMap$Tip, …) are Scala library implementation details. They should be registered by name, as some already are, so that differences between 2.13 and 3 library versions don't break installation. - Xlang
Option: this may need a nullable-wrapper field path rather than a type registration, because xlangOption[T]is meant to carryTas nullable. - Tests: once fixed, the kinds in
CollectionKindsTestthat are currently tested without registration (#4100) can move to the registration-required group.
Are you willing to submit a PR?
- I'm willing to submit a PR!
- Lingua principale
- Java
- Stelle
- 4.6k
- Fork
- 470
- Merge medio
- 9h 28m
- PR unite (30g)
- 33
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/fory
-
[Python] Compatible xlang read silently drops fields when the peer writes camelCase/PascalCase namesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
[Build] Add ASF license headers to config files that allow commentsForse di nuovo libera @Swatantra-66 l’ha presa 27 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
apache/fory#4124 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
xlang: the snake_case conversion of field names is not specified, and the runtimes do not agreeForse di nuovo libera @dhruv-dagar l’ha presa 14 giorni fa e non c’è nessuna pull request aperta. Apertabug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
apache/fory#4187 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[Rust] Add an option to use Rust native enumForse già presa @BaldDemian l’ha presa 18 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
apache/fory#4177 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Untyped read collapses a number literal that does not fit a doubleForse già presa @mohitjoshi-hey l’ha presa 20 giorni fa. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
apache/fory#4170 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
liberation-data/drivine4j#547 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
BindingServiceProperties.bindings regressed to a non-thread-safe TreeMap in GH-3158: concurrent first use of binding names corrupts itForse già presa @AkashB23 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
spring-cloud/spring-cloud-stream#3321 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] 资源包列表 与 模组/数据包/世界 列表排列顺序不一致Forse già presa @fishdry1000 l’ha presa 4 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
ai-driven-fuzzing bug claude Minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
linagora/twake-calendar-side-service#1333 ·
I maintainer di solito rispondono entro 1 giorno