refact: clean code & typo & update the name of getTimeZone (#105)
* refact: clean code & typo & update the name of getTimeZone
Typo: getTimeZome() -> getTimeZone()
And we need check/update the class used it later
* Update RestClient.java
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 8445d0a..685c72d 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -28,7 +28,7 @@
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 9724e66..6fb2d4e 100644
--- a/.github/ISSUE_TEMPLATE/question_ask.yml
+++ b/.github/ISSUE_TEMPLATE/question_ask.yml
@@ -25,7 +25,7 @@
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 eda012b..351f50c 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 @@
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 @@
}
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 @@
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 e5dba9f..ddfc8b7 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 551fe93..8676702 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 <O> Predicate<O> disallowEmpty() {
- return new Predicate<O>() {
- @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 <O> Predicate<O> allowValues(O... values) {
- return new Predicate<O>() {
- @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 <O> Predicate<List<O>> inValues(O... values) {
- return new Predicate<List<O>>() {
- @Override
- public boolean apply(@Nullable List<O> o) {
- return o != null && Arrays.asList(values).containsAll(o);
- }
- };
+ return o -> o != null && new HashSet<>(Arrays.asList(values)).containsAll(o);
}
public static <N extends Number> Predicate<N> positiveInt() {
- return new Predicate<N>() {
- @Override
- public boolean apply(@Nullable N number) {
- return number != null && number.longValue() > 0;
- }
- };
+ return number -> number != null && number.longValue() > 0;
}
public static <N extends Number> Predicate<N> nonNegativeInt() {
- return new Predicate<N>() {
- @Override
- public boolean apply(@Nullable N number) {
- return number != null && number.longValue() >= 0;
- }
- };
+ return number -> number != null && number.longValue() >= 0;
}
public static <N extends Number> Predicate<N> rangeInt(N min, N max) {
- return new Predicate<N>() {
- @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 <N extends Number> Predicate<N> rangeDouble(N min, N max) {
- return new Predicate<N>() {
- @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 0deba51..9f9a665 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 @@
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 0e426fc..2db8347 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 @@
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 a0deb4c..3810926 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 @@
* @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 b381d42..d84c26f 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 <T1, T2, T3, R> {
- 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 d4e690f..a07f3e4 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 @@
return true;
}
- Iterator<T> first = null;
+ Iterator<T> 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 2f7d81f..777e468 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 7378899..f87b9eb 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 1f63de7..ca81082 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 @@
@Override
public void fillChildrenTotal(List<Stopwatch> 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 8b8aa06..c595a34 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 @@
@Override
public void fillChildrenTotal(List<Stopwatch> 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 62bd713..1918f26 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 @@
@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 074869d..9d095c9 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<Stopwatch> children);
+ void fillChildrenTotal(List<Stopwatch> 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 @@
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<Path> {
+ final class Path implements Comparable<Path> {
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 bf156b8..276a8fe 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 @@
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 3e095d5..06347b3 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<String, Object> headers);
- public RestResult post(String path, Object object,
- Map<String, Object> params);
- public RestResult post(String path, Object object,
- MultivaluedMap<String, Object> headers,
- Map<String, Object> params);
+ RestResult post(String path, Object object, MultivaluedMap<String, Object> headers);
- public RestResult put(String path, String id, Object object);
- public RestResult put(String path, String id, Object object,
- MultivaluedMap<String, Object> headers);
- public RestResult put(String path, String id, Object object,
- Map<String, Object> params);
- public RestResult put(String path, String id, Object object,
- MultivaluedMap<String, Object> headers,
- Map<String, Object> params);
+ RestResult post(String path, Object object, Map<String, Object> params);
- public RestResult get(String path);
- public RestResult get(String path, Map<String, Object> params);
- public RestResult get(String path, String id);
+ RestResult post(String path, Object object, MultivaluedMap<String, Object> headers,
+ Map<String, Object> params);
- public RestResult delete(String path, Map<String, Object> params);
- public RestResult delete(String path, String id);
+ /**
+ * Put method
+ */
+ RestResult put(String path, String id, Object object);
- public void close();
+ RestResult put(String path, String id, Object object, MultivaluedMap<String, Object> headers);
+
+ RestResult put(String path, String id, Object object, Map<String, Object> params);
+
+ RestResult put(String path, String id, Object object, MultivaluedMap<String, Object> headers,
+ Map<String, Object> params);
+
+ /**
+ * Get method
+ */
+ RestResult get(String path);
+
+ RestResult get(String path, Map<String, Object> params);
+
+ RestResult get(String path, String id);
+
+ /**
+ * Delete method
+ */
+ RestResult delete(String path, Map<String, Object> 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 284c572..519d205 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 static void assertThrows(Class<? extends Throwable> 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<? extends Throwable> 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 9924388..96d83e3 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 @@
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 c1f3404..6e04858 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 @@
E.checkNotNull(first, "first");
E.checkNotNull(second, "second");
- HashSet<T> results = null;
+ HashSet<T> results;
if (first instanceof HashSet) {
@SuppressWarnings("unchecked")
HashSet<T> clone = (HashSet<T>) ((HashSet<T>) first).clone();
@@ -303,7 +303,7 @@
* @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 <T> boolean cnm(List<T> all, int n, int m,
Function<List<T>, Boolean> callback) {
@@ -317,9 +317,9 @@
* @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 <T> boolean cnm(List<T> all, int n, int m,
int current, List<T> selected,
@@ -360,11 +360,7 @@
// 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 @@
* @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 <T> boolean anm(List<T> all, int n, int m,
Function<List<T>, Boolean> callback) {
@@ -412,9 +408,9 @@
* @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 <T> boolean anm(List<T> all, int n, int m,
List<Integer> 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 d9dd190..f567a89 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 @@
* <code>long</code>. 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 @@
* <code>int</code>. 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 @@
/**
* 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 e21ed9e..138fed9 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 @@
} 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 57c9eb7..4bd76f7 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(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 6c9e89e..68bad8c 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 @@
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 @@
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 51b59c4..333f0ab 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> T serviceProxy(String interfaceId);
+ <T> T serviceProxy(String interfaceId);
- public <T> T serviceProxy(String graph, String interfaceId);
+ <T> T serviceProxy(String graph, String interfaceId);
- public default <T> T serviceProxy(Class<T> clazz) {
+ default <T> T serviceProxy(Class<T> clazz) {
return this.serviceProxy(clazz.getName());
}
- public default <T> T serviceProxy(String graph, Class<T> clazz) {
+ default <T> T serviceProxy(String graph, Class<T> 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 9c0a0e5..0359350 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 <T, S extends T> String addService(Class<T> clazz, S serviceImpl);
+ <T, S extends T> String addService(Class<T> clazz, S serviceImpl);
- public <T, S extends T> String addService(String graph,
+ <T, S extends T> String addService(String graph,
Class<T> 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 9ca812a..c70d00b 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 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 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 590749e..7f73a9a 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 @@
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 @@
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());
});