Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Don't crash if missing OTP_VERSION file (fix #350) #502

Merged
merged 1 commit into from
Jun 2, 2015

Conversation

choptastic
Copy link
Contributor

This is a simpler version of the fix presented in #501. If generates a WARN if no OTP_VERSION file is found, and resorts to the return of erlang:system_info(otp_release).

I wrapped the otp_release1 function in a simple process dictionary cache to prevent it from being called many times (in my tests it's called quite frequently - like a few hundred times, and since for OTP 17+, there's a hard drive or two for each call, I figured caching the result might speed things up a bit).

Anyway, let me know what you think.

@ghost
Copy link

ghost commented Jun 2, 2015

+1, even though I'm not sure about the use of pdict here. However, in this special case, like for rebar_log settings, it seems okay to use the process dictionary instead of putting it into rebar_config:config(). Let's get this into 2.6.0, once the minor issues are fixed.

@choptastic
Copy link
Contributor Author

Thanks, wow that was quite the abundance of typos. Yesterday must not have been a great day for me. Typos fixed, rebased, and pushed to the PR.

@ferd
Copy link
Contributor

ferd commented Jun 2, 2015

Looks good, got a +1, merging.

ferd added a commit that referenced this pull request Jun 2, 2015
Don't crash if missing OTP_VERSION file (fix #350)
@ferd ferd merged commit 6e7ec60 into rebar:master Jun 2, 2015
@choptastic
Copy link
Contributor Author

Thanks for merging. I do also agree that the pdict leaves a bit of a sour taste in my mouth, at least the way I'm using it here. It gets the job done, but if there are other areas that could benefit from some faux memoization/cache hackery, perhaps there's a value in adding some kind of wrapper function to deal with that. Something like rebar_utils:cache(Key, Fun) where Fun is only evaluated if Key is not found, or whatever.

@ghost
Copy link

ghost commented Jun 3, 2015

I'm already working on something like that, to be announced soon. It's fine in this case as it's write-once.

@choptastic
Copy link
Contributor Author

choptastic commented Jun 3, 2015 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants