All Questions
2 questions
0
votes
1
answer
44
views
Instantiate lazy val which depends on runtime parameter in concurrent env
I need to instantiate MyHttpClient as Singleton. MyHttpClient is used by multiple threads.
Solution below works, but it's ugly and should have issue with endpoint, I just didn't hit it yet.
endpoint ...
30
votes
2
answers
20k
views
Difference when serializing a lazy val with or without @transient
Working on spark, sometimes I need to send a non-serializable object in each task.
A common pattern is @transient lazy val, e.g
class A(val a: Int)
def compute(rdd: RDD[Int]) = {
// lazy val ...