Modified RequirementImpl to throw an invalid syntax exception instead of
swallowing it, which required further modifications to LocalRepositoryImpl
to ignore resources with invalid filters. (FELIX-484)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@654898 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/LocalRepositoryImpl.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/LocalRepositoryImpl.java
index 86fd362..3dc348b 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/LocalRepositoryImpl.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/LocalRepositoryImpl.java
@@ -98,7 +98,16 @@
// convert the bundle headers to the appropriate resource metadata.
for (int i = 0; (bundles != null) && (i < bundles.length); i++)
{
- m_localResourceList.add(new LocalResourceImpl(bundles[i]));
+ try
+ {
+ m_localResourceList.add(new LocalResourceImpl(bundles[i]));
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ // This should never happen since we are generating filters,
+ // but ignore the resource if it does occur.
+ System.err.println(ex);
+ }
}
}
@@ -106,12 +115,13 @@
{
private Bundle m_bundle = null;
- LocalResourceImpl(Bundle bundle)
+ LocalResourceImpl(Bundle bundle) throws InvalidSyntaxException
{
this(null, bundle);
}
LocalResourceImpl(ResourceImpl resource, Bundle bundle)
+ throws InvalidSyntaxException
{
super(resource);
m_bundle = bundle;
@@ -123,7 +133,7 @@
return m_bundle;
}
- private void initialize()
+ private void initialize() throws InvalidSyntaxException
{
Dictionary dict = m_bundle.getHeaders();
@@ -232,6 +242,7 @@
}
private void convertImportPackageToRequirement(Dictionary dict)
+ throws InvalidSyntaxException
{
String target = (String) dict.get(Constants.IMPORT_PACKAGE);
if (target != null)
@@ -271,13 +282,14 @@
+ imports[impIdx].getName() + ")"
+ low + ")");
}
-
+
addRequire(req);
}
}
}
private void convertImportServiceToRequirement(Dictionary dict)
+ throws InvalidSyntaxException
{
String target = (String) dict.get(Constants.IMPORT_SERVICE);
if (target != null)
@@ -329,4 +341,4 @@
}
}
}
-}
+}
\ No newline at end of file
diff --git a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RequirementImpl.java b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RequirementImpl.java
index 9287b06..0a8d951 100644
--- a/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RequirementImpl.java
+++ b/bundlerepository/src/main/java/org/apache/felix/bundlerepository/RequirementImpl.java
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -52,17 +52,9 @@
return m_filter.toString();
}
- public synchronized void setFilter(String filter)
+ public synchronized void setFilter(String filter) throws InvalidSyntaxException
{
- try
- {
- m_filter = RepositoryAdminImpl.m_context.createFilter(filter);
- }
- catch (InvalidSyntaxException ex)
- {
- m_filter = null;
- System.err.println(ex);
- }
+ m_filter = RepositoryAdminImpl.m_context.createFilter(filter);
}
public synchronized boolean isSatisfied(Capability capability)