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

[cleanup][broker] Various cleanups #20658

Merged
merged 1 commit into from
Jun 30, 2023
Merged

[cleanup][broker] Various cleanups #20658

merged 1 commit into from
Jun 30, 2023

Conversation

cbornet
Copy link
Contributor

@cbornet cbornet commented Jun 27, 2023

Motivation

Remove warnings in IDEA

Verifying this change

  • Make sure that the change passes the CI checks.

This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: cbornet#14

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jun 27, 2023
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

+1

* If the service unit is not owned, return an empty optional
*/
public Optional<URL> getWebServiceUrl(ServiceUnitId suName, LookupOptions options) throws Exception {
return getWebServiceUrlAsync(suName, options)
.get(pulsar.getConfiguration().getMetadataStoreOperationTimeoutSeconds(), SECONDS);
}

private CompletableFuture<Optional<URL>> internalGetWebServiceUrl(Optional<ServiceUnitId> topic,
private CompletableFuture<Optional<URL>> internalGetWebServiceUrl(ServiceUnitId topic,
Copy link
Contributor

@lifepuzzlefun lifepuzzlefun Jun 28, 2023

Choose a reason for hiding this comment

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

may be we need a @Nullable annotation on ServiceUnitId here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

I like this change.

Although, I remember once I change switch case to JDK 17 match style one argues that it can introduce burden on back port code if fixes made around those code snippets. This can be a reason that @lhotari suggests we make changes firstly from the earliest maintained branch.

Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

... while I agree we should not block ourselves.

@cbornet
Copy link
Contributor Author

cbornet commented Jun 29, 2023

Although, I remember once I change switch case to JDK 17 match style one argues that it can introduce burden on back port code if fixes made around those code snippets. This can be a reason that @lhotari suggests we make changes firstly from the earliest maintained branch.

That's a very valid point. I'll rollback the changes on switch expressions.

@cbornet
Copy link
Contributor Author

cbornet commented Jun 30, 2023

We also have Pulsar 2.10 which runs on JDK 8.
Does it mean that we shouldn't use JDK 11 features (Map.of, List.of, Optional.isEmpty) either ?
@lhotari WDYT ?

@@ -306,7 +306,7 @@ private CompletableFuture<Optional<URL>> internalGetWebServiceUrl(Optional<Servi
}
CompletableFuture<Optional<LookupResult>> future =
ExtensibleLoadManagerImpl.isLoadManagerExtensionEnabled(config)
? loadManager.get().findBrokerServiceUrl(topic, bundle) :
? loadManager.get().findBrokerServiceUrl(Optional.ofNullable(topic), bundle) :
Copy link
Contributor

Choose a reason for hiding this comment

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

Are @Nullable and Optional.ofNullable()both needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so.
@Nullable indicates to the caller the topic can be null.
Since it can be null we need to use Optional.ofNullable() when wrapping it into an Optional.

@cbornet cbornet changed the title [cleanup][broker] Various cleanups, leveraging JDK 17 [cleanup][broker] Various cleanups Jun 30, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #20658 (23228ea) into master (0e60340) will increase coverage by 0.53%.
The diff coverage is 70.45%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #20658      +/-   ##
============================================
+ Coverage     72.60%   73.13%   +0.53%     
- Complexity    32018    32102      +84     
============================================
  Files          1855     1871      +16     
  Lines        138569   138952     +383     
  Branches      15250    15281      +31     
============================================
+ Hits         100605   101620    +1015     
+ Misses        29945    29290     -655     
- Partials       8019     8042      +23     
Flag Coverage Δ
inttests 24.09% <32.95%> (-0.02%) ⬇️
systests 24.90% <29.54%> (?)
unittests 72.42% <70.45%> (+0.06%) ⬆️

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

Impacted Files Coverage Δ
...a/org/apache/pulsar/broker/web/RequestWrapper.java 54.54% <ø> (ø)
...pache/pulsar/broker/web/ResponseHandlerFilter.java 57.14% <ø> (ø)
...pulsar/broker/TransactionMetadataStoreService.java 68.51% <50.00%> (+0.44%) ⬆️
...ache/pulsar/broker/ManagedLedgerClientFactory.java 83.11% <57.14%> (+1.06%) ⬆️
...rg/apache/pulsar/broker/web/PulsarWebResource.java 64.60% <66.66%> (-0.01%) ⬇️
...ache/pulsar/broker/namespace/NamespaceService.java 71.69% <68.29%> (+0.56%) ⬆️
...n/java/org/apache/pulsar/broker/PulsarService.java 82.33% <80.00%> (+1.73%) ⬆️
...che/pulsar/broker/BookKeeperClientFactoryImpl.java 79.43% <100.00%> (ø)
.../apache/pulsar/broker/loadbalance/LoadManager.java 73.91% <100.00%> (-1.09%) ⬇️
...va/org/apache/pulsar/broker/web/RestException.java 96.77% <100.00%> (-0.11%) ⬇️
... and 1 more

... and 173 files with indirect coverage changes

@cbornet cbornet merged commit 8d53035 into apache:master Jun 30, 2023
@cbornet cbornet deleted the cleanup-1 branch October 15, 2023 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs ready-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants