Avoid calling SoftReference.get() twice#159
Avoid calling SoftReference.get() twice#159turbanoff wants to merge 1 commit intoeclipse-aspectj:masterfrom
Conversation
Says who? Can you elaborate, please? I am not an expert on the subject matter, but I would rather think that If your concern here is rather that the methods in question would return |
|
@turbanoff, I know you seem to avoid writing a lot, which can be a nice quality sometimes. OTOH, you keep opening new PRs without responding to feedback in existing ones first. In order to keep the number of open PRs manageable, it would be nice to have a short cycle time for them. In the next few months I will have even less time than before due to my work to click through open issues. I also want to avoid letting your very welcome contributions rot. So please respond. Thank you so much. |
Actually, for JVM, even I agree, that there are no real problems here in updated code. Let me update it to make it cleanup only in obvious cases (in |
03256a7 to
7c5de4a
Compare
|
Agreed @turbanoff . Wherever one can use refersTo it's always a better alternative to get(), unless you precisely intend to trigger the side effects of get(). If strong references are created too often, it may be impossible for the GC ever to clear them. With SoftReferences it's even worse, because they keep an internal timestamp to implement some sort of LRU policy, and that timestamp gets updated every time you call get(). |
SoftReference.get() is not supposed to be called more than once. It's because between two
.get()calls GC could clear the reference and code could get an expected result.In AspectJ it called twice in a few places, which we could easily update.