[
https://issues.apache.org/jira/browse/ZOOKEEPER-5032?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated ZOOKEEPER-5032:
--------------------------------------
Labels: pull-request-available (was: )
> StatsTrack(byte[]) throws NullPointerException when quota node data is null
> ---------------------------------------------------------------------------
>
> Key: ZOOKEEPER-5032
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-5032
> Project: ZooKeeper
> Issue Type: Bug
> Components: quota
> Affects Versions: 3.9.5
> Reporter: Julian Chandra Sutadi
> Priority: Major
> Labels: pull-request-available
> Time Spent: 20m
> Remaining Estimate: 0h
>
> While conducting testing on the ZooKeeper 3.9.5 release, a possible
> NullPointerException was identified in the StatsTrack(byte[]) constructor.
> When the byte[] parameter is null, passing it directly to new String(stat,
> StandardCharsets.UTF_8) causes an NPE. A null byte array can occur when
> node.data is null for a quota stat znode.
> *Fix*
> Delegate to the existing StatsTrack(String) constructor with a null check:
> {code:java}
> public StatsTrack(byte[] stat) {
> this(stat == null ? null : new String(stat, StandardCharsets.UTF_8));
> // invokes constructor overload below
> }
> public StatsTrack(String stat) {
> this.stats.clear();
> if (stat == null || stat.length() == 0) {
> return;
> }
> ...
> }{code}
> *Testing*
> A regression test testCreateNodeWhenQuotaStatDataIsNull is added to
> StatsTrackTest.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)