SammyVimes commented on code in PR #1291:
URL: https://github.com/apache/ignite-3/pull/1291#discussion_r1011563801
##########
modules/cluster-management/src/main/java/org/apache/ignite/internal/cluster/management/raft/ClusterStateStorage.java:
##########
@@ -104,6 +105,12 @@ public interface ClusterStateStorage extends AutoCloseable
{
*/
void restoreSnapshot(Path snapshotPath);
+ /**
+ * Closes this storage.
+ */
+ @Override
+ void close();
Review Comment:
Isn't close inherited from the interface?
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/MetaStorageManager.java:
##########
@@ -227,7 +227,7 @@ public void stop() throws Exception {
IgniteUtils.closeAll(
Review Comment:
probably this should be called `runAll` then
##########
modules/metastorage-server/src/main/java/org/apache/ignite/internal/metastorage/server/persistence/RocksDbKeyValueStorage.java:
##########
@@ -226,10 +227,10 @@ private void destroyRocksDb() throws RocksDBException {
/** {@inheritDoc} */
@Override
- public void close() throws Exception {
+ public void close() {
IgniteUtils.shutdownAndAwaitTermination(snapshotExecutor, 10,
TimeUnit.SECONDS);
- IgniteUtils.closeAll(db, options);
+ RocksUtils.closeAll(db, options);
Review Comment:
Can't it throw an exception actually?
##########
modules/raft/src/test/java/org/apache/ignite/raft/jraft/storage/impl/BaseLogStorageTest.java:
##########
@@ -16,6 +16,12 @@
*/
package org.apache.ignite.raft.jraft.storage.impl;
+import static org.junit.jupiter.api.Assertions.assertEquals;
Review Comment:
Are you sure that imports should be here in jraft?
##########
modules/transactions/src/test/java/org/apache/ignite/internal/tx/storage/state/TxStateStorageAbstractTest.java:
##########
@@ -150,10 +167,14 @@ public void testCas() throws Exception {
@Test
public void testScan() throws Exception {
- try (TxStateTableStorage tableStorage = createStorage()) {
- TxStateStorage storage0 =
tableStorage.getOrCreateTxStateStorage(0);
- TxStateStorage storage1 =
tableStorage.getOrCreateTxStateStorage(1);
- TxStateStorage storage2 =
tableStorage.getOrCreateTxStateStorage(2);
+ try (
+ var storageHolder0 = new
AutoCloser<>(tableStorage.getOrCreateTxStateStorage(0), TxStateStorage::close);
Review Comment:
Funny thing, you actually write more code than there were or even would be
if there was no `AutoCloser`:
```
var storageHolder0 = tableStorage.getOrCreateTxStateStorage(0);
storageHolder0.close();
```
And that's without calling `.value()` on all this holders...
##########
modules/core/src/main/java/org/apache/ignite/internal/close/ManuallyCloseable.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.close;
+
+/**
+ * Represents something that must be eventually closed. It is different from
{@link AutoCloseable} which is for being
+ * used in try-with-resources; IDEs treat any usage of an AutoCloseable
outside of a try-with-resources block as a suspicious
+ * and issue a warning, so it becomes a drag to work with code that uses
AutoCloseable for classes which instances
+ * are used with patterns different from the try-with-resources pattern.
+ *
+ * <p>The main reason of this interface appearance was the desire to mark
'must-be-eventually-closed' types so that
+ * we don't forget closing their instances.
Review Comment:
How does it help developers not to forget closing?
##########
modules/rocksdb-common/build.gradle:
##########
@@ -23,6 +23,10 @@ dependencies {
implementation project(':ignite-core')
implementation libs.jetbrains.annotations
api libs.rocksdb.jni
+
+ testImplementation libs.hamcrest.core
+ testImplementation libs.hamcrest.core
Review Comment:
this line is the same as above + in pom.xml you've added 4 dependencies and
here only 2 (or 3 with the duplicate)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]