Issue #984 Improve module listing

Fixed cycle in logging from gcloud datastore
This commit is contained in:
Greg Wilkins 2016-10-14 15:42:12 +11:00
parent 9bbd191a69
commit b11757a1e2
8 changed files with 52 additions and 18 deletions

View File

@ -7,8 +7,8 @@ gcloud
[depends]
gcloud
jcl-api
jcl-impl
jcl-slf4j
slf4j-impl
[files]
maven://com.google.cloud/google-cloud-datastore/0.3.0|lib/gcloud/google-cloud-datastore-0.3.0.jar

View File

@ -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}
*/
@SuppressWarnings("Duplicates")
public class TopologicalSort<T>
{
private final Map<T,Set<T>> _dependencies = new HashMap<>();
@ -126,9 +125,16 @@ public class TopologicalSort<T>
ordered_deps.addAll(dependencies);
// recursively visit each dependency
try
{
for (T d:ordered_deps)
visit(d,visited,sorted,comparator);
}
catch (CyclicException e)
{
throw new CyclicException(item,e);
}
}
// Now that we have visited all our dependencies, they and their
// 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))
// 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!
throw new IllegalStateException("cyclic at "+item);
throw new CyclicException(item);
}
@ -182,4 +188,17 @@ public class TopologicalSort<T>
{
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);
}
}
}

View File

@ -1,2 +1,2 @@
EX|IllegalStateException
EX|CyclicException
EX|cyclic

View File

@ -1,2 +1,2 @@
EX|IllegalStateException
EX|CyclicException
EX|cyclic

View File

@ -11,8 +11,8 @@ internal
slf4j-api
[provides]
jcl-impl
jcl-api
jcl-impl
[files]
maven://org.slf4j/jcl-over-slf4j/${slf4j.version}|lib/slf4j/jcl-over-slf4j-${slf4j.version}.jar

View File

@ -11,9 +11,6 @@ internal
slf4j-api
resources
[provide]
slf4j-impl
[files]
maven://org.slf4j/slf4j-simple/${slf4j.version}|lib/slf4j/slf4j-simple-${slf4j.version}.jar
basehome:modules/slf4j/simplelogger.properties|resources/simplelogger.properties

View File

@ -9,7 +9,7 @@ internal
[depend]
slf4j-api
jcl-api
jcl-impl
[provide]
slf4j-impl

View File

@ -20,7 +20,6 @@ package org.eclipse.jetty.util;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
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.Dumpable;
import org.eclipse.jetty.util.component.DumpableCollection;
/**
@ -131,9 +129,16 @@ public class TopologicalSort<T> implements Dumpable
ordered_deps.addAll(dependencies);
// recursively visit each dependency
try
{
for (T d:ordered_deps)
visit(d,visited,sorted,comparator);
}
catch (CyclicException e)
{
throw new CyclicException(item,e);
}
}
// Now that we have visited all our dependencies, they and their
// 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))
// 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!
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()));
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);
}
}
}