Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -16,6 +16,8 @@
*/
package com.alipay.sofa.isle.deployment;

import com.alipay.sofa.boot.error.ErrorCode;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -251,6 +253,9 @@ public final void addDependsOnMe(Entry<K, T> entry) {
if (dependsOnMe == null) {
dependsOnMe = new HashSet<>();
}
if (this.equals(entry)) {
throw new IllegalArgumentException(ErrorCode.convert("01-12001", this.getKey()));
}
dependsOnMe.add(entry);
}

Expand All @@ -262,6 +267,9 @@ public void addDependency(Entry<K, T> entry) {
if (dependencies == null) {
dependencies = new CopyOnWriteArraySet<>();
}
if (this.equals(entry)) {
throw new IllegalArgumentException(ErrorCode.convert("01-12001", this.getKey()));
}
dependencies.add(entry);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 com.alipay.sofa.isle.test;

import com.alipay.sofa.isle.deployment.DependencyTree;
import org.junit.Assert;
import org.junit.Test;

/**
* @author huzijie
* @version DependencyTreeTest.java, v 0.1 2022年06月22日 11:45 AM huzijie Exp $
*/
public class DependencyTreeTest {

@Test
public void testSelfDependencyCheck() {
DependencyTree<String, String> dependencyTree = new DependencyTree<>();

try {
dependencyTree.add("A", "", "A");
Assert.fail();
} catch (Throwable e) {
Assert.assertTrue(e.getMessage().contains("01-12001"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

##Module dependency error
01-12000=Modules that could not install(Mainly due to module dependency not satisfied)
01-12001=Module could not depend on itself: [%s]

##Module profile error
01-13000=Must specify at least one sofa module profile,at least one profile value is %s
Expand Down