This is an automated email from the ASF dual-hosted git repository. hulee pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/helix.git
View the commit online: https://github.com/apache/helix/commit/e3a7a0c62cdf9c06d3e9f4ac96ee1dd11bf11576 The following commit(s) were added to refs/heads/master by this push: new e3a7a0c Add default implementation to new interface methods (#626) e3a7a0c is described below commit e3a7a0c62cdf9c06d3e9f4ac96ee1dd11bf11576 Author: Hunter Lee <[email protected]> AuthorDate: Wed Nov 20 16:32:12 2019 -0800 Add default implementation to new interface methods (#626) * Add default implementation to new interface methods Some Helix data access API interfaces have close() method added. However, for users that implement these interfaces may see build failure because their implementations won't have close() implemented. This diff fixes this by ading a default implementation to close(). Change: 1. Make new close() interface methods a default implementation (a Java 8 feature) --- helix-core/src/main/java/org/apache/helix/BaseDataAccessor.java | 8 ++++++-- helix-core/src/main/java/org/apache/helix/HelixAdmin.java | 6 ++++-- .../apache/helix/tools/ClusterVerifiers/HelixClusterVerifier.java | 4 +++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/helix-core/src/main/java/org/apache/helix/BaseDataAccessor.java b/helix-core/src/main/java/org/apache/helix/BaseDataAccessor.java index 4853195..34a20ea 100644 --- a/helix-core/src/main/java/org/apache/helix/BaseDataAccessor.java +++ b/helix-core/src/main/java/org/apache/helix/BaseDataAccessor.java @@ -26,6 +26,7 @@ import org.I0Itec.zkclient.IZkChildListener; import org.I0Itec.zkclient.IZkDataListener; import org.apache.zookeeper.data.Stat; + /** * Generic interface for accessing and manipulating data on a backing store like Zookeeper. * @param <T> The type of record to use @@ -181,7 +182,8 @@ public interface BaseDataAccessor<T> { * @return A list of children of the parent ZNode */ List<T> getChildren(String parentPath, List<Stat> stats, int options, int retryCount, - int retryInterval) throws HelixException; + int retryInterval) + throws HelixException; /** * Returns the child names given a parent path @@ -261,5 +263,7 @@ public interface BaseDataAccessor<T> { /** * Close the connection to the metadata store */ - void close(); + default void close() { + System.out.println("Default close() was invoked! No operation was executed."); + } } diff --git a/helix-core/src/main/java/org/apache/helix/HelixAdmin.java b/helix-core/src/main/java/org/apache/helix/HelixAdmin.java index a986f8a..a11b235 100644 --- a/helix-core/src/main/java/org/apache/helix/HelixAdmin.java +++ b/helix-core/src/main/java/org/apache/helix/HelixAdmin.java @@ -574,7 +574,9 @@ public interface HelixAdmin { List<String> getInstancesByDomain(String clusterName, String domain); /** - * Release resources + * Release resources used in HelixAdmin. */ - void close(); + default void close() { + System.out.println("Default close() was invoked! No operation was executed."); + } } diff --git a/helix-core/src/main/java/org/apache/helix/tools/ClusterVerifiers/HelixClusterVerifier.java b/helix-core/src/main/java/org/apache/helix/tools/ClusterVerifiers/HelixClusterVerifier.java index 13f92fd..42927ab 100644 --- a/helix-core/src/main/java/org/apache/helix/tools/ClusterVerifiers/HelixClusterVerifier.java +++ b/helix-core/src/main/java/org/apache/helix/tools/ClusterVerifiers/HelixClusterVerifier.java @@ -41,5 +41,7 @@ public interface HelixClusterVerifier { /** * Close the underlying metadata store connection. */ - void close(); + default void close() { + System.out.println("Default close() was invoked! No operation was executed."); + } }
