From 3a7ed21517a29fff819307ff1d3f703ca99fbe70 Mon Sep 17 00:00:00 2001 From: imbajin Date: Fri, 14 Oct 2022 00:42:00 +0800 Subject: [PATCH 1/8] feat(apache): support check license header with RAT use `apache-rat:check` to see the report and fix current license problems TODO: we should add & use apache-rat plugin in other repos later BTW, we'd reuse such configs better (rather than copy them in each repo) --- hugegraph-common/build.sh | 16 ++++++ hugegraph-common/pom.xml | 18 ++++++- .../unit/concurrent/BarrierEventTest.java | 21 +++++++- .../src/test/resources/log4j2.xml | 16 ++++++ hugegraph-rpc/pom.xml | 18 ++++++- hugegraph-rpc/src/test/resources/log4j2.xml | 16 ++++++ pom.xml | 53 +++++++++++++++++++ 7 files changed, 155 insertions(+), 3 deletions(-) diff --git a/hugegraph-common/build.sh b/hugegraph-common/build.sh index e6479e3f4..b0eef4596 100644 --- a/hugegraph-common/build.sh +++ b/hugegraph-common/build.sh @@ -1,4 +1,20 @@ #!/usr/bin/env bash +# +# 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. +# export MAVEN_HOME=/home/scmtools/buildkit/maven/apache-maven-3.3.9/ export JAVA_HOME=/home/scmtools/buildkit/java/jdk1.8.0_25/ diff --git a/hugegraph-common/pom.xml b/hugegraph-common/pom.xml index 1c3637bfb..2a47ea8f6 100644 --- a/hugegraph-common/pom.xml +++ b/hugegraph-common/pom.xml @@ -1,4 +1,20 @@ + @@ -11,7 +27,7 @@ hugegraph-common - ${artifactId} + ${project.artifactId} https://github.com/apache/incubator-hugegraph-commons/tree/master/hugegraph-common hugegraph-common is a common module for HugeGraph and its peripheral components. diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java index c40a2f2ea..bc69386a3 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java @@ -1,3 +1,22 @@ +/* + * Copyright 2017 HugeGraph Authors + * + * 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.hugegraph.unit.concurrent; import java.util.concurrent.CountDownLatch; @@ -13,7 +32,7 @@ public class BarrierEventTest { - private static int WAIT_THREADS_COUNT = 10; + private static final int WAIT_THREADS_COUNT = 10; @Test(timeout = 5000) public void testAWait() throws InterruptedException { diff --git a/hugegraph-common/src/test/resources/log4j2.xml b/hugegraph-common/src/test/resources/log4j2.xml index 15600fcad..5ada1de62 100644 --- a/hugegraph-common/src/test/resources/log4j2.xml +++ b/hugegraph-common/src/test/resources/log4j2.xml @@ -1,4 +1,20 @@ + diff --git a/hugegraph-rpc/pom.xml b/hugegraph-rpc/pom.xml index 924c5dee0..54f8403a0 100644 --- a/hugegraph-rpc/pom.xml +++ b/hugegraph-rpc/pom.xml @@ -1,4 +1,20 @@ + @@ -11,7 +27,7 @@ hugegraph-rpc - ${artifactId} + ${project.artifactId} HugeGraph RPC component diff --git a/hugegraph-rpc/src/test/resources/log4j2.xml b/hugegraph-rpc/src/test/resources/log4j2.xml index 033c5b887..e84e39584 100644 --- a/hugegraph-rpc/src/test/resources/log4j2.xml +++ b/hugegraph-rpc/src/test/resources/log4j2.xml @@ -1,4 +1,20 @@ + diff --git a/pom.xml b/pom.xml index 6b4a83703..c49e83ec2 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,20 @@ + @@ -164,6 +180,43 @@ + + + org.apache.rat + apache-rat-plugin + + + **/*.versionsBackup + **/*.log + **/*.txt + **/*.json + **/*.conf + **/*.properties + dist/**/* + docs/**/* + scripts/dev/reviewers + **/*.md + **/dependency-reduced-pom.xml + **/logs/*.log + **/target/* + style/* + ChangeLog + CONFIG.ini + GROUPS + OWNERS + + .github/**/* + + **/*.iml + **/*.iws + **/*.ipr + **/META-INF/MANIFEST.MF + + .repository/** + + true + + From 10716b232d7c71f49485975cc44ab254eae57fb3 Mon Sep 17 00:00:00 2001 From: imbajin Date: Wed, 19 Oct 2022 21:12:52 +0800 Subject: [PATCH 2/8] separate some changes --- hugegraph-common/pom.xml | 2 +- .../org/apache/hugegraph/unit/concurrent/BarrierEventTest.java | 2 +- hugegraph-rpc/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hugegraph-common/pom.xml b/hugegraph-common/pom.xml index 2a47ea8f6..a188f9faa 100644 --- a/hugegraph-common/pom.xml +++ b/hugegraph-common/pom.xml @@ -27,7 +27,7 @@ hugegraph-common - ${project.artifactId} + ${artifactId} https://github.com/apache/incubator-hugegraph-commons/tree/master/hugegraph-common hugegraph-common is a common module for HugeGraph and its peripheral components. diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java index bc69386a3..64a0d49be 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java @@ -32,7 +32,7 @@ public class BarrierEventTest { - private static final int WAIT_THREADS_COUNT = 10; + private static int WAIT_THREADS_COUNT = 10; @Test(timeout = 5000) public void testAWait() throws InterruptedException { diff --git a/hugegraph-rpc/pom.xml b/hugegraph-rpc/pom.xml index 54f8403a0..ba61ba637 100644 --- a/hugegraph-rpc/pom.xml +++ b/hugegraph-rpc/pom.xml @@ -27,7 +27,7 @@ hugegraph-rpc - ${project.artifactId} + ${artifactId} HugeGraph RPC component From 13aaea4019251f27fa2b1f1d46105043d1fef6cf Mon Sep 17 00:00:00 2001 From: imbajin Date: Wed, 19 Oct 2022 21:32:56 +0800 Subject: [PATCH 3/8] enable rat in ci --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e319c49df..755f1c23c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,6 +39,11 @@ jobs: with: fetch-depth: 2 + - name: License check(RAT) + run: | + mvn apache-rat:check | grep -v "Downloading\|Downloaded\|Progress" + find ./ -name rat.txt -print0 | xargs -0 -I file cat file > merged-rat.txt && cat merged-rat.txt + - name: Compile run: | mvn compile -Dmaven.javadoc.skip=true | grep -v "Downloading\|Downloaded" From 8b1c1a86089677fcdfd1dec3471accf11221d37f Mon Sep 17 00:00:00 2001 From: imbajin Date: Wed, 19 Oct 2022 21:53:14 +0800 Subject: [PATCH 4/8] refact: improve some code This reverts commit e58f5d4c632f2095bacac1d29bafe1cbbb9fb8bb. --- hugegraph-common/pom.xml | 2 +- .../org/apache/hugegraph/unit/concurrent/BarrierEventTest.java | 2 +- hugegraph-rpc/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hugegraph-common/pom.xml b/hugegraph-common/pom.xml index a188f9faa..2a47ea8f6 100644 --- a/hugegraph-common/pom.xml +++ b/hugegraph-common/pom.xml @@ -27,7 +27,7 @@ hugegraph-common - ${artifactId} + ${project.artifactId} https://github.com/apache/incubator-hugegraph-commons/tree/master/hugegraph-common hugegraph-common is a common module for HugeGraph and its peripheral components. diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java index 64a0d49be..bc69386a3 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java @@ -32,7 +32,7 @@ public class BarrierEventTest { - private static int WAIT_THREADS_COUNT = 10; + private static final int WAIT_THREADS_COUNT = 10; @Test(timeout = 5000) public void testAWait() throws InterruptedException { diff --git a/hugegraph-rpc/pom.xml b/hugegraph-rpc/pom.xml index ba61ba637..54f8403a0 100644 --- a/hugegraph-rpc/pom.xml +++ b/hugegraph-rpc/pom.xml @@ -27,7 +27,7 @@ hugegraph-rpc - ${artifactId} + ${project.artifactId} HugeGraph RPC component From 80b81cc431694331874587fbc454dc56af3fad4b Mon Sep 17 00:00:00 2001 From: imbajin Date: Thu, 20 Oct 2022 12:44:42 +0800 Subject: [PATCH 5/8] fix(sec): upgrade a string of dependencies to address CVEs report --- hugegraph-common/pom.xml | 5 ----- hugegraph-rpc/pom.xml | 5 ----- pom.xml | 12 ++++++------ 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/hugegraph-common/pom.xml b/hugegraph-common/pom.xml index 2a47ea8f6..862c3d775 100644 --- a/hugegraph-common/pom.xml +++ b/hugegraph-common/pom.xml @@ -211,7 +211,6 @@ maven-compiler-plugin - 3.1 ${compiler.source} ${compiler.target} @@ -226,7 +225,6 @@ org.apache.maven.plugins maven-jar-plugin - 2.6 true @@ -281,7 +279,6 @@ org.apache.maven.plugins maven-source-plugin - 2.2.1 attach-sources @@ -294,7 +291,6 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9.1 attach-javadocs @@ -307,7 +303,6 @@ org.apache.maven.plugins maven-gpg-plugin - 1.5 sign-artifacts diff --git a/hugegraph-rpc/pom.xml b/hugegraph-rpc/pom.xml index 54f8403a0..2a29065cb 100644 --- a/hugegraph-rpc/pom.xml +++ b/hugegraph-rpc/pom.xml @@ -104,7 +104,6 @@ maven-compiler-plugin - 3.1 ${compiler.source} ${compiler.target} @@ -119,7 +118,6 @@ org.apache.maven.plugins maven-jar-plugin - 2.6 true @@ -174,7 +172,6 @@ org.apache.maven.plugins maven-source-plugin - 2.2.1 attach-sources @@ -187,7 +184,6 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9.1 attach-javadocs @@ -200,7 +196,6 @@ org.apache.maven.plugins maven-gpg-plugin - 1.5 sign-artifacts diff --git a/pom.xml b/pom.xml index c49e83ec2..0f405cff5 100644 --- a/pom.xml +++ b/pom.xml @@ -60,21 +60,21 @@ ${project.basedir}/.. 1.8 1.8 - 2.17.0 + 2.18.0 1.10 - 2.3 + 2.8.0 1.9.4 3.2.2 2.7 - 1.11 - 25.1-jre + 1.13 + 30.0-jre 1.0 3.0.1 3.28.0-GA 3.0.3 3.0.3 - 2.12.1 - 4.12 + 2.14.0-rc1 + 4.13.1 4.1.0 4.0.0-RC2 3.0.2 From d14792aebc468696cd24435fa4739b3ed3ff59d0 Mon Sep 17 00:00:00 2001 From: imbajin Date: Thu, 20 Oct 2022 13:01:06 +0800 Subject: [PATCH 6/8] adopt error message with junit-4.13 --- .../java/org/apache/hugegraph/testutil/AssertTest.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/testutil/AssertTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/testutil/AssertTest.java index 7116adc8b..efe8eaf9d 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/testutil/AssertTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/testutil/AssertTest.java @@ -192,9 +192,7 @@ public void testAssertThrowsWithError() { }); Assert.fail("Expect error"); } catch (AssertionError e) { - Assert.assertEquals("No exception was thrown" + - "(expected java.lang.NullPointerException)", - e.getMessage()); + Assert.assertContains("java.lang.NullPointerException", e.getMessage()); } try { @@ -203,10 +201,8 @@ public void testAssertThrowsWithError() { }); Assert.fail("Expect error"); } catch (AssertionError e) { - Assert.assertEquals("Bad exception type " + - "java.lang.RuntimeException" + - "(expected java.lang.NullPointerException)", - e.getMessage()); + Assert.assertContains("java.lang.NullPointerException", e.getMessage()); + Assert.assertContains("java.lang.RuntimeException", e.getMessage()); } } From 459f8df976198cb00567becec1f4866ab2bf7b1f Mon Sep 17 00:00:00 2001 From: imbajin Date: Fri, 21 Oct 2022 16:51:30 +0800 Subject: [PATCH 7/8] clean code (31 files) --- .../iterator/BatchMapperIterator.java | 1 + .../org/apache/hugegraph/perf/PerfUtil.java | 5 +- .../hugegraph/rest/AbstractRestClient.java | 2 +- .../apache/hugegraph/util/LongEncoding.java | 6 +- .../apache/hugegraph/util/OrderLimitMap.java | 3 +- .../apache/hugegraph/util/ReflectionUtil.java | 13 +- .../org/apache/hugegraph/util/UnitUtil.java | 3 +- .../apache/hugegraph/util/VersionUtil.java | 3 +- .../apache/hugegraph/testutil/AssertTest.java | 10 +- .../unit/concurrent/LockGroupTest.java | 2 +- .../PausableScheduledThreadPoolTest.java | 4 +- .../hugegraph/unit/config/HugeConfigTest.java | 6 +- .../hugegraph/unit/event/EventHubTest.java | 113 ++++-------------- .../iterator/BatchMapperIteratorTest.java | 20 +--- .../unit/iterator/ExtendableIteratorTest.java | 20 +--- .../unit/iterator/FilterIteratorTest.java | 20 +--- .../FlatMapperFilterIteratorTest.java | 28 ++--- .../unit/iterator/FlatMapperIteratorTest.java | 20 +--- .../unit/iterator/LimitIteratorTest.java | 20 +--- .../unit/iterator/ListIteratorTest.java | 56 +++------ .../unit/iterator/MapperIteratorTest.java | 23 +--- .../hugegraph/unit/perf/StopwatchTest.java | 48 ++++---- .../apache/hugegraph/unit/util/BytesTest.java | 6 +- .../hugegraph/unit/util/LongEncodingTest.java | 4 +- .../hugegraph/unit/util/NumericUtilTest.java | 64 +++++----- .../unit/util/ReflectionUtilTest.java | 2 +- .../hugegraph/unit/util/StringUtilTest.java | 11 +- .../hugegraph/unit/util/UnitUtilTest.java | 4 +- .../hugegraph/unit/util/VersionUtilTest.java | 3 +- .../rpc/RpcServiceConfig4Server.java | 3 +- .../hugegraph/unit/ServerClientTest.java | 10 +- 31 files changed, 184 insertions(+), 349 deletions(-) diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/BatchMapperIterator.java b/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/BatchMapperIterator.java index 79f9e87bd..39be041e5 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/BatchMapperIterator.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/BatchMapperIterator.java @@ -25,6 +25,7 @@ import org.apache.hugegraph.util.E; import org.apache.hugegraph.util.InsertionOrderUtil; + import com.google.common.collect.ImmutableList; public class BatchMapperIterator extends WrappedIterator { 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 1918f2692..39cface3d 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 @@ -361,7 +361,8 @@ public String toECharts() { sb.append("',"); sb.append("value:"); - sb.append(w.totalCost()); // w.totalCost() - w.totalWasted() ? + // w.totalCost() - w.totalWasted() ? + sb.append(w.totalCost()); sb.append(','); sb.append("cost:"); @@ -419,7 +420,7 @@ public String toECharts() { return c.parent().equals(parent.id()); }); // Fill other cost - long sumCost = children.mapToLong(c -> c.totalCost()).sum(); + long sumCost = children.mapToLong(Stopwatch::totalCost).sum(); long otherCost = parent.totalCost() - sumCost; if (otherCost > 0L) { Stopwatch other = newStopwatch("~", parent.id()); 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 276a8fe0a..fd9fdaba2 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 @@ -589,7 +589,7 @@ public ClientConfig build() { public static class BearerRequestFilter implements ClientRequestFilter { @Override - public void filter(ClientRequestContext context) throws IOException { + public void filter(ClientRequestContext context) { String token = context.getClient().getConfiguration() .getProperty(TOKEN_KEY).toString(); context.getHeaders().add(HttpHeaders.AUTHORIZATION, diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/util/LongEncoding.java b/hugegraph-common/src/main/java/org/apache/hugegraph/util/LongEncoding.java index 3488445f7..24c857fd0 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/util/LongEncoding.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/util/LongEncoding.java @@ -40,8 +40,7 @@ public static String encodeNumber(Object number) { public static Number decodeNumber(String str, Class clazz) { long value = decodeSortable(str); - Number number = NumericUtil.sortableLongToNumber(value, clazz); - return number; + return NumericUtil.sortableLongToNumber(value, clazz); } public static String encodeSortable(long num) { @@ -130,10 +129,11 @@ public static long decode(String encoded, String symbols) { for (char ch : encoded.toCharArray()) { num *= B; int pos = symbols.indexOf(ch); - if (pos < 0) + if (pos < 0) { throw new NumberFormatException(String.format( "Can't decode symbol '%s' in string '%s'", ch, encoded)); + } num += pos; } return num; diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/util/OrderLimitMap.java b/hugegraph-common/src/main/java/org/apache/hugegraph/util/OrderLimitMap.java index e286ca934..d8b0cc6ff 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/util/OrderLimitMap.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/util/OrderLimitMap.java @@ -27,7 +27,8 @@ import com.google.common.collect.Ordering; /** - * Reference: https://stackoverflow.com/questions/109383/sort-a-mapkey-value-by-values + * Reference: + * ... */ public class OrderLimitMap, V extends Comparable> extends TreeMap { diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/util/ReflectionUtil.java b/hugegraph-common/src/main/java/org/apache/hugegraph/util/ReflectionUtil.java index 853086912..812a962ae 100644 --- a/hugegraph-common/src/main/java/org/apache/hugegraph/util/ReflectionUtil.java +++ b/hugegraph-common/src/main/java/org/apache/hugegraph/util/ReflectionUtil.java @@ -39,14 +39,11 @@ public final class ReflectionUtil { public static boolean isSimpleType(Class type) { - if (type.isPrimitive() || - type.equals(String.class) || - type.equals(Boolean.class) || - type.equals(Character.class) || - NumericUtil.isNumber(type)) { - return true; - } - return false; + return type.isPrimitive() || + type.equals(String.class) || + type.equals(Boolean.class) || + type.equals(Character.class) || + NumericUtil.isNumber(type); } public static List getMethodsAnnotatedWith( 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 138fed9cd..30c1beee0 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 @@ -20,6 +20,7 @@ package org.apache.hugegraph.util; import java.math.BigDecimal; +import java.math.RoundingMode; import java.time.Duration; public final class UnitUtil { @@ -34,7 +35,7 @@ public static double bytesToGB(long bytes) { public static double doubleWith2Scale(double value) { BigDecimal decimal = new BigDecimal(value); - return decimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + return decimal.setScale(2, RoundingMode.HALF_UP).doubleValue(); } public static String bytesToReadableString(long bytes) { 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 4bd76f771..cc98fa1c5 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 @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; +import java.util.Objects; import java.util.jar.Attributes; import java.util.jar.Manifest; @@ -79,7 +80,7 @@ public static String getImplementationVersion(Class clazz) { * https://stackoverflow.com/questions/1272648/reading-my-own-jars-manifest */ String className = clazz.getSimpleName() + ".class"; - String classPath = clazz.getResource(className).toString(); + String classPath = Objects.requireNonNull(clazz.getResource(className)).toString(); if (!classPath.startsWith("jar:file:")) { // Class not from JAR return null; diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/testutil/AssertTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/testutil/AssertTest.java index efe8eaf9d..0f30bbd2c 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/testutil/AssertTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/testutil/AssertTest.java @@ -126,7 +126,7 @@ public void testAssertEqualsOfIntWithError() { }); Assert.assertThrows(AssertionError.class, () -> { - Assert.assertEquals(1, (Long) 1l); + Assert.assertEquals(1, (Long) 1L); }, e -> { Assert.assertContains("expected: java.lang.Integer", e.getMessage()); @@ -250,7 +250,7 @@ public void testAssertGt() { }); Assert.assertThrows(AssertionError.class, () -> { - Assert.assertGt(1, Character.valueOf('2')); + Assert.assertGt(1, '2'); }, e -> { Assert.assertContains("Expected: an instance of java.lang.Integer", e.getMessage()); @@ -308,7 +308,7 @@ public void testAssertGte() { }); Assert.assertThrows(AssertionError.class, () -> { - Assert.assertGte(1, Character.valueOf('2')); + Assert.assertGte(1, '2'); }, e -> { Assert.assertContains("Expected: an instance of java.lang.Integer", e.getMessage()); @@ -338,7 +338,7 @@ public void testAssertLt() { }); Assert.assertThrows(AssertionError.class, () -> { - Assert.assertGt(1, Character.valueOf('0')); + Assert.assertGt(1, '0'); }, e -> { Assert.assertContains("Expected: an instance of java.lang.Integer", e.getMessage()); @@ -375,7 +375,7 @@ public void testAssertLte() { }); Assert.assertThrows(AssertionError.class, () -> { - Assert.assertLte(1, Character.valueOf('0')); + Assert.assertLte(1, '0'); }, e -> { Assert.assertContains("Expected: an instance of java.lang.Integer", e.getMessage()); diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/LockGroupTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/LockGroupTest.java index 3309a43b2..0d0d06430 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/LockGroupTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/LockGroupTest.java @@ -37,7 +37,7 @@ public class LockGroupTest extends BaseUnitTest { private static final String GROUP = "LockGroupTest-test-group"; - private LockGroup group = new LockGroup(GROUP); + private final LockGroup group = new LockGroup(GROUP); @Test public void testLock() { diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/PausableScheduledThreadPoolTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/PausableScheduledThreadPoolTest.java index fb66741d3..a477344de 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/PausableScheduledThreadPoolTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/PausableScheduledThreadPoolTest.java @@ -31,7 +31,7 @@ public class PausableScheduledThreadPoolTest { @Test - public void testscheduleWithFixedDelay() throws InterruptedException { + public void testScheduleWithFixedDelay() throws InterruptedException { PausableScheduledThreadPool executor = ExecutorUtil.newPausableScheduledThreadPool("test"); long period = 500L; @@ -64,7 +64,7 @@ public void testscheduleWithFixedDelay() throws InterruptedException { } @Test - public void testscheduleWithFixedRate() throws InterruptedException { + public void testScheduleWithFixedRate() throws InterruptedException { PausableScheduledThreadPool executor = ExecutorUtil.newPausableScheduledThreadPool(2, "test"); long period = 500L; diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/config/HugeConfigTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/config/HugeConfigTest.java index 01ffb316b..7664f7847 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/config/HugeConfigTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/config/HugeConfigTest.java @@ -99,8 +99,8 @@ public void testOptionDesc() { @Test public void testOptionRequired() { - Assert.assertEquals(false, TestOptions.text1.required()); - Assert.assertEquals(true, TestSubOptions.text2.required()); + Assert.assertFalse(TestOptions.text1.required()); + Assert.assertTrue(TestSubOptions.text2.required()); } @Test @@ -670,6 +670,6 @@ protected boolean forList() { public enum WeekDay { - SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY; + SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } } diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/event/EventHubTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/event/EventHubTest.java index c8743e99a..b5b159195 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/event/EventHubTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/event/EventHubTest.java @@ -80,12 +80,7 @@ public void testEventGetListenerNonResult() { public void testEventAddListener() { final String event = "event-test"; - EventListener listener = new EventListener() { - @Override - public Object event(Event arg0) { - return null; - } - }; + EventListener listener = (Event e) -> null; this.eventHub.listen(event, listener); @@ -98,12 +93,7 @@ public Object event(Event arg0) { public void testEventAddListenerTwice() { final String event = "event-test"; - EventListener listener = new EventListener() { - @Override - public Object event(Event arg0) { - return null; - } - }; + EventListener listener = (Event e) -> null; this.eventHub.listen(event, listener); this.eventHub.listen(event, listener); @@ -118,12 +108,7 @@ public Object event(Event arg0) { public void testEventRemoveListener() { final String event = "event-test"; - EventListener listener = new EventListener() { - @Override - public Object event(Event arg0) { - return null; - } - }; + EventListener listener = (Event e) -> null; this.eventHub.listen(event, listener); @@ -141,12 +126,7 @@ public Object event(Event arg0) { public void testEventRemoveListenerButNonResult() { final String event = "event-test"; - EventListener listener = new EventListener() { - @Override - public Object event(Event arg0) { - return null; - } - }; + EventListener listener = (Event e) -> null; this.eventHub.listen(event, listener); @@ -167,12 +147,7 @@ public void testEventRemoveListenerOfOneInTwo() { final String event1 = "event-test1"; final String event2 = "event-test2"; - EventListener listener = new EventListener() { - @Override - public Object event(Event arg0) { - return null; - } - }; + EventListener listener = (Event e) -> null; this.eventHub.listen(event1, listener); this.eventHub.listen(event2, listener); @@ -200,19 +175,8 @@ public Object event(Event arg0) { public void testEventRemoveListenerByEvent() { final String event = "event-test"; - EventListener listener1 = new EventListener() { - @Override - public Object event(Event arg0) { - return null; - } - }; - - EventListener listener2 = new EventListener() { - @Override - public Object event(Event arg0) { - return null; - } - }; + EventListener listener1 = (Event e) -> null; + EventListener listener2 = (Event e) -> null; this.eventHub.listen(event, listener1); this.eventHub.listen(event, listener2); @@ -232,19 +196,8 @@ public Object event(Event arg0) { public void testEventRemoveListenerByEventButNonResult() { final String event = "event-test"; - EventListener listener1 = new EventListener() { - @Override - public Object event(Event arg0) { - return null; - } - }; - - EventListener listener2 = new EventListener() { - @Override - public Object event(Event arg0) { - return null; - } - }; + EventListener listener1 = (Event e) -> null; + EventListener listener2 = (Event e) -> null; this.eventHub.listen(event, listener1); this.eventHub.listen(event, listener2); @@ -263,12 +216,7 @@ public Object event(Event arg0) { public void testEventRemoveListenerByEventOf2SameListener() { final String event = "event-test"; - EventListener listener = new EventListener() { - @Override - public Object event(Event arg0) { - return null; - } - }; + EventListener listener = (Event e) -> null; this.eventHub.listen(event, listener); this.eventHub.listen(event, listener); @@ -446,27 +394,21 @@ public void testEventNotifyWithArg2() { public void testEventNotifyWithMultiThreads() throws InterruptedException { final String notify = "event-notify"; - EventListener listener1 = new EventListener() { - @Override - public Object event(Event event) { - Assert.assertEquals(notify, event.name()); - event.checkArgs(Integer.class); - return null; - } + EventListener listener1 = event -> { + Assert.assertEquals(notify, event.name()); + event.checkArgs(Integer.class); + return null; }; - EventListener listener2 = new EventListener() { - @Override - public Object event(Event event) { - Assert.assertEquals(notify, event.name()); + EventListener listener2 = event -> { + Assert.assertEquals(notify, event.name()); - event.checkArgs(Integer.class); - int i = (int) event.args()[0]; - if (i % 10000 == 0) { - System.out.println("On event '" + notify + "': " + i); - } - return null; + event.checkArgs(Integer.class); + int i = (int) event.args()[0]; + if (i % 10000 == 0) { + System.out.println("On event '" + notify + "': " + i); } + return null; }; Thread listenerUpdateThread = new Thread(() -> { @@ -503,15 +445,12 @@ public Object event(Event event) { public void testEventCallWithMultiThreads() { final String call = "event-call"; - EventListener listener = new EventListener() { - @Override - public Object event(Event event) { - Assert.assertEquals(call, event.name()); + EventListener listener = event -> { + Assert.assertEquals(call, event.name()); - event.checkArgs(Integer.class); - int i = (int) event.args()[0]; - return i; - } + event.checkArgs(Integer.class); + int i = (int) event.args()[0]; + return i; }; this.eventHub.listen(call, listener); diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/BatchMapperIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/BatchMapperIteratorTest.java index 40a39a217..78bd08cb0 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/BatchMapperIteratorTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/BatchMapperIteratorTest.java @@ -123,12 +123,8 @@ public void testHasNextAndNextWithMultiTimes() { Assert.assertFalse(results.hasNext()); Assert.assertFalse(results.hasNext()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -159,9 +155,7 @@ public void testNextWithMultiTimes() { for (int i = 0; i < 2; i++) { results.next(); } - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -281,12 +275,8 @@ public void testMapperReturnNullThenNext() { results = new BatchMapperIterator<>(1, DATA3.iterator(), batch -> { return null; }); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ExtendableIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ExtendableIteratorTest.java index e753ea8ea..fc1e9f3ba 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ExtendableIteratorTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ExtendableIteratorTest.java @@ -89,9 +89,7 @@ public void testExtendAfterHasNext() { public void testNext() { Iterator results = new ExtendableIterator<>(DATA1.iterator()); Assert.assertEquals(1, (int) results.next()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -101,9 +99,7 @@ public void testNextWithMultiTimes() { Assert.assertEquals(1, (int) results.next()); Assert.assertEquals(2, (int) results.next()); Assert.assertEquals(3, (int) results.next()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -114,9 +110,7 @@ public void testHasNextAndNext() { Assert.assertEquals(1, (int) results.next()); Assert.assertFalse(results.hasNext()); Assert.assertFalse(results.hasNext()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -143,15 +137,11 @@ public void testRemove() { @Test public void testRemoveWithoutResult() { Iterator results = new ExtendableIterator<>(); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.remove(); - }); + Assert.assertThrows(NoSuchElementException.class, results::remove); List list = new ArrayList<>(); Iterator results2 = new ExtendableIterator<>(list.iterator()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results2.remove(); - }); + Assert.assertThrows(NoSuchElementException.class, results2::remove); } @Test diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FilterIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FilterIteratorTest.java index f6c0e1758..845c5c642 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FilterIteratorTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FilterIteratorTest.java @@ -95,12 +95,8 @@ public void testHasNextAndNextWithMultiTimes() { Assert.assertFalse(results.hasNext()); Assert.assertFalse(results.hasNext()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -120,9 +116,7 @@ public void testNextWithMultiTimes() { for (int i = 0; i < 4; i++) { results.next(); } - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -130,12 +124,8 @@ public void testNextWithMultiTimesWithoutAnyResult() { Iterator vals = DATA.iterator(); Iterator results = new FilterIterator<>(vals, val -> false); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperFilterIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperFilterIteratorTest.java index 536f38a3e..5370fe335 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperFilterIteratorTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperFilterIteratorTest.java @@ -94,9 +94,7 @@ public void testHasNext() { key -> DATA.get(key).iterator(), val -> false); Assert.assertFalse(results2.hasNext()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results2.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results2::next); } @Test @@ -113,12 +111,8 @@ public void testHasNextWithMultiTimes() { results.next(); } Assert.assertFalse(results.hasNext()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); + Assert.assertThrows(NoSuchElementException.class, results::next); Iterator results2 = new FlatMapperFilterIterator<>(keys, key -> DATA.get(key).iterator(), @@ -140,9 +134,7 @@ public void testNext() { Iterator results2 = new FlatMapperFilterIterator<>(keys, key -> DATA.get(key).iterator(), val -> false); - Assert.assertThrows(NoSuchElementException.class, () -> { - results2.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results2::next); } @Test @@ -155,19 +147,13 @@ public void testNextWithMultiTimes() { for (int i = 0; i < 10; i++) { results.next(); } - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); Iterator results2 = new FlatMapperFilterIterator<>(keys, key -> DATA.get(key).iterator(), val -> false); - Assert.assertThrows(NoSuchElementException.class, () -> { - results2.next(); - }); - Assert.assertThrows(NoSuchElementException.class, () -> { - results2.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results2::next); + Assert.assertThrows(NoSuchElementException.class, results2::next); } @Test diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperIteratorTest.java index 5e5baf461..f286dd47b 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperIteratorTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperIteratorTest.java @@ -107,12 +107,8 @@ public void testHasNextAndNextWithMultiTimes() { Assert.assertFalse(results.hasNext()); Assert.assertFalse(results.hasNext()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -132,9 +128,7 @@ public void testNextWithMultiTimes() { for (int i = 0; i < 10; i++) { results.next(); } - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -157,12 +151,8 @@ public void testMapperReturnNullThenNext() { Assert.assertNull(DATA.get(key)); return null; }); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/LimitIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/LimitIteratorTest.java index f806b5e62..9a9f7ca0d 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/LimitIteratorTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/LimitIteratorTest.java @@ -95,12 +95,8 @@ public void testHasNextAndNextWithMultiTimes() { Assert.assertFalse(results.hasNext()); Assert.assertFalse(results.hasNext()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); + Assert.assertThrows(NoSuchElementException.class, results::next); Iterator results2 = new LimitIterator<>(vals, val -> false); Assert.assertFalse(results2.hasNext()); @@ -123,9 +119,7 @@ public void testNextWithMultiTimes() { for (int i = 0; i < 4; i++) { results.next(); } - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -133,12 +127,8 @@ public void testNextWithMultiTimesWithoutAnyResult() { Iterator vals = DATA.iterator(); Iterator results = new LimitIterator<>(vals, val -> true); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ListIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ListIteratorTest.java index d8334344a..d6949bf5f 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ListIteratorTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ListIteratorTest.java @@ -100,9 +100,7 @@ public void testHasNext() { public void testNext() { Iterator results = new ListIterator<>(-1, DATA1.iterator()); Assert.assertEquals(1, (int) results.next()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -111,9 +109,7 @@ public void testNextAfterList() { Assert.assertEquals(ImmutableList.of(1), ((ListIterator) results).list()); Assert.assertEquals(1, (int) results.next()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -121,9 +117,7 @@ public void testNextWithMultiTimes() { Iterator results = new ListIterator<>(-1, DATA2.iterator()); Assert.assertEquals(2, (int) results.next()); Assert.assertEquals(3, (int) results.next()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -134,9 +128,7 @@ public void testHasNextAndNext() { Assert.assertEquals(1, (int) results.next()); Assert.assertFalse(results.hasNext()); Assert.assertFalse(results.hasNext()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -147,13 +139,9 @@ public void testRemove() { Assert.assertEquals(ImmutableList.of(4, 5, 6), list); Assert.assertEquals(ImmutableList.of(4, 5, 6), results.list()); - Assert.assertThrows(UnsupportedOperationException.class, () -> { - results.remove(); - }); + Assert.assertThrows(UnsupportedOperationException.class, results::remove); results.next(); - Assert.assertThrows(UnsupportedOperationException.class, () -> { - results.remove(); - }); + Assert.assertThrows(UnsupportedOperationException.class, results::remove); Assert.assertEquals(ImmutableList.of(4, 5, 6), list); Assert.assertEquals(ImmutableList.of(4, 5, 6), results.list()); @@ -162,15 +150,11 @@ public void testRemove() { @Test public void testRemoveWithoutResult() { Iterator results = new ListIterator<>(-1, EMPTY); - Assert.assertThrows(UnsupportedOperationException.class, () -> { - results.remove(); - }); + Assert.assertThrows(UnsupportedOperationException.class, results::remove); List list0 = new ArrayList<>(); Iterator results2 = new ListIterator<>(-1, list0.iterator()); - Assert.assertThrows(UnsupportedOperationException.class, () -> { - results2.remove(); - }); + Assert.assertThrows(UnsupportedOperationException.class, results2::remove); } @Test @@ -207,17 +191,13 @@ public void testListWithConstructFromList() { public void testHasNextAndNextWithConstructFromList() { ListIterator results0 = new ListIterator<>(ImmutableList.of()); Assert.assertFalse(results0.hasNext()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results0.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results0::next); ListIterator results1 = new ListIterator<>(DATA1); Assert.assertTrue(results1.hasNext()); Assert.assertEquals(1, results1.next()); Assert.assertFalse(results1.hasNext()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results1.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results1::next); ListIterator results3 = new ListIterator<>(DATA3); Assert.assertTrue(results3.hasNext()); @@ -227,25 +207,19 @@ public void testHasNextAndNextWithConstructFromList() { Assert.assertTrue(results3.hasNext()); Assert.assertEquals(6, results3.next()); Assert.assertFalse(results3.hasNext()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results3.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results3::next); } @Test public void testNextWithConstructFromList() { ListIterator results0 = new ListIterator<>(ImmutableList.of()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results0.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results0::next); ListIterator results3 = new ListIterator<>(DATA3); Assert.assertEquals(4, results3.next()); Assert.assertEquals(5, results3.next()); Assert.assertEquals(6, results3.next()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results3.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results3::next); } @Test @@ -255,8 +229,6 @@ public void testNextAfterListWithConstructFromList() { Assert.assertEquals(4, results3.next()); Assert.assertEquals(5, results3.next()); Assert.assertEquals(6, results3.next()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results3.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results3::next); } } diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/MapperIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/MapperIteratorTest.java index 23b2ab07e..c8878cab4 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/MapperIteratorTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/MapperIteratorTest.java @@ -46,9 +46,7 @@ public class MapperIteratorTest extends BaseUnitTest { "forth", 4 ); - private static final Function MAPPER = key -> { - return DATA.get(key); - }; + private static final Function MAPPER = DATA::get; @Test public void testMapper() { @@ -100,12 +98,8 @@ public void testHasNextAndNextWithMultiTimes() { Assert.assertFalse(results.hasNext()); Assert.assertFalse(results.hasNext()); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -125,9 +119,7 @@ public void testNextWithMultiTimes() { for (int i = 0; i < 4; i++) { results.next(); } - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -147,9 +139,7 @@ public void testMapperReturnNullThenNext() { Iterator results = new MapperIterator<>(keys, key -> { return null; }); - Assert.assertThrows(NoSuchElementException.class, () -> { - results.next(); - }); + Assert.assertThrows(NoSuchElementException.class, results::next); } @Test @@ -157,8 +147,7 @@ public void testClose() throws Exception { CloseableItor keys = new CloseableItor<>( ImmutableList.of("fifth").iterator()); - MapperIterator results = - new MapperIterator<>(keys, k -> null); + MapperIterator results = new MapperIterator<>(keys, k -> null); Assert.assertFalse(keys.closed()); results.close(); diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/perf/StopwatchTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/perf/StopwatchTest.java index dbbe4823f..63ef77d08 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/perf/StopwatchTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/perf/StopwatchTest.java @@ -49,21 +49,21 @@ public void testNormalStopwatchChild() { Assert.assertEquals(watch4, watch1.child("w4", null)); Assert.assertEquals(watch5, watch1.child("w5", null)); - Assert.assertEquals(null, watch1.child("w2")); - Assert.assertEquals(null, watch1.child("w3")); - Assert.assertEquals(null, watch1.child("w4")); - Assert.assertEquals(null, watch1.child("w5")); + Assert.assertNull(watch1.child("w2")); + Assert.assertNull(watch1.child("w3")); + Assert.assertNull(watch1.child("w4")); + Assert.assertNull(watch1.child("w5")); - Assert.assertEquals(null, watch1.child("w2", watch2)); - Assert.assertEquals(null, watch1.child("w3", watch3)); - Assert.assertEquals(null, watch1.child("w4", watch4)); - Assert.assertEquals(null, watch1.child("w5", watch5)); + Assert.assertNull(watch1.child("w2", watch2)); + Assert.assertNull(watch1.child("w3", watch3)); + Assert.assertNull(watch1.child("w4", watch4)); + Assert.assertNull(watch1.child("w5", watch5)); watch1.clear(); - Assert.assertEquals(null, watch1.child("w2")); - Assert.assertEquals(null, watch1.child("w3")); - Assert.assertEquals(null, watch1.child("w4")); - Assert.assertEquals(null, watch1.child("w5")); + Assert.assertNull(watch1.child("w2")); + Assert.assertNull(watch1.child("w3")); + Assert.assertNull(watch1.child("w4")); + Assert.assertNull(watch1.child("w5")); } @Test @@ -85,20 +85,20 @@ public void testLightStopwatchChild() { Assert.assertEquals(watch4, watch1.child("w4", null)); Assert.assertEquals(watch5, watch1.child("w5", null)); - Assert.assertEquals(null, watch1.child("w2")); - Assert.assertEquals(null, watch1.child("w3")); - Assert.assertEquals(null, watch1.child("w4")); - Assert.assertEquals(null, watch1.child("w5")); + Assert.assertNull(watch1.child("w2")); + Assert.assertNull(watch1.child("w3")); + Assert.assertNull(watch1.child("w4")); + Assert.assertNull(watch1.child("w5")); - Assert.assertEquals(null, watch1.child("w2", watch2)); - Assert.assertEquals(null, watch1.child("w3", watch3)); - Assert.assertEquals(null, watch1.child("w4", watch4)); - Assert.assertEquals(null, watch1.child("w5", watch5)); + Assert.assertNull(watch1.child("w2", watch2)); + Assert.assertNull(watch1.child("w3", watch3)); + Assert.assertNull(watch1.child("w4", watch4)); + Assert.assertNull(watch1.child("w5", watch5)); watch1.clear(); - Assert.assertEquals(null, watch1.child("w2")); - Assert.assertEquals(null, watch1.child("w3")); - Assert.assertEquals(null, watch1.child("w4")); - Assert.assertEquals(null, watch1.child("w5")); + Assert.assertNull(watch1.child("w2")); + Assert.assertNull(watch1.child("w3")); + Assert.assertNull(watch1.child("w4")); + Assert.assertNull(watch1.child("w5")); } } diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/BytesTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/BytesTest.java index 0d184a5b6..0867a7f7c 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/BytesTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/BytesTest.java @@ -63,12 +63,12 @@ public void testBytesPrefixWith() { @Test public void testBytesCompare() { - Assert.assertTrue(Bytes.compare(b("12345678"), b("12345678")) == 0); + Assert.assertEquals(0, Bytes.compare(b("12345678"), b("12345678"))); Assert.assertTrue(Bytes.compare(b("12345678"), b("1234567")) > 0); Assert.assertTrue(Bytes.compare(b("12345678"), b("12345679")) < 0); - Assert.assertTrue(Bytes.compare(new byte[]{1, 3, 5, 7}, - new byte[]{1, 3, 5, 7}) == 0); + Assert.assertEquals(0, + Bytes.compare(new byte[]{1, 3, 5, 7}, new byte[]{1, 3, 5, 7})); Assert.assertTrue(Bytes.compare(new byte[]{1, 3, 5, 7}, new byte[]{1, 3, 5, 6}) > 0); diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/LongEncodingTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/LongEncodingTest.java index 7f44340e6..a3f1518ef 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/LongEncodingTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/LongEncodingTest.java @@ -629,7 +629,7 @@ public void testEncodeSortableThenCompare() { int cmp = Bytes.compare(encoded1.getBytes(), encoded2.getBytes()); if (num1 == num2) { - Assert.assertTrue(cmp == 0); + Assert.assertEquals(0, cmp); } else if (num1 > num2) { Assert.assertTrue(cmp > 0); } else { @@ -675,7 +675,7 @@ private static void compareEncodedNumber(Number num1, Number num2) { int cmp = Bytes.compare(encoded1.getBytes(), encoded2.getBytes()); if (cmpExpected == 0) { - Assert.assertTrue(cmp == 0); + Assert.assertEquals(0, cmp); } else if (cmpExpected > 0) { Assert.assertTrue(cmp > 0); } else { diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/NumericUtilTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/NumericUtilTest.java index c6b94b1bf..5278427d0 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/NumericUtilTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/NumericUtilTest.java @@ -140,7 +140,7 @@ public void testSortableBytesToNumber() { public void testIntToSortableBytesAndCompare() { byte[] bytes1 = NumericUtil.numberToSortableBytes(123456); byte[] bytes2 = NumericUtil.numberToSortableBytes(123456); - Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0); + Assert.assertEquals(0, Bytes.compare(bytes1, bytes2)); bytes1 = NumericUtil.numberToSortableBytes(1); bytes2 = NumericUtil.numberToSortableBytes(2); @@ -156,7 +156,7 @@ public void testIntToSortableBytesAndCompare() { bytes1 = NumericUtil.numberToSortableBytes(-123456); bytes2 = NumericUtil.numberToSortableBytes(-123456); - Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0); + Assert.assertEquals(0, Bytes.compare(bytes1, bytes2)); bytes1 = NumericUtil.numberToSortableBytes(-1); bytes2 = NumericUtil.numberToSortableBytes(-2); @@ -191,7 +191,7 @@ public void testIntToSortableBytesAndCompare() { public void testLongToSortableBytesAndCompare() { byte[] bytes1 = NumericUtil.numberToSortableBytes(123456L); byte[] bytes2 = NumericUtil.numberToSortableBytes(123456L); - Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0); + Assert.assertEquals(0, Bytes.compare(bytes1, bytes2)); bytes1 = NumericUtil.numberToSortableBytes(1L); bytes2 = NumericUtil.numberToSortableBytes(2L); @@ -207,7 +207,7 @@ public void testLongToSortableBytesAndCompare() { bytes1 = NumericUtil.numberToSortableBytes(-123456L); bytes2 = NumericUtil.numberToSortableBytes(-123456L); - Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0); + Assert.assertEquals(0, Bytes.compare(bytes1, bytes2)); bytes1 = NumericUtil.numberToSortableBytes(-1L); bytes2 = NumericUtil.numberToSortableBytes(-2L); @@ -242,7 +242,7 @@ public void testLongToSortableBytesAndCompare() { public void testFloatToSortableBytesAndCompare() { byte[] bytes1 = NumericUtil.numberToSortableBytes(123456F); byte[] bytes2 = NumericUtil.numberToSortableBytes(123456F); - Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0); + Assert.assertEquals(0, Bytes.compare(bytes1, bytes2)); bytes1 = NumericUtil.numberToSortableBytes(1F); bytes2 = NumericUtil.numberToSortableBytes(2F); @@ -258,7 +258,7 @@ public void testFloatToSortableBytesAndCompare() { bytes1 = NumericUtil.numberToSortableBytes(-123456F); bytes2 = NumericUtil.numberToSortableBytes(-123456F); - Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0); + Assert.assertEquals(0, Bytes.compare(bytes1, bytes2)); bytes1 = NumericUtil.numberToSortableBytes(-1F); bytes2 = NumericUtil.numberToSortableBytes(-2F); @@ -293,7 +293,7 @@ public void testFloatToSortableBytesAndCompare() { public void testDoubleToSortableBytesAndCompare() { byte[] bytes1 = NumericUtil.numberToSortableBytes(123456D); byte[] bytes2 = NumericUtil.numberToSortableBytes(123456D); - Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0); + Assert.assertEquals(0, Bytes.compare(bytes1, bytes2)); bytes1 = NumericUtil.numberToSortableBytes(1D); bytes2 = NumericUtil.numberToSortableBytes(2D); @@ -309,7 +309,7 @@ public void testDoubleToSortableBytesAndCompare() { bytes1 = NumericUtil.numberToSortableBytes(-123456D); bytes2 = NumericUtil.numberToSortableBytes(-123456D); - Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0); + Assert.assertEquals(0, Bytes.compare(bytes1, bytes2)); bytes1 = NumericUtil.numberToSortableBytes(-1D); bytes2 = NumericUtil.numberToSortableBytes(-2D); @@ -392,28 +392,28 @@ public void testMaxValueOf() { @Test public void testIsNumber() { - Assert.assertEquals(true, NumericUtil.isNumber(byte.class)); - Assert.assertEquals(true, NumericUtil.isNumber(Byte.class)); - Assert.assertEquals(true, NumericUtil.isNumber(short.class)); - Assert.assertEquals(true, NumericUtil.isNumber(Short.class)); - Assert.assertEquals(true, NumericUtil.isNumber(int.class)); - Assert.assertEquals(true, NumericUtil.isNumber(Integer.class)); - Assert.assertEquals(true, NumericUtil.isNumber(long.class)); - Assert.assertEquals(true, NumericUtil.isNumber(Long.class)); - Assert.assertEquals(true, NumericUtil.isNumber(float.class)); - Assert.assertEquals(true, NumericUtil.isNumber(Float.class)); - Assert.assertEquals(true, NumericUtil.isNumber(double.class)); - Assert.assertEquals(true, NumericUtil.isNumber(Double.class)); - - Assert.assertEquals(false, NumericUtil.isNumber(char.class)); - Assert.assertEquals(false, NumericUtil.isNumber(Character.class)); - - Assert.assertEquals(true, NumericUtil.isNumber(1)); - Assert.assertEquals(true, NumericUtil.isNumber(1L)); - Assert.assertEquals(true, NumericUtil.isNumber(1.0f)); - Assert.assertEquals(true, NumericUtil.isNumber(1.0d)); - Assert.assertEquals(false, NumericUtil.isNumber('1')); - Assert.assertEquals(false, NumericUtil.isNumber((Object) null)); + Assert.assertTrue(NumericUtil.isNumber(byte.class)); + Assert.assertTrue(NumericUtil.isNumber(Byte.class)); + Assert.assertTrue(NumericUtil.isNumber(short.class)); + Assert.assertTrue(NumericUtil.isNumber(Short.class)); + Assert.assertTrue(NumericUtil.isNumber(int.class)); + Assert.assertTrue(NumericUtil.isNumber(Integer.class)); + Assert.assertTrue(NumericUtil.isNumber(long.class)); + Assert.assertTrue(NumericUtil.isNumber(Long.class)); + Assert.assertTrue(NumericUtil.isNumber(float.class)); + Assert.assertTrue(NumericUtil.isNumber(Float.class)); + Assert.assertTrue(NumericUtil.isNumber(double.class)); + Assert.assertTrue(NumericUtil.isNumber(Double.class)); + + Assert.assertFalse(NumericUtil.isNumber(char.class)); + Assert.assertFalse(NumericUtil.isNumber(Character.class)); + + Assert.assertTrue(NumericUtil.isNumber(1)); + Assert.assertTrue(NumericUtil.isNumber(1L)); + Assert.assertTrue(NumericUtil.isNumber(1.0f)); + Assert.assertTrue(NumericUtil.isNumber(1.0d)); + Assert.assertFalse(NumericUtil.isNumber('1')); + Assert.assertFalse(NumericUtil.isNumber((Object) null)); } @Test @@ -421,13 +421,13 @@ public void testConvertToNumber() { Assert.assertEquals(1, NumericUtil.convertToNumber(1)); Assert.assertEquals(1.2, NumericUtil.convertToNumber(1.2)); - Assert.assertEquals(new BigDecimal(1.25), + Assert.assertEquals(new BigDecimal("1.25"), NumericUtil.convertToNumber("1.25")); Date date = new Date(); Assert.assertEquals(date.getTime(), NumericUtil.convertToNumber(date)); - Assert.assertEquals(null, NumericUtil.convertToNumber(null)); + Assert.assertNull(NumericUtil.convertToNumber(null)); } @Test diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/ReflectionUtilTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/ReflectionUtilTest.java index b400f5297..6c5e62098 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/ReflectionUtilTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/ReflectionUtilTest.java @@ -122,7 +122,7 @@ public void testNestedClasses() throws NotFoundException { List classes = ReflectionUtil.nestedClasses( TestClass.class.getName()); Assert.assertEquals(5, classes.size()); - classes.sort((c1, c2) -> c1.compareTo(c2)); + classes.sort(String::compareTo); Assert.assertEquals(Bar.class.getName(), classes.get(0)); Assert.assertEquals(Base.class.getName(), classes.get(1)); Assert.assertEquals(Foo.class.getName(), classes.get(2)); diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/StringUtilTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/StringUtilTest.java index bd4e962e2..d271ae93b 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/StringUtilTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/StringUtilTest.java @@ -20,13 +20,14 @@ package org.apache.hugegraph.unit.util; import java.util.ArrayList; +import java.util.Collections; import java.util.List; -import org.junit.Test; - +import org.apache.hugegraph.testutil.Assert; import org.apache.hugegraph.util.StringUtil; import org.apache.hugegraph.util.StringUtil.Chars; -import org.apache.hugegraph.testutil.Assert; +import org.junit.Test; + import com.google.common.base.Splitter; public class StringUtilTest { @@ -155,9 +156,7 @@ private static List guavaSplit(String line, String delimiter) { private static List toStringList(String[] stringArray) { List results = new ArrayList<>(stringArray.length); - for (String str : stringArray) { - results.add(str); - } + Collections.addAll(results, stringArray); return results; } } diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/UnitUtilTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/UnitUtilTest.java index fd146b8fc..8b383034d 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/UnitUtilTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/UnitUtilTest.java @@ -33,7 +33,7 @@ public void testBytesToMB() { Assert.assertEquals(0d, value, 0d); // KB - value = UnitUtil.bytesToMB(Bytes.KB * 1); + value = UnitUtil.bytesToMB(1 * Bytes.KB); Assert.assertEquals(0d, value, 0d); value = UnitUtil.bytesToMB(Bytes.KB * 10); @@ -86,7 +86,7 @@ public void testBytesToGB() { Assert.assertEquals(0d, value, 0d); // MB - value = UnitUtil.bytesToGB(Bytes.MB * 1); + value = UnitUtil.bytesToGB(1 * Bytes.MB); Assert.assertEquals(0d, value, 0d); value = UnitUtil.bytesToGB(Bytes.MB * 10); diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/VersionUtilTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/VersionUtilTest.java index 6ed04505a..b405e7daf 100644 --- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/VersionUtilTest.java +++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/VersionUtilTest.java @@ -133,8 +133,7 @@ public void testGetImplementationVersion() throws MalformedURLException { VersionUtil.getImplementationVersion(manifestPath)); manifestPath = "file:./src/test/resources2"; - Assert.assertEquals(null, - VersionUtil.getImplementationVersion(manifestPath)); + Assert.assertNull(VersionUtil.getImplementationVersion(manifestPath)); } @Test 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 035935047..0deabfd22 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 @@ -23,8 +23,7 @@ public interface RpcServiceConfig4Server { String addService(Class clazz, S serviceImpl); - String addService(String graph, - Class clazz, S serviceImpl); + String addService(String graph, Class clazz, S serviceImpl); void removeService(String serviceId); 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 7f73a9afe..8daa37e1f 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 @@ -54,7 +54,7 @@ public static void init() { } @AfterClass - public static void clear() throws Exception { + public static void clear() { if (rpcClient != null) { rpcClient.destroy(); } @@ -711,13 +711,13 @@ public void testInitRpcConfigs() { RpcCommonConfig.initRpcConfigs(RpcOptions.CONSUMER_RETRIES, 2); } - public static interface HelloService { + public interface HelloService { - public String hello(String string); + String hello(String string); - public String echo(String string); + String echo(String string); - public double sum(long a, double b); + double sum(long a, double b); } public static class HelloServiceImpl implements HelloService { From adc98d651295296f5638487f3164141a35bb6f98 Mon Sep 17 00:00:00 2001 From: imbajin Date: Fri, 21 Oct 2022 17:15:42 +0800 Subject: [PATCH 8/8] ignore pom backup file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index fa22f5876..8053b45a7 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ target gen-java build node* +*.versionsBackup