Skip to content
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

Merged
merged 2 commits into from Nov 24, 2021

Conversation

minherz
Copy link
Contributor

@minherz minherz commented Nov 24, 2021

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.

Fix behavior of getRegion and getZone methods when attributes aren't defined.
Align getNamespaceName return value with other methods to return null.
@minherz minherz requested review from a team as code owners November 24, 2021 12:40
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Nov 24, 2021
@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/java-logging API. label Nov 24, 2021
Copy link
Contributor

@losalex losalex left a 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) {
Copy link
Contributor

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);
Copy link
Contributor

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

@minherz minherz merged commit e8cf6f9 into main Nov 24, 2021
@minherz minherz deleted the minherz/fix-logback-599 branch November 24, 2021 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/java-logging API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants