This is an automated email from the ASF dual-hosted git repository.
apolovtsev pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 52df5378d1 IGNITE-23659 Remove dubious sneakyThrow usages (#4709)
52df5378d1 is described below
commit 52df5378d1914c933a5e8172a51653c8c4902f44
Author: Alexander Polovtcev <[email protected]>
AuthorDate: Wed Nov 13 10:03:48 2024 +0200
IGNITE-23659 Remove dubious sneakyThrow usages (#4709)
---
.../internal/table/distributed/TableManager.java | 23 +++++-----------------
.../replicator/PartitionReplicaListener.java | 9 +--------
2 files changed, 6 insertions(+), 26 deletions(-)
diff --git
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
index b4c49b4007..7649737e14 100644
---
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
+++
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java
@@ -58,7 +58,6 @@ import static
org.apache.ignite.internal.util.CompletableFutures.emptyListComple
import static
org.apache.ignite.internal.util.CompletableFutures.falseCompletedFuture;
import static
org.apache.ignite.internal.util.CompletableFutures.nullCompletedFuture;
import static
org.apache.ignite.internal.util.CompletableFutures.trueCompletedFuture;
-import static org.apache.ignite.internal.util.ExceptionUtils.sneakyThrow;
import static org.apache.ignite.internal.util.ExceptionUtils.unwrapCause;
import static org.apache.ignite.internal.util.IgniteUtils.inBusyLock;
import static org.apache.ignite.internal.util.IgniteUtils.inBusyLockAsync;
@@ -799,16 +798,12 @@ public class TableManager implements
IgniteTablesInternal, IgniteComponent {
// TODO: https://issues.apache.org/jira/browse/IGNITE-19913 Possible
performance degradation.
return createPartsFut.thenAccept(ignore -> startedTables.put(tableId,
table))
- .handle((v, th) -> {
+ .whenComplete((v, th) -> {
partitionReplicaLifecycleManager.unlockZoneForRead(zoneDescriptor.id(), stamp);
- if (th != null) {
- sneakyThrow(th);
+ if (th == null) {
+ addTableToZone(zoneDescriptor.id(), table);
}
-
- addTableToZone(zoneDescriptor.id(), table);
-
- return v;
})
.thenApply(unused -> false);
}
@@ -973,18 +968,14 @@ public class TableManager implements
IgniteTablesInternal, IgniteComponent {
return metaStorageMgr
.invoke(condition, partitionAssignments,
Collections.emptyList())
- .handle((invokeResult, e) -> {
+ .whenComplete((invokeResult, e) -> {
if (e != null) {
LOG.error(
"Couldn't write assignments
[assignmentsList={}] to metastore during invoke.",
e,
Assignments.assignmentListToString(newAssignments)
);
-
- throw sneakyThrow(e);
}
-
- return invokeResult;
})
.thenCompose(invokeResult -> {
if (invokeResult) {
@@ -1028,14 +1019,10 @@ public class TableManager implements
IgniteTablesInternal, IgniteComponent {
});
}
})
- .handle((realAssignments, e) -> {
+ .whenComplete((realAssignments, e) -> {
if (e != null) {
LOG.error("Couldn't get assignments from metastore
for table [tableId={}].", e, tableId);
-
- throw sneakyThrow(e);
}
-
- return realAssignments;
});
});
}
diff --git
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java
index 14716b8430..61bee26e96 100644
---
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java
+++
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java
@@ -208,7 +208,6 @@ import
org.apache.ignite.internal.tx.message.WriteIntentSwitchReplicatedInfo;
import org.apache.ignite.internal.tx.storage.state.TxStateStorage;
import org.apache.ignite.internal.util.Cursor;
import org.apache.ignite.internal.util.CursorUtils;
-import org.apache.ignite.internal.util.ExceptionUtils;
import org.apache.ignite.internal.util.IgniteSpinBusyLock;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.Lazy;
@@ -748,16 +747,10 @@ public class PartitionReplicaListener implements
ReplicaListener {
.thenApply(ignored -> rows);
}
})
- .handle((rows, err) -> {
+ .whenComplete((rows, err) -> {
if (req.full() && (err != null || rows.size() <
req.batchSize())) {
releaseTxLocks(req.transactionId());
}
-
- if (err != null) {
- ExceptionUtils.sneakyThrow(err);
- }
-
- return rows;
});
} else if (request instanceof ScanCloseReplicaRequest) {
processScanCloseAction((ScanCloseReplicaRequest) request);