From c5f2e187fd8c10d209206640870a1b555a974b0f Mon Sep 17 00:00:00 2001 From: Jack Green Date: Fri, 19 Apr 2024 17:29:50 +0100 Subject: [PATCH] Revert "Ensure EE has OS `runtime` dependencies [DI-91]" (#1414) Reverts hazelcast/hazelcast-mono#1315 The shading of OS into EE is not working correctly, causing the OS codebase to be absent from the shaded JAR. If you check with something like `./mvnw clean install -Pquick -f hazelcast-enterprise/pom.xml | jar -tf hazelcast-enterprise/target/hazelcast-enterprise-5.5.0-SNAPSHOT.jar | grep RunnerEx` there are no matches. [Investigation continues into how to address DI-91](https://hazelcast.slack.com/archives/C05LM8B80UT/p1713535383269039). GitOrigin-RevId: ec97b41cf58e63984eb6ce1477d23a3de821be4d --- .../hazelcast/osgi/CheckDependenciesIT.java | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/hazelcast/src/test/java/com/hazelcast/osgi/CheckDependenciesIT.java b/hazelcast/src/test/java/com/hazelcast/osgi/CheckDependenciesIT.java index ab05d7364e2b..5eedec97f979 100644 --- a/hazelcast/src/test/java/com/hazelcast/osgi/CheckDependenciesIT.java +++ b/hazelcast/src/test/java/com/hazelcast/osgi/CheckDependenciesIT.java @@ -20,8 +20,8 @@ import com.hazelcast.instance.BuildInfoProvider; import com.hazelcast.internal.util.StringUtil; import com.hazelcast.test.HazelcastParallelClassRunner; +import com.hazelcast.test.HazelcastTestSupport; import com.hazelcast.test.annotation.QuickTest; -import org.apache.commons.lang3.StringUtils; import org.apache.felix.utils.manifest.Clause; import org.apache.felix.utils.manifest.Parser; import org.junit.Test; @@ -37,13 +37,15 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; @RunWith(HazelcastParallelClassRunner.class) @Category(QuickTest.class) -public class CheckDependenciesIT { +public class CheckDependenciesIT extends HazelcastTestSupport { + + private static final String MANIFEST_PATH = "META-INF/MANIFEST.MF"; - protected static final String[] WHITELIST_PREFIXES = new String[]{ + private static final String[] WHITELIST_PREFIXES = new String[]{ // everything from the Java package is OK - it's part of the Java SE platform "java.", @@ -99,7 +101,7 @@ protected String getBundleName() { return "Hazelcast(Core)"; } - private Manifest getHazelcastManifest() throws IOException { + protected Manifest getHazelcastManifest() throws IOException { URL hazelcastAllManifestUrl = findHazelcastManifestURL(); try (InputStream inputStream = hazelcastAllManifestUrl.openStream()) { return new Manifest(inputStream); @@ -107,13 +109,24 @@ private Manifest getHazelcastManifest() throws IOException { } private void checkImport(String name, String resolution) { - if (!isWhitelisted(name)) { - assertEquals("Import " + name + " is not declared as optional", "optional", resolution); + if ("optional".equals(resolution)) { + return; } + if (isWhitelisted(name)) { + return; + } + + fail("Import " + name + " is not declared as optional"); } private boolean isWhitelisted(String name) { - return StringUtils.startsWithAny(name, getWhitelistPrefixes()); + String[] whitelistPrefixes = getWhitelistPrefixes(); + for (String whitelistPrefix : whitelistPrefixes) { + if (name.startsWith(whitelistPrefix)) { + return true; + } + } + return false; } private URL findHazelcastManifestURL() throws IOException { @@ -124,11 +137,16 @@ private URL findHazelcastManifestURL() throws IOException { URL url = resources.nextElement(); String urlString = url.toString(); if (isMatching(urlString)) { - assertNull("Found multiple matching URLs: " + url + " and " + matchedUrl, matchedUrl); - matchedUrl = url; + if (matchedUrl == null) { + matchedUrl = url; + } else { + throw new AssertionError("Found multiple matching URLs: " + url + " and " + matchedUrl); + } } } - assertNotNull("Cannot find Hazelcast manifest", matchedUrl); + if (matchedUrl == null) { + throw new AssertionError("Cannot find Hazelcast manifest"); + } return matchedUrl; }