Skip to content

Commit

Permalink
Fixes #2849: bug in getEnv (#2850)
Browse files Browse the repository at this point in the history
This PR (fixes #2849) since `c_string` has been deprecated we need to use `string.createCopyingBuffer` instead of casting

Co-authored-by: Pierce Hayes <pierce314159@users.noreply.github.com>
  • Loading branch information
stress-tess and Pierce Hayes authored Nov 15, 2023
1 parent 02c3a04 commit f359644
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ExternalIntegration.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ module ExternalIntegration {
return (serviceName,servicePort,targetServicePort);
}

proc getKubernetesDeregisterParameters(serviceEndpoint: ServiceEndpoint) {
proc getKubernetesDeregisterParameters(serviceEndpoint: ServiceEndpoint) throws {
if serviceEndpoint == ServiceEndpoint.METRICS {
return ServerConfig.getEnv('METRICS_SERVICE_NAME');
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/MetricsMsg.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module MetricsMsg {
private config const logChannel = ServerConfig.logChannel;
const mLogger = new Logger(logLevel, logChannel);

var metricScope = ServerConfig.getEnv(name='METRIC_SCOPE',default='MetricScope.REQUEST');
var metricScope = try! ServerConfig.getEnv(name='METRIC_SCOPE',default='MetricScope.REQUEST');

var serverMetrics = new CounterTable();

Expand Down
6 changes: 3 additions & 3 deletions src/ServerConfig.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ module ServerConfig
/*
Write the server `hostname:port` to this file.
*/
config const serverConnectionInfo: string = getEnv("ARKOUDA_SERVER_CONNECTION_INFO", "");
config const serverConnectionInfo: string = try! getEnv("ARKOUDA_SERVER_CONNECTION_INFO", "");

/*
Flag to shut down the arkouda server automatically when the client disconnects
Expand Down Expand Up @@ -231,10 +231,10 @@ module ServerConfig
return cfgStr;
}

proc getEnv(name: string, default=""): string {
proc getEnv(name: string, default=""): string throws {
use OS.POSIX;
var envBytes = getenv(name.localize().c_str());
var val = envBytes:string;
var val = string.createCopyingBuffer(envBytes:c_string_ptr);
if envBytes == nil || val.isEmpty() { val = default; }
return val;
}
Expand Down

0 comments on commit f359644

Please sign in to comment.