File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
commons-core/src/main/scala/com/avsystem/commons/serialization/cbor Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import com.avsystem.commons.meta._
66import com .avsystem .commons .misc .ValueOf
77import com .avsystem .commons .serialization .GenCodec .OOOFieldsObjectCodec
88import com .avsystem .commons .serialization ._
9+ import monix .execution .atomic .AtomicBoolean
910
1011/**
1112 * Like [[HasGenCodec ]] but generates a codec optimized for writing and reading CBOR via [[CborOutput ]] and
@@ -255,10 +256,16 @@ trait CborAdtInstances[T] {
255256}
256257
257258trait CborAdtPolyInstances [C [_]] {
259+ private val alreadyValidated = AtomicBoolean (false )
258260 def stdCodec [T : GenCodec ]: GenObjectCodec [C [T ]]
259261 def metadata [T : GenCodec ]: CborAdtMetadata [C [T ]]
260262 def cborCodec [T : GenCodec ]: GenObjectCodec [C [T ]] =
261- metadata.setup(_.validate()).adjustCodec(stdCodec)
263+ metadata.setup { metadata =>
264+ alreadyValidated.transform { validated =>
265+ if (! validated) metadata.validate()
266+ true
267+ }
268+ }.adjustCodec(stdCodec)
262269}
263270
264271/**
You can’t perform that action at this time.
0 commit comments