Skip to content

Commit

Permalink
Revert "Ensure EE has OS runtime dependencies [DI-91]" (#1414)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JackPGreen authored and actions-user committed Apr 19, 2024
1 parent f3f624f commit c5f2e18
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions hazelcast/src/test/java/com/hazelcast/osgi/CheckDependenciesIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.",
Expand Down Expand Up @@ -99,21 +101,32 @@ 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);
}
}

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 {
Expand All @@ -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;
}

Expand Down

0 comments on commit c5f2e18

Please sign in to comment.