Comments (4)
Hello, thanks for the report.
The problem is in this line: https://github.com/plokhotnyuk/jsoniter-scala/blob/3f81687acabc30202d43c2a9f31fb541fb342112/benchmark/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/macros/AVSystemCodecs.scala#L48
implicit val twitterAPIGenCodec: GenCodec[Seq[Tweet]] = GenCodec.materializeRecursively[Seq[Tweet]]
You should not macro-materialize codec for a Seq
, because GenCodec[Seq[A]]
is automatically provided as long as there is a GenCodec[A]
, so this would be sufficient:
implicit val twitterAPIGenCodec: GenCodec[Tweet] = GenCodec.materializeRecursively[Tweet]
... but I just realized that it doesn't work because GenCodec
cannot be materialized for case classes with more than 22 fields 😢
Also, the macro itself should be more secured to reject materializing something like a Seq
.
Will fix that.
from scala-commons.
This is interesting. It turns out that Seq[A]
is actually a completely valid type for macro materialization of GenCodec
because it has a companion object with matching apply
and unapplySeq
methods. The only problem is that the argument of apply
is also a Seq[A]
which creates a cycle and causes stack to overflow.
from scala-commons.
Stack overflow cannot be reproduced by this code with v1.28.2, but JsonStringInput.read[Seq[Tweet]]
returns an instance of Vector
instead of expected List
:
https://github.com/plokhotnyuk/jsoniter-scala/blob/7aa20826271d03262b734caa40d818bda5f725d3/jsoniter-scala-benchmark/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/macros/TwitterAPIBenchmark.scala#L25-L28
Should I close this issue and open a new one for that case?
from scala-commons.
@plokhotnyuk I've created separate issue for that, closing this one. Thanks!
from scala-commons.
Related Issues (20)
- Compilation error when importing GenCodec in Scala 2.11 HOT 2
- GenCodec for Seq creates a Vector instead of List when reading HOT 3
- Release for Scala 2.13.x HOT 3
- Possible DoS when parsing a JSON number to BigInt or BigDecimal HOT 5
- More user-friendly support of value classes HOT 2
- Compilation error in `materializeRecursively` call when upgrading to 1.34.3 version HOT 1
- Allow metadata annotations to accept arbitrary metadata parameters
- Require explicit @encoded annotation on @multi params/methods
- GenCodec regression in 1.34.15 HOT 1
- Mapping scala BigDecimal to BSON NumberDecimal instead of binary HOT 3
- [TypedMongo] Allowing the discriminator field at any position HOT 7
- Accepting Ints as Doubles in BSON HOT 3
- Cannot pull single element by value in Mongo update HOT 2
- Referencing nested array fields in typed Mongo HOT 6
- Scala 3? HOT 2
- Conditional beans include support in commons-spring
- Invalid condition generation in filtered positional operator
- Handle thrown exception outside the monadic context of Task
- Emptiness and Definition of Opt HOT 1
- quasi-Opaque types in Scala 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scala-commons.