diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 8445d0a5..685c72de 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -28,7 +28,7 @@ body: options: - exception / error (异常报错) - logic (逻辑设计问题) - - performence (性能下降) + - performance (性能下降) - others (please edit later) - type: checkboxes diff --git a/.github/ISSUE_TEMPLATE/question_ask.yml b/.github/ISSUE_TEMPLATE/question_ask.yml index 9724e66c..6fb2d4eb 100644 --- a/.github/ISSUE_TEMPLATE/question_ask.yml +++ b/.github/ISSUE_TEMPLATE/question_ask.yml @@ -25,7 +25,7 @@ body: label: Problem Type (问题类型) options: - struct / logic (架构 / 逻辑设计问题) - - performence (性能优化) + - performance (性能优化) - exception / error (异常报错) - others (please edit later) diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/concurrent/KeyLock.java b/hugegraph-common/src/main/java/org/apache/hugegraph/concurrent/KeyLock.java index eda012b8..351f50cf 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/concurrent/KeyLock.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/concurrent/KeyLock.java @@ -88,7 +88,7 @@ public final List lockAll(Object... keys) { Lock lock = this.locks.get(key); locks.add(lock); } - Collections.sort(locks, (a, b) -> { + locks.sort((a, b) -> { int diff = a.hashCode() - b.hashCode(); if (diff == 0 && a != b) { diff = this.indexOf(a) - this.indexOf(b); @@ -96,8 +96,8 @@ public final List lockAll(Object... keys) { } return diff; }); - for (int i = 0; i < locks.size(); i++) { - locks.get(i).lock(); + for (Lock lock : locks) { + lock.lock(); } return Collections.unmodifiableList(locks); } @@ -125,8 +125,8 @@ public List lockAll(Object key1, Object key2) { ImmutableList.of(lock2, lock1) : ImmutableList.of(lock1, lock2); - for (int i = 0; i < locks.size(); i++) { - locks.get(i).lock(); + for (Lock lock : locks) { + lock.lock(); } return locks; diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/concurrent/PausableScheduledThreadPool.java b/hugegraph-common/src/main/java/org/apache/hugegraph/concurrent/PausableScheduledThreadPool.java index e5dba9fe..ddfc8b72 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/concurrent/PausableScheduledThreadPool.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/concurrent/PausableScheduledThreadPool.java @@ -28,8 +28,7 @@ public class PausableScheduledThreadPool extends ScheduledThreadPoolExecutor { - private static final Logger LOG = Log.logger( - PausableScheduledThreadPool.class); + private static final Logger LOG = Log.logger(PausableScheduledThreadPool.class); private volatile boolean paused = false; diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/config/OptionChecker.java b/hugegraph-common/src/main/java/org/apache/hugegraph/config/OptionChecker.java index 551fe93c..8676702a 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/config/OptionChecker.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/config/OptionChecker.java @@ -21,6 +21,7 @@ import java.lang.reflect.Array; import java.util.Arrays; +import java.util.HashSet; import java.util.List; import javax.annotation.Nullable; @@ -32,88 +33,55 @@ public final class OptionChecker { public static Predicate disallowEmpty() { - return new Predicate() { - @Override - public boolean apply(@Nullable O o) { - if (o == null) { - return false; - } - if (o instanceof String) { - return StringUtils.isNotBlank((String) o); - } - if (o.getClass().isArray() && (Array.getLength(o) == 0)) { - return false; - } - if (o instanceof Iterable && - !((Iterable) o).iterator().hasNext()) { - return false; - } - return true; + return o -> { + if (o == null) { + return false; } + if (o instanceof String) { + return StringUtils.isNotBlank((String) o); + } + if (o.getClass().isArray() && (Array.getLength(o) == 0)) { + return false; + } + return !(o instanceof Iterable) || ((Iterable) o).iterator().hasNext(); }; } @SuppressWarnings("unchecked") public static Predicate allowValues(O... values) { - return new Predicate() { - @Override - public boolean apply(@Nullable O o) { - return o != null && Arrays.asList(values).contains(o); - } - }; + return o -> o != null && Arrays.asList(values).contains(o); } @SuppressWarnings("unchecked") public static Predicate> inValues(O... values) { - return new Predicate>() { - @Override - public boolean apply(@Nullable List o) { - return o != null && Arrays.asList(values).containsAll(o); - } - }; + return o -> o != null && new HashSet<>(Arrays.asList(values)).containsAll(o); } public static Predicate positiveInt() { - return new Predicate() { - @Override - public boolean apply(@Nullable N number) { - return number != null && number.longValue() > 0; - } - }; + return number -> number != null && number.longValue() > 0; } public static Predicate nonNegativeInt() { - return new Predicate() { - @Override - public boolean apply(@Nullable N number) { - return number != null && number.longValue() >= 0; - } - }; + return number -> number != null && number.longValue() >= 0; } public static Predicate rangeInt(N min, N max) { - return new Predicate() { - @Override - public boolean apply(@Nullable N number) { - if (number == null) { - return false; - } - long value = number.longValue(); - return value >= min.longValue() && value <= max.longValue(); + return number -> { + if (number == null) { + return false; } + long value = number.longValue(); + return value >= min.longValue() && value <= max.longValue(); }; } public static Predicate rangeDouble(N min, N max) { - return new Predicate() { - @Override - public boolean apply(@Nullable N number) { - if (number == null) { - return false; - } - double value = number.doubleValue(); - return value >= min.doubleValue() && value <= max.doubleValue(); + return number -> { + if (number == null) { + return false; } + double value = number.doubleValue(); + return value >= min.doubleValue() && value <= max.doubleValue(); }; } } diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/date/SafeDateFormat.java b/hugegraph-common/src/main/java/org/apache/hugegraph/date/SafeDateFormat.java index 0deba51e..9f9a665f 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/date/SafeDateFormat.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/date/SafeDateFormat.java @@ -48,7 +48,7 @@ public synchronized void setTimeZone(String zoneId) { this.formatter = this.formatter.withZone(zone); } - public TimeZone getTimeZome() { + public TimeZone getTimeZone() { return this.formatter.getZone().toTimeZone(); } diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/event/EventHub.java b/hugegraph-common/src/main/java/org/apache/hugegraph/event/EventHub.java index 0e426fcb..2db83474 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/event/EventHub.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/event/EventHub.java @@ -159,8 +159,8 @@ public Future notify(String event, @Nullable Object... args) { try { all.next().event(ev); count++; - } catch (Throwable ignored) { - LOG.warn("Failed to handle event: {}", ev, ignored); + } catch (Throwable e) { + LOG.warn("Failed to handle event: {}", ev, e); } } return count; diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/event/EventListener.java b/hugegraph-common/src/main/java/org/apache/hugegraph/event/EventListener.java index a0deb4c0..3810926f 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/event/EventListener.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/event/EventListener.java @@ -25,5 +25,5 @@ public interface EventListener extends java.util.EventListener { * @param event object * @return event result */ - public Object event(Event event); + Object event(Event event); } diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/func/TriFunction.java b/hugegraph-common/src/main/java/org/apache/hugegraph/func/TriFunction.java index b381d42e..d84c26f3 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/func/TriFunction.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/func/TriFunction.java @@ -20,5 +20,6 @@ package org.apache.hugegraph.func; public interface TriFunction { - public R apply(T1 v1, T2 v2, T3 v3); + + R apply(T1 v1, T2 v2, T3 v3); } diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/ExtendableIterator.java b/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/ExtendableIterator.java index d4e690f8..a07f3e47 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/ExtendableIterator.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/ExtendableIterator.java @@ -82,7 +82,7 @@ protected boolean fetch() { return true; } - Iterator first = null; + Iterator first; while ((first = this.itors.peekFirst()) != null && !first.hasNext()) { if (first == this.itors.peekLast() && this.itors.size() == 1) { this.currentIterator = first; diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/Metadatable.java b/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/Metadatable.java index 2f7d81f3..777e4680 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/Metadatable.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/Metadatable.java @@ -21,5 +21,5 @@ public interface Metadatable { - public Object metadata(String meta, Object... args); + Object metadata(String meta, Object... args); } diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/license/LicenseManager.java b/hugegraph-common/src/main/java/org/apache/hugegraph/license/LicenseManager.java index 73788999..f87b9ebb 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/license/LicenseManager.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/license/LicenseManager.java @@ -21,14 +21,14 @@ public interface LicenseManager { - public LicenseParams installLicense() throws Exception; + LicenseParams installLicense() throws Exception; - public void uninstallLicense() throws Exception; + void uninstallLicense() throws Exception; - public LicenseParams verifyLicense() throws Exception; + LicenseParams verifyLicense() throws Exception; - public interface VerifyCallback { + interface VerifyCallback { - public void onVerifyLicense(LicenseParams params) throws Exception; + void onVerifyLicense(LicenseParams params) throws Exception; } } diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/perf/LightStopwatch.java b/hugegraph-common/src/main/java/org/apache/hugegraph/perf/LightStopwatch.java index 1f63de73..ca81082e 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/perf/LightStopwatch.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/perf/LightStopwatch.java @@ -135,8 +135,7 @@ public long totalChildrenWasted() { @Override public void fillChildrenTotal(List children) { // Fill total times of children - this.totalChildrenTimes = children.stream().mapToLong( - c -> c.totalTimes()).sum(); + this.totalChildrenTimes = children.stream().mapToLong(Stopwatch::totalTimes).sum(); } @Override diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/perf/NormalStopwatch.java b/hugegraph-common/src/main/java/org/apache/hugegraph/perf/NormalStopwatch.java index 8b8aa069..c595a343 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/perf/NormalStopwatch.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/perf/NormalStopwatch.java @@ -184,11 +184,9 @@ public long totalChildrenWasted() { @Override public void fillChildrenTotal(List children) { // Fill total wasted cost of children - this.totalChildrenWasted = children.stream().mapToLong( - c -> c.totalWasted()).sum(); + this.totalChildrenWasted = children.stream().mapToLong(Stopwatch::totalWasted).sum(); // Fill total times of children - this.totalChildrenTimes = children.stream().mapToLong( - c -> c.totalTimes()).sum(); + this.totalChildrenTimes = children.stream().mapToLong(Stopwatch::totalTimes).sum(); } @Override diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/perf/PerfUtil.java b/hugegraph-common/src/main/java/org/apache/hugegraph/perf/PerfUtil.java index 62bd713e..1918f269 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/perf/PerfUtil.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/perf/PerfUtil.java @@ -681,8 +681,8 @@ public void clear() { @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.METHOD, ElementType.CONSTRUCTOR }) - public static @interface Watched { - public String value() default ""; - public String prefix() default ""; + public @interface Watched { + String value() default ""; + String prefix() default ""; } } diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/perf/Stopwatch.java b/hugegraph-common/src/main/java/org/apache/hugegraph/perf/Stopwatch.java index 074869d9..9d095c92 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/perf/Stopwatch.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/perf/Stopwatch.java @@ -23,40 +23,40 @@ public interface Stopwatch extends Cloneable { - public Path id(); - public String name(); - public Path parent(); + Path id(); + String name(); + Path parent(); - public void startTime(long startTime); - public void endTime(long startTime); + void startTime(long startTime); + void endTime(long startTime); - public void lastStartTime(long startTime); + void lastStartTime(long startTime); - public long times(); - public long totalTimes(); - public long totalChildrenTimes(); + long times(); + long totalTimes(); + long totalChildrenTimes(); - public long totalCost(); - public void totalCost(long otherCost); + long totalCost(); + void totalCost(long otherCost); - public long minCost(); - public long maxCost(); + long minCost(); + long maxCost(); - public long totalWasted(); - public long totalSelfWasted(); - public long totalChildrenWasted(); + long totalWasted(); + long totalSelfWasted(); + long totalChildrenWasted(); - public void fillChildrenTotal(List children); + void fillChildrenTotal(List children); - public Stopwatch copy(); + Stopwatch copy(); - public Stopwatch child(String name); - public Stopwatch child(String name, Stopwatch watch); + Stopwatch child(String name); + Stopwatch child(String name, Stopwatch watch); - public boolean empty(); - public void clear(); + boolean empty(); + void clear(); - public default String toJson() { + default String toJson() { int len = 200 + this.name().length() + this.parent().length(); StringBuilder sb = new StringBuilder(len); sb.append("{"); @@ -75,14 +75,14 @@ public default String toJson() { return sb.toString(); } - public static Path id(Path parent, String name) { + static Path id(Path parent, String name) { if (parent == Path.EMPTY && name == Path.ROOT_NAME) { return Path.EMPTY; } return new Path(parent, name); } - public static final class Path implements Comparable { + final class Path implements Comparable { public static final String ROOT_NAME = "root"; public static final Path EMPTY = new Path(""); diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java b/hugegraph-common/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java index bf156b8e..276a8fe0 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java @@ -435,11 +435,11 @@ private static PoolingHttpClientConnectionManager connectionManager( String url, ClientConfig conf) { String protocol = (String) conf.getProperty("protocol"); - if (protocol == null || protocol.equals("http")) { + if (protocol == null || "http".equals(protocol)) { return new PoolingHttpClientConnectionManager(TTL, TimeUnit.HOURS); } - assert protocol.equals("https"); + assert "https".equals(protocol); String trustStoreFile = (String) conf.getProperty("trustStoreFile"); E.checkArgument(trustStoreFile != null && !trustStoreFile.isEmpty(), "The trust store file must be set when use https"); diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/rest/RestClient.java b/hugegraph-common/src/main/java/org/apache/hugegraph/rest/RestClient.java index 3e095d53..06347b3b 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/rest/RestClient.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/rest/RestClient.java @@ -24,31 +24,45 @@ import jakarta.ws.rs.core.MultivaluedMap; public interface RestClient { + /** + * Post method + */ + RestResult post(String path, Object object); - public RestResult post(String path, Object object); - public RestResult post(String path, Object object, - MultivaluedMap headers); - public RestResult post(String path, Object object, - Map params); - public RestResult post(String path, Object object, - MultivaluedMap headers, - Map params); - - public RestResult put(String path, String id, Object object); - public RestResult put(String path, String id, Object object, - MultivaluedMap headers); - public RestResult put(String path, String id, Object object, - Map params); - public RestResult put(String path, String id, Object object, - MultivaluedMap headers, - Map params); - - public RestResult get(String path); - public RestResult get(String path, Map params); - public RestResult get(String path, String id); - - public RestResult delete(String path, Map params); - public RestResult delete(String path, String id); - - public void close(); + RestResult post(String path, Object object, MultivaluedMap headers); + + RestResult post(String path, Object object, Map params); + + RestResult post(String path, Object object, MultivaluedMap headers, + Map params); + + /** + * Put method + */ + RestResult put(String path, String id, Object object); + + RestResult put(String path, String id, Object object, MultivaluedMap headers); + + RestResult put(String path, String id, Object object, Map params); + + RestResult put(String path, String id, Object object, MultivaluedMap headers, + Map params); + + /** + * Get method + */ + RestResult get(String path); + + RestResult get(String path, Map params); + + RestResult get(String path, String id); + + /** + * Delete method + */ + RestResult delete(String path, Map params); + + RestResult delete(String path, String id); + + void close(); } diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/testutil/Assert.java b/hugegraph-common/src/main/java/org/apache/hugegraph/testutil/Assert.java index 284c5721..519d2053 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/testutil/Assert.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/testutil/Assert.java @@ -42,9 +42,7 @@ public interface ThrowableConsumer { public static void assertThrows(Class throwable, ThrowableRunnable runnable) { CompletableFuture future = assertThrowsFuture(throwable, runnable); - future.thenAccept(e -> { - System.err.println(e); - }); + future.thenAccept(System.err::println); } public static void assertThrows(Class throwable, diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/util/CheckSocket.java b/hugegraph-common/src/main/java/org/apache/hugegraph/util/CheckSocket.java index 99243882..96d83e38 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/util/CheckSocket.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/util/CheckSocket.java @@ -47,8 +47,8 @@ public static void main(String[] args) { Integer.parseInt(args[1])); s.close(); System.exit(0); - } catch (IOException ignored) { - System.err.println(ignored.toString()); + } catch (IOException e) { + System.err.println(e); System.exit(E_FAILED); } } diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/util/CollectionUtil.java b/hugegraph-common/src/main/java/org/apache/hugegraph/util/CollectionUtil.java index c1f3404e..6e04858b 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/util/CollectionUtil.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/util/CollectionUtil.java @@ -150,7 +150,7 @@ public static Collection intersect(Collection first, E.checkNotNull(first, "first"); E.checkNotNull(second, "second"); - HashSet results = null; + HashSet results; if (first instanceof HashSet) { @SuppressWarnings("unchecked") HashSet clone = (HashSet) ((HashSet) first).clone(); @@ -303,7 +303,7 @@ public static List> cnm(List all, int n, int m) { * @param n m of C(n, m) * @param m n of C(n, m) * @return true if matched any kind of items combination else false, the - * callback can always return false if want to traverse all combinations + * callback can always return false if you want to traverse all combinations */ public static boolean cnm(List all, int n, int m, Function, Boolean> callback) { @@ -317,9 +317,9 @@ public static boolean cnm(List all, int n, int m, * @param n n of C(n, m) * @param m m of C(n, m) * @param current current position in list - * @param selected list to contains selected items + * @param selected list to contain selected items * @return true if matched any kind of items combination else false, the - * callback can always return false if want to traverse all combinations + * callback can always return false if you want to traverse all combinations */ private static boolean cnm(List all, int n, int m, int current, List selected, @@ -360,11 +360,7 @@ private static boolean cnm(List all, int n, int m, // Not select current item, pop it and continue to select C(m-1, n) selected.remove(index); assert selected.size() == index : selected; - if (cnm(all, n - 1, m, current, selected, callback)) { - return true; - } - - return false; + return cnm(all, n - 1, m, current, selected, callback); } /** @@ -399,7 +395,7 @@ public static List> anm(List all, int n, int m) { * @param n m of A(n, m) * @param m n of A(n, m) * @return true if matched any kind of items combination else false, the - * callback can always return false if want to traverse all combinations + * callback can always return false if you want to traverse all combinations */ public static boolean anm(List all, int n, int m, Function, Boolean> callback) { @@ -412,9 +408,9 @@ public static boolean anm(List all, int n, int m, * @param all list to contain all items for combination * @param n m of A(n, m) * @param m n of A(n, m) - * @param selected list to contains selected items + * @param selected list to contain selected items * @return true if matched any kind of items combination else false, the - * callback can always return false if want to traverse all combinations + * callback can always return false if you want to traverse all combinations */ private static boolean anm(List all, int n, int m, List selected, diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/util/NumericUtil.java b/hugegraph-common/src/main/java/org/apache/hugegraph/util/NumericUtil.java index d9dd1904..f567a895 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/util/NumericUtil.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/util/NumericUtil.java @@ -40,7 +40,7 @@ private NumericUtil() { * long. The value is converted by getting their IEEE 754 * floating-point "double format" bit layout and then some bits * are swapped, to be able to compare the result as long. By this the - * precision is not reduced, but the value can easily used as a long. The + * precision is not reduced, but the value can be easily used as a long. The * sort order (including {@link Double#NaN}) is defined by * {@link Double#compareTo}; {@code NaN} is greater than positive infinity. * @param value input double value @@ -66,7 +66,7 @@ public static double sortableLongToDouble(long value) { * int. The value is converted by getting their IEEE 754 * floating-point "float format" bit layout and then some bits are * swapped, to be able to compare the result as int. By this the precision - * is not reduced, but the value can easily used as an int. The sort order + * is not reduced, but the value can be easily used as an int. The sort order * (including {@link Float#NaN}) is defined by {@link Float#compareTo}; * {@code NaN} is greater than positive infinity. * @param value input float value @@ -100,7 +100,7 @@ public static long sortableDoubleBits(long bits) { /** * Converts IEEE 754 representation of a float to sortable order (or back to * the original) - * @param bits The int format of an float value + * @param bits The int format of a float value * @return The sortable int value */ public static int sortableFloatBits(int bits) { diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/util/UnitUtil.java b/hugegraph-common/src/main/java/org/apache/hugegraph/util/UnitUtil.java index e21ed9e6..138fed9c 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/util/UnitUtil.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/util/UnitUtil.java @@ -156,7 +156,7 @@ public static long timestampFromReadableString(String valueWithUnit) { } else { // Not exists days int msPos = formatDuration.indexOf("MS"); - // If contains ms, rmove the ms part + // If contains ms, remove the ms part if (msPos >= 0) { int sPos = formatDuration.indexOf("S"); if (0 <= sPos && sPos < msPos) { diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/util/VersionUtil.java b/hugegraph-common/src/main/java/org/apache/hugegraph/util/VersionUtil.java index 57c9eb7c..4bd76f77 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/util/VersionUtil.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/util/VersionUtil.java @@ -94,7 +94,7 @@ public static String getImplementationVersion(Class clazz) { public static String getImplementationVersion(String manifestPath) { manifestPath += "/META-INF/MANIFEST.MF"; - Manifest manifest = null; + Manifest manifest; try { manifest = new Manifest(new URL(manifestPath).openStream()); } catch (IOException ignored) { diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/date/SafeDateFormatTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/date/SafeDateFormatTest.java index 6c9e89ed..68bad8c3 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/date/SafeDateFormatTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/date/SafeDateFormatTest.java @@ -109,7 +109,7 @@ public void testTimeZone() throws ParseException { SafeDateFormat sdf = new SafeDateFormat("yyyy-MM-dd HH:mm:ss"); sdf.setTimeZone("GMT+10"); - Assert.assertEquals(df.getTimeZone(), sdf.getTimeZome()); + Assert.assertEquals(df.getTimeZone(), sdf.getTimeZone()); Assert.assertEquals(df.parse("2019-08-10 00:00:00"), sdf.parse("2019-08-10 00:00:00")); Assert.assertEquals("2019-08-10 00:00:00", @@ -118,7 +118,7 @@ public void testTimeZone() throws ParseException { sdf.format(sdf.parse("2019-08-10 00:00:00"))); sdf.setTimeZone("GMT+11"); - Assert.assertNotEquals(df.getTimeZone(), sdf.getTimeZome()); + Assert.assertNotEquals(df.getTimeZone(), sdf.getTimeZone()); Assert.assertNotEquals(df.parse("2019-08-10 00:00:00"), sdf.parse("2019-08-10 00:00:00")); Assert.assertEquals("2019-08-10 00:00:00", diff --git a/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServiceConfig4Client.java b/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServiceConfig4Client.java index 51b59c4a..333f0abc 100644 --- a/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServiceConfig4Client.java +++ b/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServiceConfig4Client.java @@ -21,17 +21,17 @@ public interface RpcServiceConfig4Client { - public T serviceProxy(String interfaceId); + T serviceProxy(String interfaceId); - public T serviceProxy(String graph, String interfaceId); + T serviceProxy(String graph, String interfaceId); - public default T serviceProxy(Class clazz) { + default T serviceProxy(Class clazz) { return this.serviceProxy(clazz.getName()); } - public default T serviceProxy(String graph, Class clazz) { + default T serviceProxy(String graph, Class clazz) { return this.serviceProxy(graph, clazz.getName()); } - public void removeAllServiceProxy(); + void removeAllServiceProxy(); } diff --git a/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServiceConfig4Server.java b/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServiceConfig4Server.java index 9c0a0e51..03593504 100644 --- a/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServiceConfig4Server.java +++ b/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServiceConfig4Server.java @@ -21,12 +21,12 @@ public interface RpcServiceConfig4Server { - public String addService(Class clazz, S serviceImpl); + String addService(Class clazz, S serviceImpl); - public String addService(String graph, + String addService(String graph, Class clazz, S serviceImpl); - public void removeService(String serviceId); + void removeService(String serviceId); - public void removeAllService(); + void removeAllService(); } diff --git a/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ExceptionTest.java b/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ExceptionTest.java index 9ca812a5..c70d00b7 100644 --- a/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ExceptionTest.java +++ b/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ExceptionTest.java @@ -30,7 +30,7 @@ public class ExceptionTest { public void testExceptionWithMessage() { RpcException e = new RpcException("test"); Assert.assertEquals("test", e.getMessage()); - Assert.assertEquals(null, e.getCause()); + Assert.assertNull(e.getCause()); } @Test @@ -45,7 +45,7 @@ public void testExceptionWithMessageAndCause() { public void testExceptionWithMessageAndArgs() { RpcException e = new RpcException("test %s", 168); Assert.assertEquals("test 168", e.getMessage()); - Assert.assertEquals(null, e.getCause()); + Assert.assertNull(e.getCause()); } @Test diff --git a/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ServerClientTest.java b/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ServerClientTest.java index 590749e1..7f73a9af 100644 --- a/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ServerClientTest.java +++ b/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ServerClientTest.java @@ -682,9 +682,7 @@ public void testServerDisabled() { RpcServer rpcServerDisabled = new RpcServer(clientConf); Assert.assertFalse(rpcServerDisabled.enabled()); - Assert.assertThrows(IllegalArgumentException.class, () -> { - rpcServerDisabled.config(); - }, e -> { + Assert.assertThrows(IllegalArgumentException.class, rpcServerDisabled::config, e -> { Assert.assertContains("RpcServer is not enabled", e.getMessage()); }); @@ -697,9 +695,7 @@ public void testClientDisabled() { RpcClientProvider rpcClientDisabled = new RpcClientProvider(serverConf); Assert.assertFalse(rpcClientDisabled.enabled()); - Assert.assertThrows(IllegalArgumentException.class, () -> { - rpcClientDisabled.config(); - }, e -> { + Assert.assertThrows(IllegalArgumentException.class, rpcClientDisabled::config, e -> { Assert.assertContains("RpcClient is not enabled", e.getMessage()); });