Skip to content

Commit

Permalink
Enable jarhell check (opensearch-project#3227)
Browse files Browse the repository at this point in the history
JarHell was disabled due to an issue with Kafka where there were
multiple copies of the same class packaged inside of a release and test
distribution jar. This was resolved with
apache/kafka#12407

The Kafka change has been merged, released, and pulled into this
repository so we are removing the workaround to supress jar hell issue
detection.

Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied authored Aug 22, 2023
1 parent 07406d6 commit 75f529a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 44 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ forbiddenApisTest.enabled = false
filepermissions.enabled = false
forbiddenPatterns.enabled = false
testingConventions.enabled = false
// Conflicts between runtime kafka-clients:x.y.z & testRuntime kafka-clients:x.y.z:test
jarHell.enabled = false
jarHell.enabled = true
tasks.whenTaskAdded {task ->
if(task.name.contains("forbiddenApisIntegrationTest")) {
task.enabled = false
Expand Down
39 changes: 0 additions & 39 deletions src/test/java/org/opensearch/bootstrap/JarHell.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.opensearch.security.transport;

// CS-SUPPRESS-SINGLE: RegexpSingleline Extensions manager used for creating a mock
import java.net.UnknownHostException;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
Expand All @@ -32,13 +33,13 @@
import org.opensearch.security.support.Base64Helper;
import org.opensearch.security.support.ConfigConstants;
import org.opensearch.security.user.User;
import org.opensearch.test.OpenSearchTestCase;
import org.opensearch.test.transport.MockTransport;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.Transport.Connection;
import org.opensearch.transport.TransportInterceptor.AsyncSender;
import org.opensearch.transport.TransportRequest;
import org.opensearch.transport.TransportRequestOptions;
import org.opensearch.core.common.transport.TransportAddress;
import org.opensearch.core.transport.TransportResponse;
import org.opensearch.transport.TransportResponseHandler;
import org.opensearch.transport.TransportService;
Expand All @@ -52,6 +53,8 @@
import static org.mockito.Mockito.when;
// CS-ENFORCE-SINGLE

import java.net.InetAddress;

public class SecurityInterceptorTests {

private SecurityInterceptor securityInterceptor;
Expand Down Expand Up @@ -141,10 +144,17 @@ public void testSendRequestDecorate() {
TransportRequestOptions options = mock(TransportRequestOptions.class);
TransportResponseHandler<TransportResponse> handler = mock(TransportResponseHandler.class);

DiscoveryNode localNode = new DiscoveryNode("local-node", OpenSearchTestCase.buildNewFakeTransportAddress(), Version.CURRENT);
InetAddress localAddress = null;
try {
localAddress = InetAddress.getByName("0.0.0.0");
} catch (final UnknownHostException uhe) {
throw new RuntimeException(uhe);
}

DiscoveryNode localNode = new DiscoveryNode("local-node", new TransportAddress(localAddress, 1234), Version.CURRENT);
Connection connection1 = transportService.getConnection(localNode);

DiscoveryNode otherNode = new DiscoveryNode("local-node", OpenSearchTestCase.buildNewFakeTransportAddress(), Version.CURRENT);
DiscoveryNode otherNode = new DiscoveryNode("local-node", new TransportAddress(localAddress, 4321), Version.CURRENT);
Connection connection2 = transportService.getConnection(otherNode);

// isSameNodeRequest = true
Expand Down

0 comments on commit 75f529a

Please sign in to comment.