Issue #984 Improve module listing
Fixed cycle in logging from gcloud datastore
This commit is contained in:
parent
9bbd191a69
commit
b11757a1e2
|
@ -7,8 +7,8 @@ gcloud
|
||||||
|
|
||||||
[depends]
|
[depends]
|
||||||
gcloud
|
gcloud
|
||||||
jcl-api
|
jcl-slf4j
|
||||||
jcl-impl
|
slf4j-impl
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
maven://com.google.cloud/google-cloud-datastore/0.3.0|lib/gcloud/google-cloud-datastore-0.3.0.jar
|
maven://com.google.cloud/google-cloud-datastore/0.3.0|lib/gcloud/google-cloud-datastore-0.3.0.jar
|
||||||
|
|
|
@ -45,7 +45,6 @@ import java.util.TreeSet;
|
||||||
*
|
*
|
||||||
* @param <T> The type to be sorted. It must be able to be added to a {@link HashSet}
|
* @param <T> The type to be sorted. It must be able to be added to a {@link HashSet}
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("Duplicates")
|
|
||||||
public class TopologicalSort<T>
|
public class TopologicalSort<T>
|
||||||
{
|
{
|
||||||
private final Map<T,Set<T>> _dependencies = new HashMap<>();
|
private final Map<T,Set<T>> _dependencies = new HashMap<>();
|
||||||
|
@ -126,9 +125,16 @@ public class TopologicalSort<T>
|
||||||
ordered_deps.addAll(dependencies);
|
ordered_deps.addAll(dependencies);
|
||||||
|
|
||||||
// recursively visit each dependency
|
// recursively visit each dependency
|
||||||
|
try
|
||||||
|
{
|
||||||
for (T d:ordered_deps)
|
for (T d:ordered_deps)
|
||||||
visit(d,visited,sorted,comparator);
|
visit(d,visited,sorted,comparator);
|
||||||
}
|
}
|
||||||
|
catch (CyclicException e)
|
||||||
|
{
|
||||||
|
throw new CyclicException(item,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Now that we have visited all our dependencies, they and their
|
// Now that we have visited all our dependencies, they and their
|
||||||
// dependencies will have been added to the sorted list. So we can
|
// dependencies will have been added to the sorted list. So we can
|
||||||
|
@ -138,7 +144,7 @@ public class TopologicalSort<T>
|
||||||
else if (!sorted.contains(item))
|
else if (!sorted.contains(item))
|
||||||
// If we have already visited an item, but it has not yet been put in the
|
// If we have already visited an item, but it has not yet been put in the
|
||||||
// sorted list, then we must be in a cycle!
|
// sorted list, then we must be in a cycle!
|
||||||
throw new IllegalStateException("cyclic at "+item);
|
throw new CyclicException(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -182,4 +188,17 @@ public class TopologicalSort<T>
|
||||||
{
|
{
|
||||||
return "TopologicalSort "+_dependencies;
|
return "TopologicalSort "+_dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class CyclicException extends IllegalStateException
|
||||||
|
{
|
||||||
|
CyclicException(Object item)
|
||||||
|
{
|
||||||
|
super("cyclic at "+item);
|
||||||
|
}
|
||||||
|
|
||||||
|
CyclicException(Object item,CyclicException e)
|
||||||
|
{
|
||||||
|
super("cyclic at "+item,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
EX|IllegalStateException
|
EX|CyclicException
|
||||||
EX|cyclic
|
EX|cyclic
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
EX|IllegalStateException
|
EX|CyclicException
|
||||||
EX|cyclic
|
EX|cyclic
|
||||||
|
|
|
@ -11,8 +11,8 @@ internal
|
||||||
slf4j-api
|
slf4j-api
|
||||||
|
|
||||||
[provides]
|
[provides]
|
||||||
jcl-impl
|
|
||||||
jcl-api
|
jcl-api
|
||||||
|
jcl-impl
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
maven://org.slf4j/jcl-over-slf4j/${slf4j.version}|lib/slf4j/jcl-over-slf4j-${slf4j.version}.jar
|
maven://org.slf4j/jcl-over-slf4j/${slf4j.version}|lib/slf4j/jcl-over-slf4j-${slf4j.version}.jar
|
||||||
|
|
|
@ -11,9 +11,6 @@ internal
|
||||||
slf4j-api
|
slf4j-api
|
||||||
resources
|
resources
|
||||||
|
|
||||||
[provide]
|
|
||||||
slf4j-impl
|
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
maven://org.slf4j/slf4j-simple/${slf4j.version}|lib/slf4j/slf4j-simple-${slf4j.version}.jar
|
maven://org.slf4j/slf4j-simple/${slf4j.version}|lib/slf4j/slf4j-simple-${slf4j.version}.jar
|
||||||
basehome:modules/slf4j/simplelogger.properties|resources/simplelogger.properties
|
basehome:modules/slf4j/simplelogger.properties|resources/simplelogger.properties
|
||||||
|
|
|
@ -9,7 +9,7 @@ internal
|
||||||
|
|
||||||
[depend]
|
[depend]
|
||||||
slf4j-api
|
slf4j-api
|
||||||
jcl-api
|
jcl-impl
|
||||||
|
|
||||||
[provide]
|
[provide]
|
||||||
slf4j-impl
|
slf4j-impl
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.eclipse.jetty.util;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -32,7 +31,6 @@ import java.util.TreeSet;
|
||||||
|
|
||||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||||
import org.eclipse.jetty.util.component.Dumpable;
|
import org.eclipse.jetty.util.component.Dumpable;
|
||||||
import org.eclipse.jetty.util.component.DumpableCollection;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,9 +129,16 @@ public class TopologicalSort<T> implements Dumpable
|
||||||
ordered_deps.addAll(dependencies);
|
ordered_deps.addAll(dependencies);
|
||||||
|
|
||||||
// recursively visit each dependency
|
// recursively visit each dependency
|
||||||
|
try
|
||||||
|
{
|
||||||
for (T d:ordered_deps)
|
for (T d:ordered_deps)
|
||||||
visit(d,visited,sorted,comparator);
|
visit(d,visited,sorted,comparator);
|
||||||
}
|
}
|
||||||
|
catch (CyclicException e)
|
||||||
|
{
|
||||||
|
throw new CyclicException(item,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Now that we have visited all our dependencies, they and their
|
// Now that we have visited all our dependencies, they and their
|
||||||
// dependencies will have been added to the sorted list. So we can
|
// dependencies will have been added to the sorted list. So we can
|
||||||
|
@ -143,7 +148,7 @@ public class TopologicalSort<T> implements Dumpable
|
||||||
else if (!sorted.contains(item))
|
else if (!sorted.contains(item))
|
||||||
// If we have already visited an item, but it has not yet been put in the
|
// If we have already visited an item, but it has not yet been put in the
|
||||||
// sorted list, then we must be in a cycle!
|
// sorted list, then we must be in a cycle!
|
||||||
throw new IllegalStateException("cyclic at "+item);
|
throw new CyclicException(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -201,4 +206,17 @@ public class TopologicalSort<T> implements Dumpable
|
||||||
out.append(String.format("TopologicalSort@%x%n",hashCode()));
|
out.append(String.format("TopologicalSort@%x%n",hashCode()));
|
||||||
ContainerLifeCycle.dump(out, indent,_dependencies.entrySet());
|
ContainerLifeCycle.dump(out, indent,_dependencies.entrySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class CyclicException extends IllegalStateException
|
||||||
|
{
|
||||||
|
CyclicException(Object item)
|
||||||
|
{
|
||||||
|
super("cyclic at "+item);
|
||||||
|
}
|
||||||
|
|
||||||
|
CyclicException(Object item,CyclicException e)
|
||||||
|
{
|
||||||
|
super("cyclic at "+item,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue