479343 calls to MetaData#orderFragments() with relative ordering adds duplicate jars

This commit is contained in:
Jan Bartel 2015-10-09 10:48:16 +11:00
parent 7bb1cce754
commit 2bdb4e7474
2 changed files with 25 additions and 4 deletions

View File

@ -146,6 +146,10 @@ public interface Ordering
@Override
public List<Resource> order(List<Resource> jars)
{
_beforeOthers.clear();
_afterOthers.clear();
_noOthers.clear();
//for each jar, put it into the ordering according to the fragment ordering
for (Resource jar:jars)
{
@ -157,17 +161,17 @@ public interface Ordering
{
case None:
{
((RelativeOrdering)_metaData.getOrdering()).addNoOthers(jar);
addNoOthers(jar);
break;
}
case Before:
{
((RelativeOrdering)_metaData.getOrdering()).addBeforeOthers(jar);
addBeforeOthers(jar);
break;
}
case After:
{
((RelativeOrdering)_metaData.getOrdering()).addAfterOthers(jar);
addAfterOthers(jar);
break;
}
}
@ -175,7 +179,7 @@ public interface Ordering
else
{
//jar fragment has no descriptor, but there is a relative ordering in place, so it must be part of the others
((RelativeOrdering)_metaData.getOrdering()).addNoOthers(jar);
addNoOthers(jar);
}
}

View File

@ -18,6 +18,7 @@
package org.eclipse.jetty.webapp;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@ -504,6 +505,22 @@ public class OrderingTest
fail ("No outcome matched "+result);
}
@Test
public void testOrderFragments() throws Exception
{
final MetaData metadata = new MetaData();
final Resource jarResource = new TestResource("A");
metadata.setOrdering(new Ordering.RelativeOrdering(metadata));
metadata.addWebInfJar(jarResource);
metadata.orderFragments();
assertEquals(1, metadata.getOrderedWebInfJars().size());
metadata.orderFragments();
assertEquals(1, metadata.getOrderedWebInfJars().size());
}
@Test
public void testCircular1 ()
throws Exception