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][admin] Fix NPE when get OffloadThreshold on namespace. #18061

Merged
merged 1 commit into from
Oct 17, 2022

Conversation

Technoboy-
Copy link
Contributor

@Technoboy- Technoboy- commented Oct 17, 2022

Fixes #18023

Motivation

If the namespace policy inits without setting managedLedgerOffloadThresholdInBytes(like : if user setOffloadDeletionLag first and then getOffloadThreshold ), it will cause NPE when get OffloadThreshold.

Documentation

  • doc-not-needed

Matching PR in forked repository

PR in forked repository: https://github.com/Technoboy-/pulsar/pull/12

@Technoboy- Technoboy- self-assigned this Oct 17, 2022
@Technoboy- Technoboy- added this to the 2.12.0 milestone Oct 17, 2022
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Oct 17, 2022
@codecov-commenter
Copy link

codecov-commenter commented Oct 17, 2022

Codecov Report

Merging #18061 (4829ab9) into master (6c65ca0) will increase coverage by 11.88%.
The diff coverage is 80.00%.

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #18061       +/-   ##
=============================================
+ Coverage     34.91%   46.80%   +11.88%     
- Complexity     5707    17880    +12173     
=============================================
  Files           607     1574      +967     
  Lines         53396   128311    +74915     
  Branches       5712    14113     +8401     
=============================================
+ Hits          18644    60054    +41410     
- Misses        32119    62085    +29966     
- Partials       2633     6172     +3539     
Flag Coverage Δ
unittests 46.80% <80.00%> (+11.88%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...org/apache/pulsar/broker/ServiceConfiguration.java 52.07% <ø> (ø)
.../service/SystemTopicBasedTopicPoliciesService.java 61.39% <0.00%> (+9.80%) ⬆️
...g/apache/pulsar/compaction/CompactedTopicImpl.java 73.57% <0.00%> (+62.85%) ⬆️
...va/org/apache/pulsar/client/impl/ConsumerBase.java 21.95% <0.00%> (ø)
.../org/apache/pulsar/broker/admin/v2/Namespaces.java 57.46% <50.00%> (+49.43%) ⬆️
...he/pulsar/functions/worker/rest/api/SinksImpl.java 36.82% <50.00%> (ø)
...apache/pulsar/proxy/server/DirectProxyHandler.java 63.63% <50.00%> (ø)
...ulsar/functions/worker/rest/api/ComponentImpl.java 25.26% <57.14%> (ø)
...broker/delayed/InMemoryDelayedDeliveryTracker.java 65.00% <75.00%> (+65.00%) ⬆️
...che/bookkeeper/mledger/impl/ManagedLedgerImpl.java 71.07% <80.00%> (ø)
... and 1149 more

Copy link
Contributor

@HQebupt HQebupt left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -2054,7 +2054,8 @@ public void getOffloadThreshold(
validateNamespacePolicyOperationAsync(namespaceName, PolicyName.OFFLOAD, PolicyOperation.READ)
.thenCompose(__ -> getNamespacePoliciesAsync(namespaceName))
.thenAccept(policies -> {
if (policies.offload_policies == null) {
if (policies.offload_policies == null
|| policies.offload_policies.getManagedLedgerOffloadThresholdInBytes() == null) {
Copy link
Member

Choose a reason for hiding this comment

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

It's weird why the DEFAULT_OFFLOAD_THRESHOLD_IN_BYTES is null. But I think it's better to use this constant.

@codelipenghui codelipenghui merged commit 8f44c1a into apache:master Oct 17, 2022
@Technoboy- Technoboy- modified the milestones: 2.12.0, 2.11.0 Oct 18, 2022
congbobo184 pushed a commit to congbobo184/pulsar that referenced this pull request Nov 8, 2022
@congbobo184 congbobo184 added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label Nov 8, 2022
liangyepianzhou pushed a commit that referenced this pull request Dec 5, 2022
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Dec 6, 2022
@Technoboy- Technoboy- deleted the fix-18023 branch November 11, 2023 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] 500 Server error on pulsar-admin namespaces get-offload-threshold
8 participants