FELIX-3619: protect against concurrent in-process updates of local repository.xml, also protect static use of DateFormat when initializing bnd analyzer
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1490744 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
index 496f844..95039aa 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -421,7 +421,10 @@
properties.putAll( transformDirectives( originalInstructions ) );
Builder builder = new Builder();
- builder.setBase( getBase( currentProject ) );
+ synchronized ( BundlePlugin.class ) // protect setBase...getBndLastModified which uses static DateFormat
+ {
+ builder.setBase( getBase( currentProject ) );
+ }
builder.setProperties( sanitize( properties ) );
if ( classpath != null )
{
diff --git a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java
index 5f4039d..d4b4003 100644
--- a/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java
+++ b/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrInstall.java
@@ -138,15 +138,18 @@
Config userConfig = new Config();
update = new ObrUpdate( repositoryXml, obrXmlFile, project, mavenRepository, userConfig, log );
- update.parseRepositoryXml();
-
- updateLocalBundleMetadata( project.getArtifact(), update );
- for ( Iterator i = attachedArtifacts.iterator(); i.hasNext(); )
+ synchronized ( ObrUpdate.class ) // protect against concurrent in-process updates
{
- updateLocalBundleMetadata( ( Artifact ) i.next(), update );
- }
+ update.parseRepositoryXml();
- update.writeRepositoryXml();
+ updateLocalBundleMetadata( project.getArtifact(), update );
+ for ( Iterator i = attachedArtifacts.iterator(); i.hasNext(); )
+ {
+ updateLocalBundleMetadata( ( Artifact ) i.next(), update );
+ }
+
+ update.writeRepositoryXml();
+ }
}
catch ( Exception e )
{