This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
The following commit(s) were added to refs/heads/master by this push:
new 13224c4 fix two catalog/osgi edge bugs
13224c4 is described below
commit 13224c4aafdce8750655373bb655ce348a8614fa
Author: Alex Heneveld <[email protected]>
AuthorDate: Mon Jan 17 15:22:58 2022 +0000
fix two catalog/osgi edge bugs
* when uploading a zip, the manifest needs a Bundle-ManifestVersion: 2
header
* when attempting legacy parses, do not consider types in eg
brooklyn.enrichers if there is a root type also
---
.../catalog/internal/BasicBrooklynCatalog.java | 29 +++++++++++++++-------
.../mgmt/ha/BrooklynBomOsgiArchiveInstaller.java | 6 +++++
.../AbstractBrooklynLauncherRebindTest.java | 4 ++-
3 files changed, 29 insertions(+), 10 deletions(-)
diff --git
a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
index 64b578f..0a5b1e8 100644
---
a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
+++
b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
@@ -1361,9 +1361,9 @@ public class BasicBrooklynCatalog implements
BrooklynCatalog {
// as we parse using CAMP and need that
// so prefer those for now (may change with YOML)
- attemptLegacySpecTransformersForType(POLICIES_KEY,
CatalogItemType.POLICY);
- attemptLegacySpecTransformersForType(ENRICHERS_KEY,
CatalogItemType.ENRICHER);
- attemptLegacySpecTransformersForType(LOCATIONS_KEY,
CatalogItemType.LOCATION);
+ attemptLegacySpecTransformersForType(POLICIES_KEY,
CatalogItemType.POLICY, true);
+ attemptLegacySpecTransformersForType(ENRICHERS_KEY,
CatalogItemType.ENRICHER, true);
+ attemptLegacySpecTransformersForType(LOCATIONS_KEY,
CatalogItemType.LOCATION, true);
}
boolean suspicionOfABean = false;
@@ -1496,18 +1496,29 @@ public class BasicBrooklynCatalog implements
BrooklynCatalog {
}
private boolean attemptLegacySpecTransformersForType(String key,
CatalogItemType candidateCiType) {
+ return attemptLegacySpecTransformersForType(key, candidateCiType,
false);
+ }
+
+ private boolean attemptLegacySpecTransformersForType(String key,
CatalogItemType candidateCiType, boolean requireKeyAdded) {
if (resolved) return false;
if (catalogItemType!=null && catalogItemType!=candidateCiType)
return false;
final String candidateYaml;
- if (key==null) candidateYaml = itemYaml;
- else {
- if (item.containsKey(key))
- candidateYaml = itemYaml;
- else
- candidateYaml = key + ":\n" + makeAsIndentedList(itemYaml);
+ boolean keyAdded = false;
+ if (key==null) {
+ candidateYaml = itemYaml;
+ } else if (item.containsKey(key)) {
+ candidateYaml = itemYaml;
+ } else {
+ candidateYaml = key + ":\n" + makeAsIndentedList(itemYaml);
+ keyAdded = true;
}
+
String type = (String) item.get("type");
+ if (type!=null && requireKeyAdded && !keyAdded) {
+ return false;
+ }
+
if (itemsDefinedSoFar!=null) {
// first look in collected items, if a key is given
diff --git
a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/BrooklynBomOsgiArchiveInstaller.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/BrooklynBomOsgiArchiveInstaller.java
index a7d4bc4..901b00f 100644
---
a/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/BrooklynBomOsgiArchiveInstaller.java
+++
b/core/src/main/java/org/apache/brooklyn/core/mgmt/ha/BrooklynBomOsgiArchiveInstaller.java
@@ -431,6 +431,12 @@ public class BrooklynBomOsgiArchiveInstaller {
}
if
(discoveredManifest.getMainAttributes().getValue(Attributes.Name.MANIFEST_VERSION)==null)
{
discoveredManifest.getMainAttributes().putValue(Attributes.Name.MANIFEST_VERSION.toString(),
BasicBrooklynCatalog.OSGI_MANIFEST_VERSION_VALUE);
+ manifestNeedsUpdating = true;
+ }
+ if
(discoveredManifest.getMainAttributes().getValue(Constants.BUNDLE_MANIFESTVERSION)==null
||
+
(""+discoveredManifest.getMainAttributes().getValue(Constants.BUNDLE_MANIFESTVERSION)).startsWith("1"))
{
+ // manifest version must be 2 otherwise cannot install to osgi
+
discoveredManifest.getMainAttributes().putValue(Constants.BUNDLE_MANIFESTVERSION,
"2");
manifestNeedsUpdating = true;
}
if (manifestNeedsUpdating) {
diff --git
a/launcher/src/test/java/org/apache/brooklyn/launcher/AbstractBrooklynLauncherRebindTest.java
b/launcher/src/test/java/org/apache/brooklyn/launcher/AbstractBrooklynLauncherRebindTest.java
index ee51783..95552b6 100644
---
a/launcher/src/test/java/org/apache/brooklyn/launcher/AbstractBrooklynLauncherRebindTest.java
+++
b/launcher/src/test/java/org/apache/brooklyn/launcher/AbstractBrooklynLauncherRebindTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.brooklyn.launcher;
+import java.util.jar.Attributes;
import org.apache.brooklyn.util.stream.InputStreamSource;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -179,7 +180,8 @@ public abstract class AbstractBrooklynLauncherRebindTest {
if (bundleName != null || manifestLines.size() > 0) {
Map<String, String> manifestAllLines = MutableMap.<String,
String>builder()
.putAll(manifestLines)
- .putIfAbsent("Manifest-Version", "2.0")
+
.putIfAbsent(java.util.jar.Attributes.Name.MANIFEST_VERSION.toString(),
BasicBrooklynCatalog.OSGI_MANIFEST_VERSION_VALUE)
+ .putIfAbsent(Constants.BUNDLE_MANIFESTVERSION, "2")
.build();
if (bundleName != null) {
manifestAllLines.putIfAbsent(Constants.BUNDLE_SYMBOLICNAME,
bundleName.getSymbolicName());