You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "jianghuazhu (via GitHub)" <gi...@apache.org> on 2025/05/09 04:39:10 UTC
[PR] RATIS-2180. Unified judgment object is not null [ratis]
jianghuazhu opened a new pull request, #1256:
URL: https://github.com/apache/ratis/pull/1256
## What changes were proposed in this pull request?
We use Objects.requireNonNull() to uniformly replace Preconditions.assertNotNull().
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/RATIS-2180
## How was this patch tested?
ci:
https://github.com/jianghuazhu/ratis/actions/runs/14921172685
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RATIS-2180. Use Objects.requireNonNull instead of Preconditions.assertNotNull [ratis]
Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on code in PR #1256:
URL: https://github.com/apache/ratis/pull/1256#discussion_r2083421576
##########
ratis-common/src/main/java/org/apache/ratis/util/ReferenceCountedLeakDetector.java:
##########
@@ -202,7 +203,7 @@ public synchronized boolean release() {
}
if (released) {
- Preconditions.assertNotNull(removeMethod, () -> "Not yet retained (removeMethod == null): " + valueClass);
+ Objects.requireNonNull(removeMethod, "Not yet retained (removeMethod == null): " + valueClass);
Review Comment:
Thanks @szetszwo for the comment and review.
I have updated it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RATIS-2180. Use Objects.requireNonNull instead of Preconditions.assertNotNull [ratis]
Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo commented on PR #1256:
URL: https://github.com/apache/ratis/pull/1256#issuecomment-2869011106
> ... Preconditions.assertTrue() and Preconditions.assertNull() , should we keep the current status?
Let's keep using them since there is no standard java replacement.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RATIS-2180. Use Objects.requireNonNull instead of Preconditions.assertNotNull [ratis]
Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo commented on code in PR #1256:
URL: https://github.com/apache/ratis/pull/1256#discussion_r2083237277
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/ServerImplUtils.java:
##########
@@ -170,8 +171,8 @@ public static RaftServerProxy newRaftServer(
ThreadGroup threadGroup, RaftProperties properties, Parameters parameters) throws IOException {
RaftServer.LOG.debug("newRaftServer: {}, {}", id, group);
if (group != null && !group.getPeers().isEmpty()) {
- Preconditions.assertNotNull(id, "RaftPeerId %s is not in RaftGroup %s", id, group);
- Preconditions.assertNotNull(group.getPeer(id), "RaftPeerId %s is not in RaftGroup %s", id, group);
+ Objects.requireNonNull(id, "RaftPeerId " + id + " is not in RaftGroup " + group);
+ Objects.requireNonNull(group.getPeer(id), "RaftPeerId " + id + " is not in RaftGroup " + group);
Review Comment:
We should use Supplier in order to avoid unnecessarily creating the string.
##########
ratis-common/src/main/java/org/apache/ratis/util/ReferenceCountedLeakDetector.java:
##########
@@ -202,7 +203,7 @@ public synchronized boolean release() {
}
if (released) {
- Preconditions.assertNotNull(removeMethod, () -> "Not yet retained (removeMethod == null): " + valueClass);
+ Objects.requireNonNull(removeMethod, "Not yet retained (removeMethod == null): " + valueClass);
Review Comment:
We should keep using the Supplier in order to avoid unnecessarily creating the string.
```java
Objects.requireNonNull(removeMethod, () -> "Not yet retained (removeMethod == null): " + valueClass);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RATIS-2180. Unified judgment object is not null [ratis]
Posted by "jianghuazhu (via GitHub)" <gi...@apache.org>.
jianghuazhu commented on PR #1256:
URL: https://github.com/apache/ratis/pull/1256#issuecomment-2865082525
@szetszwo , can you help look at this PR?
We have now replaced `Preconditions.assertNotNull()` with `Objects.requireNonNull()`, and `Preconditions.assertTrue()` and `Preconditions.assertNull()` seem to be difficult to resolve. For `Preconditions.assertTrue()` and `Preconditions.assertNull()` , should we keep the current status?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RATIS-2180. Use Objects.requireNonNull instead of Preconditions.assertNotNull [ratis]
Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo merged PR #1256:
URL: https://github.com/apache/ratis/pull/1256
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org