-
Notifications
You must be signed in to change notification settings - Fork 39
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
fix: handle null pointer when parsing metadata attributes #759
Conversation
Fix behavior of getRegion and getZone methods when attributes aren't defined. Align getNamespaceName return value with other methods to return null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -178,7 +175,10 @@ private String getProjectId() { | |||
*/ | |||
private String getRegion() { | |||
String loc = getter.getAttribute("instance/region"); | |||
return loc.substring(loc.lastIndexOf('/') + 1); | |||
if (loc != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: return loc != null ? loc.substring(loc.lastIndexOf('/') + 1) : null;
@@ -199,6 +199,9 @@ private String getVersionId() { | |||
*/ | |||
private String getZone() { | |||
String loc = getter.getAttribute("instance/zone"); | |||
return loc.substring(loc.lastIndexOf('/') + 1); | |||
if (loc != null) { | |||
return loc.substring(loc.lastIndexOf('/') + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Same as above - simplifies reading
Fix behavior of getRegion and getZone methods when attributes aren't defined.
Align getNamespaceName return value with other methods to return null.
Addresses googleapis/java-logging-logback#599 when incorrect resource type is enforced.