The substring matching algorithm had a couple bugs in it. (FELIX-2107)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@912085 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/util/Util.java b/framework/src/main/java/org/apache/felix/framework/util/Util.java
index 8545707..3f5f8ae 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/Util.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/Util.java
@@ -619,16 +619,26 @@
// assert (pieces.length > 1)
// minimal case is <string>*<string>
- boolean result = false;
+ boolean result = true;
int len = pieces.length;
+ int index = 0;
+
loop: for (int i = 0; i < len; i++)
{
String piece = pieces[i];
- int index = 0;
- if (i == len - 1)
+ // initial non-star; assert index == 0
+ if (i == 0)
{
- // this is the last piece
+ if (!s.startsWith(piece))
+ {
+ result = false;
+ break loop;
+ }
+ }
+ // this is the last piece
+ else if (i == len - 1)
+ {
if (s.endsWith(piece))
{
result = true;
@@ -639,15 +649,6 @@
}
break loop;
}
- // initial non-star; assert index == 0
- else if (i == 0)
- {
- if (!s.startsWith(piece))
- {
- result = false;
- break loop;
- }
- }
// assert i > 0 && i < len-1
else
{