Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

fix: handle null pointer when parsing metadata attributes#759

Merged
minherz merged 2 commits into
mainfrom
minherz/fix-logback-599
Nov 24, 2021
Merged

fix: handle null pointer when parsing metadata attributes#759
minherz merged 2 commits into
mainfrom
minherz/fix-logback-599

Conversation

@minherz

@minherz minherz commented Nov 24, 2021

Copy link
Copy Markdown
Contributor

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 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

@losalex losalex left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

private String getRegion() {
String loc = getter.getAttribute("instance/region");
return loc.substring(loc.lastIndexOf('/') + 1);
if (loc != null) {

Copy link
Copy Markdown
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;

String loc = getter.getAttribute("instance/zone");
return loc.substring(loc.lastIndexOf('/') + 1);
if (loc != null) {
return loc.substring(loc.lastIndexOf('/') + 1);

Copy link
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

3 participants