Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: empty label exception should be labelCanNotBeNull() #2063

Merged
merged 8 commits into from
Dec 30, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.UUID;
import java.util.function.Supplier;

import org.apache.commons.lang3.ObjectUtils;
import org.apache.hugegraph.HugeGraph;
import org.apache.hugegraph.backend.id.EdgeId;
import org.apache.hugegraph.backend.id.Id;
Expand All @@ -55,6 +56,8 @@
import org.apache.hugegraph.util.E;
import org.apache.hugegraph.util.InsertionOrderUtil;

import com.alipay.remoting.util.StringUtils;
seagle-yuan marked this conversation as resolved.
Show resolved Hide resolved

public abstract class HugeElement implements Element, GraphType, Idfiable {

private static final MutableIntObjectMap<HugeProperty<?>> EMPTY_MAP =
Expand Down Expand Up @@ -430,15 +433,19 @@ public static final ElementKeys classifyKeys(Object... keyValues) {
throw Element.Exceptions
.providedKeyValuesMustHaveALegalKeyOnEvenIndices();
}
if (val == null) {
if (key.equals(T.label)) {

if(ObjectUtils.isEmpty(val)) {
if (val == null && key.equals(T.label)) {
throw Element.Exceptions.labelCanNotBeNull();
seagle-yuan marked this conversation as resolved.
Show resolved Hide resolved
} else if (key.equals(T.label)) {
throw Element.Exceptions.labelCanNotBeEmpty();
}
throw Property.Exceptions.propertyDoesNotExist();
}

if (key.equals(T.id)) {
elemKeys.id = val;

seagle-yuan marked this conversation as resolved.
Show resolved Hide resolved
} else if (key.equals(T.label)) {
elemKeys.label = val;
} else {
Expand Down