Skip to content

Fixed NPE warnings #515

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

Merged
merged 1 commit into from
Jul 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ private class LeaseCreator implements Function<Result<Boolean>, Result<Semaphore
@Override
public Result<SemaphoreLease> apply(Result<Boolean> acquireResult) {
if (!acquireResult.isSuccess()) {
return acquireResult.map(null);
return acquireResult.map(l -> null);
}
if (!acquireResult.getValue()) {
return Result.fail(Status.of(StatusCode.TIMEOUT));
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/tech/ydb/core/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public interface Result<T> {
T getValue() throws UnexpectedResultException;

@Nonnull
<U> Result<U> map(Function<T, U> mapper);
<U> Result<U> map(@Nonnull Function<T, U> mapper);

@Nonnull
<U> CompletableFuture<Result<U>> mapResultFuture(Function<T, CompletableFuture<Result<U>>> mapper);
<U> CompletableFuture<Result<U>> mapResultFuture(@Nonnull Function<T, CompletableFuture<Result<U>>> mapper);

@Nonnull
CompletableFuture<Status> mapStatusFuture(Function<T, CompletableFuture<Status>> mapper);
CompletableFuture<Status> mapStatusFuture(@Nonnull Function<T, CompletableFuture<Status>> mapper);

default boolean isSuccess() {
return getStatus().getCode() == StatusCode.SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public <ReqT, RespT> CompletableFuture<Result<RespT>> unaryCall(
ReqT request
) {
if (isClosed.get()) {
return CompletableFuture.completedFuture(SHUTDOWN_RESULT.map(null));
return CompletableFuture.completedFuture(SHUTDOWN_RESULT.map(o -> null));
}

String traceId = settings.getTraceId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static <R, M extends Message> Function<Result<R>, Result<M>> bindSync(
) {
return (result) -> {
if (!result.isSuccess()) {
return result.map(null);
return result.map(r -> null);
}
OperationProtos.Operation operation = method.apply(result.getValue());
if (!operation.getReady()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ StatusCode toStatusCode(Result<T> result) {

@Override
Result<T> toFailedResult(Result<QuerySession> sessionResult) {
return sessionResult.map(null);
return sessionResult.map(s -> null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ StatusCode toStatusCode(Result<T> result) {

@Override
Result<T> toFailedResult(Result<Session> sessionResult) {
return sessionResult.map(null);
return sessionResult.map(s -> null);
}
}

Expand Down
4 changes: 2 additions & 2 deletions table/src/main/java/tech/ydb/table/impl/BaseSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ private static ChangefeedDescription.State mapChangefeedState(YdbTable.Changefee
private static Result<TableDescription> mapDescribeTable(Result<YdbTable.DescribeTableResult> describeResult,
DescribeTableSettings settings) {
if (!describeResult.isSuccess()) {
return describeResult.map(null);
return describeResult.map(r -> null);
}
YdbTable.DescribeTableResult desc = describeResult.getValue();
SchemeOperationProtos.Entry.Type entryType = desc.getSelf().getType();
Expand Down Expand Up @@ -900,7 +900,7 @@ private static YdbTable.TransactionSettings txSettings(Transaction.Mode transact
private static Result<TableOptionDescription> mapDescribeTableOptions(
Result<YdbTable.DescribeTableOptionsResult> describeTableOptionsResult) {
if (!describeTableOptionsResult.isSuccess()) {
return describeTableOptionsResult.map(null);
return describeTableOptionsResult.map(r -> null);
}

YdbTable.DescribeTableOptionsResult describeResult = describeTableOptionsResult.getValue();
Expand Down