-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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][broker] Fix UnsupportedOperationException
when update topic properties.
#20261
Merged
Technoboy-
merged 3 commits into
apache:master
from
liangyepianzhou:xiangying/fix/topic-police
May 9, 2023
Merged
[fix][broker] Fix UnsupportedOperationException
when update topic properties.
#20261
Technoboy-
merged 3 commits into
apache:master
from
liangyepianzhou:xiangying/fix/topic-police
May 9, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…roperties. ## Motivation The branch master has an NPE check in the `BrokerService::checkOwnershipAndCreatePersistentTopic`, but it will lead to a `UnsupportedOperationException`. The returned map might be an unmodifiable `Collections.emptyMap()`. The call chain involved is as follows: 1. `BrokerService::checkOwnershipAndCreatePersistentTopic` 2. `BrokerService::fetchTopicPropertiesAsync` 3. `ManagedLedgerFactory::getManagedLedgerPropertiesAsync` 4. `MetaStoreImpl::getManagedLedgerPropertiesAsync` 5. `operationFailed` ```java public void operationFailed(MetaStoreException e) { if (e instanceof MetadataNotFoundException) { result.complete(Collections.emptyMap()); } else { result.completeExceptionally(e); } } ```
liangyepianzhou
requested review from
Jason918,
codelipenghui,
poorbarcode and
congbobo184
May 8, 2023 17:01
gaoran10
reviewed
May 9, 2023
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java
Show resolved
Hide resolved
Technoboy-
reviewed
May 9, 2023
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
liangyepianzhou
added
release/2.10.5
release/2.9.6
release/2.11.2
release/3.0.1
and removed
release/2.10.5
release/2.9.6
release/2.11.2
release/3.0.1
labels
May 9, 2023
Technoboy-
approved these changes
May 9, 2023
poorbarcode
approved these changes
May 9, 2023
congbobo184
approved these changes
May 9, 2023
lifepuzzlefun
approved these changes
May 9, 2023
@liangyepianzhou - would you mind sharing the stack trace for the |
Why remove these labels? |
@michaeljmarshall Sure, of course. Message: java.util.concurrent.CompletionException: java.lang.UnsupportedOperationException
Stacktrace:
org.apache.bookkeeper.mledger.ManagedLedgerException$MetaStoreException: java.util.concurrent.CompletionException: java.lang.UnsupportedOperationException
Caused by: java.util.concurrent.CompletionException: java.lang.UnsupportedOperationException
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:722)
at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482)
at org.apache.bookkeeper.common.util.OrderedExecutor$TimedRunnable.run(OrderedExecutor.java:201)
at org.apache.bookkeeper.common.util.SingleThreadSafeScheduledExecutorService$SafeRunnable.run(SingleThreadSafeScheduledExecutorService.java:46)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.UnsupportedOperationException
at java.base/java.util.AbstractMap.put(AbstractMap.java:209)
at java.base/java.util.AbstractMap.putAll(AbstractMap.java:281)
at org.apache.pulsar.broker.admin.impl.PersistentTopicsBase$1.updatePropertiesComplete(PersistentTopicsBase.java:701)
at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl$26.operationComplete(ManagedLedgerImpl.java:4177)
at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl$26.operationComplete(ManagedLedgerImpl.java:4173)
at org.apache.bookkeeper.mledger.impl.MetaStoreImpl.lambda$asyncUpdateLedgerIds$7(MetaStoreImpl.java:203)
at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:718)
... 10 more
at org.apache.pulsar.client.admin.PulsarAdminException.wrap(PulsarAdminException.java:252)
at org.apache.pulsar.client.admin.internal.BaseResource.sync(BaseResource.java:352)
at org.apache.pulsar.client.admin.internal.TopicsImpl.updateProperties(TopicsImpl.java:419)
at org.apache.pulsar.broker.admin.TopicPoliciesTest.updatePropertiesForAutoCreatedTopicTest(TopicPoliciesTest.java:142)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:677)
at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:221)
at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:969)
at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194)
at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.testng.TestRunner.privateRun(TestRunner.java:829)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:437)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:431)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:391)
at org.testng.SuiteRunner.run(SuiteRunner.java:330)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1256)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1176)
at org.testng.TestNG.runSuites(TestNG.java:1099)
at org.testng.TestNG.run(TestNG.java:1067)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)
Suppressed: org.apache.pulsar.client.admin.PulsarAdminException$ServerSideErrorException:
--- An unexpected error occurred in the server ---
|
@poorbarcode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/broker
cherry-picked/branch-3.0
doc-not-needed
Your PR changes do not impact docs
ready-to-test
release/3.0.1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
The branch master has an NPE check in the
BrokerService::checkOwnershipAndCreatePersistentTopic
, but it will lead to aUnsupportedOperationException
. The returned map might be an unmodifiableCollections.emptyMap()
. The call chain involved is as follows:BrokerService::checkOwnershipAndCreatePersistentTopic
BrokerService::fetchTopicPropertiesAsync
ManagedLedgerFactory::getManagedLedgerPropertiesAsync
MetaStoreImpl::getManagedLedgerPropertiesAsync
operationFailed
Modifications
Make the getManagedLedgerPropertiesAsync return a modifiable map.
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: