in src/hbase/client/configuration.cc [49:90]
std::string Configuration::SubstituteVars(const std::string &expr) const {
if (0 == expr.size()) return expr;
std::string eval(expr);
std::string value_to_be_replaced("");
std::string var("");
for (int i = 0; i < kMaxSubsts; i++) {
var = "";
size_t start_pos = IsSubVariable(eval, var);
if (start_pos != std::string::npos) {
// We are blindly checking for environment property at first.
// If we don't get any value from GetEnv, check in hbase-site.xml.
value_to_be_replaced = GetEnv(var).value_or(GetProperty(var).value_or(""));
// we haven't found any value yet so we are returning eval
if (0 == value_to_be_replaced.size()) {
return eval;
}
// return original expression if there is a loop
if (value_to_be_replaced == expr) {
return expr;
}
eval.replace(start_pos, var.size() + 3, value_to_be_replaced);
} else {
// No further expansion required.
return eval;
}
}
// We reached here if the loop is exhausted
// If MAX_SUBSTS is exhausted, check if more variable substitution is reqd.
// If any-more substitutions are reqd, throw an error.
var = "";
if (IsSubVariable(eval, var) != std::string::npos) {
throw std::runtime_error("Variable substitution depth too large: " +
std::to_string(kMaxSubsts) + " " + expr);
} else {
return eval;
}
}