tsreaper commented on code in PR #405:
URL: https://github.com/apache/flink-table-store/pull/405#discussion_r1033077832


##########
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/operation/Lock.java:
##########
@@ -31,13 +32,57 @@ public interface Lock extends AutoCloseable {
     /** Run with lock. */
     <T> T runWithLock(Callable<T> callable) throws Exception;
 
-    @Nullable
-    static Lock fromCatalog(CatalogLock.Factory lockFactory, ObjectPath 
tablePath) {
-        if (lockFactory == null) {
-            return null;
+    /** A factory to create {@link Lock}. */
+    interface Factory extends Serializable {
+        Lock create();
+    }
+
+    static Factory factory(@Nullable CatalogLock.Factory lockFactory, 
ObjectPath tablePath) {
+        return lockFactory == null
+                ? new EmptyFactory()
+                : new CatalogLockFactory(lockFactory, tablePath);
+    }
+
+    static Factory emptyFactory() {
+        return new EmptyFactory();
+    }
+
+    /** A {@link Factory} creating lock from catalog. */
+    class CatalogLockFactory implements Factory {
+
+        private static final long serialVersionUID = 1L;
+
+        private final CatalogLock.Factory lockFactory;
+        private final ObjectPath tablePath;
+
+        public CatalogLockFactory(CatalogLock.Factory lockFactory, ObjectPath 
tablePath) {
+            this.lockFactory = lockFactory;
+            this.tablePath = tablePath;
+        }
+
+        @Override
+        public Lock create() {
+            return fromCatalog(lockFactory.create(), tablePath);
         }
+    }
 
-        return fromCatalog(lockFactory.create(), tablePath);
+    /** A {@link Factory} creating empty lock. */
+    class EmptyFactory implements Factory {
+
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public Lock create() {
+            return new Lock() {
+                @Override
+                public <T> T runWithLock(Callable<T> callable) throws 
Exception {
+                    return callable.call();
+                }
+
+                @Override
+                public void close() {}
+            };

Review Comment:
   Just return `null`?



-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to