-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor RealEnvStore methods to use uv_os_getenv/setenv/unsetenv #27211
Comments
Prior work: #14641 It seems easier to refactor |
Hi, It seems to be a good item for me as a first timer. I will work one this and will share the updates soon. |
Modified as Joyee Cheung suggested and tested by following contributors guide. Created pull request: #27310 |
Modified RealEnvStore::Get - removed os switch statements and replaced logic to use libuv uv_getos_env method. Fixes: nodejs#27211 Refs: http://docs.libuv.org/en/v1.x/misc.html
Modified RealEnvStore::Get, Set, Query and Delete methods to use libuv methods environment variables operations instead of using os specific logic and switches. Fixes: nodejs#27211 Refs: http://docs.libuv.org/en/v1.x/misc.html
Below review comments are taken care in this submission: 1. followed snake case naming convention for local variables 2. dropped sizeof(char) since it is obvious value 1 3. Used MaybeLocal<String> instead of Local<String> to check for empty strings and throw exception if empty. Fixes: nodejs#27211 Refs: https://v8docs.nodesource.com/node-4.8/annotated.html
used 2 spaces instead of 4 for indentation Fixes: nodejs#27211 Refs: https://v8docs.nodesource.com/node-4.8/annotated.html
Below review comments by Anna Henningsen are taken care: 1. avoided Yoda style comparisons 2. used MaybeStackBuffer instead of raw char pointers 3. used MaybeLocal<String> to inspect for empty string value and then raise exception and return empty Local<String> handle. (Changing return type of RealEnvStore::Get method to MaybeLocal<String> is pending, and planning to submit in next commit) Fixes: nodejs#27211 Refs: nodejs#27310 (comment)
Modified KVStore::Get return type to MaybeLocal and also modified RealEnvStore::Get, MapKVStore::Get respectively. Fixes: nodejs#27211 Refs: nodejs#27310 (comment)
Removed exception throwing if value is empty, since the same is handled in caller and returned immediately. Fixes: nodejs#27211 Refs: nodejs#27310 (comment)
1. All tests were failing due to the exception raising from within RealEnvStore::Get method, removed the exception raising since the caller are checking for empty handles and taking necessary actions. 2. Used MayLocal<String>’s ToLocalChecked() function instead of FromMaybe(). Fixes: nodejs#27211 Refs: nodejs#27310 (comment)
Modified an if statment and formatted the code as per Joyee Cheung's review comments Fixes: nodejs#27211 Refs: nodejs#27310 (comment) Refs: nodejs#27310 (comment)
All windows tests were failing after previous commit, as per Joyee Cheung suggestion modified to inspect the first character of env variable key’s on windows machine for the character ‘=‘ and skip if the key contains. Since these keys are hidden/read-only env vars in windows machines. Fixes: nodejs#27211 Refs: nodejs#27310 (comment)
Modified RealEnvStore::Get, Set, Query and Delete methods to use libuv methods environment variables operations instead of using os specific logic and switches. Fixes: #27211 Refs: http://docs.libuv.org/en/v1.x/misc.html PR-URL: #27310 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Modified RealEnvStore::Get, Set, Query and Delete methods to use libuv methods environment variables operations instead of using os specific logic and switches. Fixes: #27211 Refs: http://docs.libuv.org/en/v1.x/misc.html PR-URL: #27310 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
From a glance I think the uv_os_* methods are adequate to replace our conditional switches in the RealEnvStore methods.
I think this is a good first issue if you are familiar with C++ and has some idea on how to use libuv methods, but you may need to read into the libuv implementation to make sure the refactor does not change the functionality.
Pointers:
node/src/node_env_var.cc
Line 71 in dfd7e99
node/src/node_env_var.cc
Line 107 in dfd7e99
node/src/node_env_var.cc
Line 123 in dfd7e99
node/src/node_env_var.cc
Line 146 in dfd7e99
docs:
http://docs.libuv.org/en/v1.x/misc.html?highlight=uv_os_getenv#c.uv_os_getenv
http://docs.libuv.org/en/v1.x/misc.html?highlight=uv_os_getenv#c.uv_os_setenv
http://docs.libuv.org/en/v1.x/misc.html?highlight=uv_os_getenv#c.uv_os_unsetenv
The text was updated successfully, but these errors were encountered: