[Scala] Native mode rebuilds IntMap, LongMap, BitSet, mutable.LongMap and StringBuilder as a different collection class
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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!
- Ngôn ngữ chính
- Java
- Star
- 4.6k
- Fork
- 470
- Merge trung bình
- 9 giờ 28 phút
- Pull request đã merge (30 ngày)
- 33
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/fory
-
[Python] Compatible xlang read silently drops fields when the peer writes camelCase/PascalCase namesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Build] Add ASF license headers to config files that allow commentsCó thể làm lại được @Swatantra-66 đã nhận 27 ngày trước và không có pull request nào đang mở. Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
apache/fory#4124 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
xlang: the snake_case conversion of field names is not specified, and the runtimes do not agreeCó thể làm lại được @dhruv-dagar đã nhận 14 ngày trước và không có pull request nào đang mở. Đang mởbug
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
apache/fory#4187 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Rust] Add an option to use Rust native enumCó thể đã có người làm @BaldDemian đã nhận 18 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
apache/fory#4177 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Untyped read collapses a number literal that does not fit a doubleCó thể đã có người làm @mohitjoshi-hey đã nhận 20 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
apache/fory#4170 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Shweit/EtherealPortals#30 ·
-
Typo in jakartaee-bom 12.0.0-SNAPSHOT with cdiCó thể đã có người làm @ElectLive đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
jakartaee/jakartaee-api#205 · 1 bình luận ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
liberation-data/drivine4j#547 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
BindingServiceProperties.bindings regressed to a non-thread-safe TreeMap in GH-3158: concurrent first use of binding names corrupts itCó thể đã có người làm @AkashB23 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
spring-cloud/spring-cloud-stream#3321 ·
Maintainer thường phản hồi trong vòng 1 ngày