Skip to content

Commit

Permalink
Handle nulls more explicitly in schema derivation (#3970)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw authored Aug 6, 2024
1 parent ef22dd9 commit faa2566
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,14 @@ trait SchemaMagnoliaDerivation {
*/
private def withCache[T](typeName: TypeInfo, annotations: Seq[Any])(f: => Schema[T]): Schema[T] = {
val cacheKey = typeName.full
var inProgress = deriveCache.get()
val newCache = inProgress == null
if (newCache) {
inProgress = mutable.Set[String]()
deriveCache.set(inProgress)
}
val inProgressOrNull = deriveCache.get()
val newCache = inProgressOrNull == null

val inProgress = if (inProgressOrNull == null) {
val newInProgress = mutable.Set[String]()
deriveCache.set(newInProgress)
newInProgress
} else inProgressOrNull

if (inProgress.contains(cacheKey)) {
Schema[T](SRef(typeNameToSchemaName(typeName, annotations)))
Expand Down

0 comments on commit faa2566

Please sign in to comment.