File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
google-cloud-logging/src/main/java/com/google/cloud/logging Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -137,10 +137,10 @@ private String getModuleId() {
137
137
* K8S_POD_NAMESPACE_PATH} when available or read from a user defined environment variable
138
138
* "NAMESPACE_NAME"
139
139
*
140
- * @return Namespace name or empty string if the name could not be discovered
140
+ * @return Namespace string or null if the name could not be discovered
141
141
*/
142
142
private String getNamespaceName () {
143
- String value = "" ;
143
+ String value = null ;
144
144
try {
145
145
value =
146
146
new String (
@@ -151,9 +151,6 @@ private String getNamespaceName() {
151
151
// if SA token is not shared the info about namespace is unavailable
152
152
// allow users to define the namespace name explicitly
153
153
value = getter .getEnv ("NAMESPACE_NAME" );
154
- if (value == null ) {
155
- value = "" ;
156
- }
157
154
}
158
155
return value ;
159
156
}
@@ -178,7 +175,10 @@ private String getProjectId() {
178
175
*/
179
176
private String getRegion () {
180
177
String loc = getter .getAttribute ("instance/region" );
181
- return loc .substring (loc .lastIndexOf ('/' ) + 1 );
178
+ if (loc != null ) {
179
+ return loc .substring (loc .lastIndexOf ('/' ) + 1 );
180
+ }
181
+ return null ;
182
182
}
183
183
184
184
private String getRevisionName () {
@@ -199,6 +199,9 @@ private String getVersionId() {
199
199
*/
200
200
private String getZone () {
201
201
String loc = getter .getAttribute ("instance/zone" );
202
- return loc .substring (loc .lastIndexOf ('/' ) + 1 );
202
+ if (loc != null ) {
203
+ return loc .substring (loc .lastIndexOf ('/' ) + 1 );
204
+ }
205
+ return null ;
203
206
}
204
207
}
You can’t perform that action at this time.
0 commit comments