Skip to content

Commit

Permalink
Make inlined schema derivation null safe (softwaremill#3977)
Browse files Browse the repository at this point in the history
  • Loading branch information
coryfklein authored Aug 7, 2024
1 parent a35ed84 commit d90e319
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ trait SchemaMagnoliaDerivation {
*/
private def withCache[T](typeName: TypeInfo, annotations: Seq[Any])(f: => Schema[T]): Schema[T] = {
val cacheKey = typeName.full
val inProgressOrNull = deriveCache.get()
val inProgressOrNull: mutable.Set[String] | Null = deriveCache.get()
val newCache = inProgressOrNull == null

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

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

0 comments on commit d90e319

Please sign in to comment.