tedyu commented on PR #48362:
URL: https://github.com/apache/spark/pull/48362#issuecomment-2400438925
What if we introduce the following wrapper in place of the Scala lazy value ?
```
class LazyRetry[T](compute: => T) {
private var initialized = false
private var value: Option[T] = None
def get: T = synchronized {
if (!initialized) {
try {
value = Some(compute)
initialized = true
} catch {
case e: Exception =>
// So that it can retry on the next call
initialized = false
throw e
}
}
value.getOrElse(throw new RuntimeException("Computation not successful"))
}
}
```
This wrapper doesn't cache exceptions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]