Skip to content

Commit 2ceae8c

Browse files
authored
Bug/40 No class def found error (#41)
* #40: NoClassDefFoundError when used without exasol-test-setup-abstraction-java
1 parent 68e0705 commit 2ceae8c

File tree

13 files changed

+67
-29
lines changed

13 files changed

+67
-29
lines changed

doc/changes/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Changes
22

3+
* [0.6.4](changes_0.6.4.md)
34
* [0.6.3](changes_0.6.3.md)
45
* [0.6.2](changes_0.6.2.md)
56
* [0.6.1](changes_0.6.1.md)

doc/changes/changes_0.6.4.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# udf-debugging-java 0.6.4, released 2022-06-27
2+
3+
Code name: Fixed NoClassDefFoundError
4+
5+
## Summary
6+
7+
## Bug Fixes
8+
9+
* #40: Fixed NoClassDefFoundError when used without exasol-test-setup-abstraction-java
10+
11+
## Dependency Updates

pk_generated_parent.pom

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.exasol</groupId>
55
<artifactId>udf-debugging-java-generated-parent</artifactId>
6-
<version>0.6.3</version>
6+
<version>0.6.4</version>
77
<packaging>pom</packaging>
88
<properties>
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

pom.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45
<groupId>com.exasol</groupId>
56
<artifactId>udf-debugging-java</artifactId>
6-
<version>0.6.3</version>
7+
<version>0.6.4</version>
78
<name>udf-debugging-java</name>
89
<description>Utilities for debugging, profiling and code coverage measure for UDFs.</description>
910
<url>https://github.com/exasol/udf-debugging-java/</url>
@@ -81,6 +82,8 @@
8182
<groupId>com.exasol</groupId>
8283
<artifactId>exasol-test-setup-abstraction-java</artifactId>
8384
<version>0.3.2</version>
85+
<!-- This is not a compile-dependency since it would pull a lot of transitive dependencies (like the AWS SDK) into project where it's absolutely not needed.
86+
That's possible since we only use the classes from this dependencies in methods that are ment to be used with the exasol-test-setup-abstraction-java. -->
8487
<scope>provided</scope>
8588
</dependency>
8689
<dependency>
@@ -258,7 +261,7 @@
258261
<parent>
259262
<artifactId>udf-debugging-java-generated-parent</artifactId>
260263
<groupId>com.exasol</groupId>
261-
<version>0.6.3</version>
264+
<version>0.6.4</version>
262265
<relativePath>pk_generated_parent.pom</relativePath>
263266
</parent>
264267
</project>

src/main/java/com/exasol/udfdebugging/LocalServiceExposer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.exasol.udfdebugging;
22

3-
import com.exasol.exasoltestsetup.ServiceAddress;
3+
import java.net.InetSocketAddress;
44

55
/**
66
* Implementors of this interface exposes a local service (socket) into the Exasol database.
@@ -14,5 +14,5 @@ public interface LocalServiceExposer {
1414
* @param port port number
1515
* @return proxy
1616
*/
17-
ServiceAddress exposeLocalServiceToDatabase(int port);
17+
InetSocketAddress exposeLocalServiceToDatabase(int port);
1818
}

src/main/java/com/exasol/udfdebugging/UdfTestSetup.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.exasol.udfdebugging;
22

3+
import java.net.InetSocketAddress;
34
import java.sql.Connection;
45
import java.util.List;
56
import java.util.stream.Collectors;
@@ -32,7 +33,7 @@ public class UdfTestSetup implements AutoCloseable {
3233
* @param exasolConnection connection to the Exasol database. Make sure that your tests use the same connection
3334
*/
3435
public UdfTestSetup(final String testHostIpAddress, final Bucket bucket, final Connection exasolConnection) {
35-
this(port -> new ServiceAddress(testHostIpAddress, port), bucket, exasolConnection);
36+
this(port -> new InetSocketAddress(testHostIpAddress, port), bucket, exasolConnection);
3637
}
3738

3839
/**
@@ -57,7 +58,10 @@ private UdfTestSetup(final LocalServiceExposer localServiceExposer, final Bucket
5758
* @param exasolConnection connection to the Exasol database. Make sure that your tests use the same connection
5859
*/
5960
public UdfTestSetup(final ExasolTestSetup testSetup, final Connection exasolConnection) {
60-
this(testSetup::makeLocalTcpServiceAccessibleFromDatabase, testSetup.getDefaultBucket(), exasolConnection);
61+
this(port -> {
62+
final ServiceAddress serviceAddress = testSetup.makeLocalTcpServiceAccessibleFromDatabase(port);
63+
return new InetSocketAddress(serviceAddress.getHostName(), serviceAddress.getPort());
64+
}, testSetup.getDefaultBucket(), exasolConnection);
6165
}
6266

6367
/**

src/main/java/com/exasol/udfdebugging/modules/coverage/CoverageModule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
import java.io.FileNotFoundException;
44
import java.io.IOException;
5+
import java.net.InetSocketAddress;
56
import java.nio.file.Path;
67
import java.util.concurrent.TimeoutException;
78
import java.util.stream.Stream;
89

910
import com.exasol.bucketfs.Bucket;
1011
import com.exasol.bucketfs.BucketAccessException;
1112
import com.exasol.errorreporting.ExaError;
12-
import com.exasol.exasoltestsetup.ServiceAddress;
1313
import com.exasol.udfdebugging.LocalServiceExposer;
1414
import com.exasol.udfdebugging.Module;
1515

@@ -31,7 +31,7 @@ public CoverageModule(final LocalServiceExposer localServiceExposer, final Bucke
3131
assertJacocoAgentExists();
3232
uploadAgentToBucketFs(bucket);
3333
JacocoServer.startIfNotRunning();
34-
final ServiceAddress proxyForHostPort = localServiceExposer.exposeLocalServiceToDatabase(JacocoServer.PORT);
34+
final InetSocketAddress proxyForHostPort = localServiceExposer.exposeLocalServiceToDatabase(JacocoServer.PORT);
3535
this.jvmOption = "-javaagent:/buckets/" + bucket.getBucketFsName() + "/" + bucket.getBucketName() + "/"
3636
+ JACOCO_AGENT_NAME + "=output=tcpclient,address=" + proxyForHostPort.getHostName() + ",port="
3737
+ proxyForHostPort.getPort();

src/main/java/com/exasol/udfdebugging/modules/debugging/DebuggingModule.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.exasol.udfdebugging.modules.debugging;
22

3+
import java.net.InetSocketAddress;
34
import java.util.stream.Stream;
45

5-
import com.exasol.exasoltestsetup.ServiceAddress;
66
import com.exasol.udfdebugging.LocalServiceExposer;
77
import com.exasol.udfdebugging.Module;
88

@@ -25,7 +25,8 @@ public DebuggingModule(final LocalServiceExposer localServiceExposer) {
2525

2626
@Override
2727
public Stream<String> getJvmOptions() {
28-
final ServiceAddress proxyForHostPort = this.localServiceExposer.exposeLocalServiceToDatabase(DEBUGGING_PORT);
28+
final InetSocketAddress proxyForHostPort = this.localServiceExposer
29+
.exposeLocalServiceToDatabase(DEBUGGING_PORT);
2930
return Stream.of("-agentlib:jdwp=transport=dt_socket,server=n,address=" + proxyForHostPort.getHostName() + ":"
3031
+ proxyForHostPort.getPort() + ",suspend=y");
3132
}

src/main/java/com/exasol/udfdebugging/modules/udflogs/UdfLogsModule.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.exasol.udfdebugging.modules.udflogs;
22

3+
import java.net.InetSocketAddress;
34
import java.nio.file.Path;
45
import java.sql.*;
56
import java.util.ArrayList;
@@ -10,7 +11,6 @@
1011
import java.util.stream.Stream;
1112

1213
import com.exasol.errorreporting.ExaError;
13-
import com.exasol.exasoltestsetup.ServiceAddress;
1414
import com.exasol.udfdebugging.LocalServiceExposer;
1515
import com.exasol.udfdebugging.Module;
1616

@@ -37,7 +37,8 @@ public UdfLogsModule(final LocalServiceExposer localServiceExposer, final Connec
3737
LOGGER.log(Level.INFO, "Created log file for UDF output: {0}", file);
3838
};
3939
this.logRecorder = new LogRecorder(logFileHandler);
40-
final ServiceAddress inDbAddress = localServiceExposer.exposeLocalServiceToDatabase(this.logRecorder.getPort());
40+
final InetSocketAddress inDbAddress = localServiceExposer
41+
.exposeLocalServiceToDatabase(this.logRecorder.getPort());
4142
redirectLogging(exasolConnection, inDbAddress);
4243
}
4344

@@ -55,9 +56,9 @@ public List<Path> getCapturedLogFiles() {
5556
return this.capturedLogFiles;
5657
}
5758

58-
private void redirectLogging(final Connection exasolConnection, final ServiceAddress logServerAddress) {
59+
private void redirectLogging(final Connection exasolConnection, final InetSocketAddress logServerAddress) {
5960
try (final Statement statement = exasolConnection.createStatement()) {
60-
final String logServerAddressString = logServerAddress.toString();
61+
final String logServerAddressString = logServerAddress.getHostString() + ":" + logServerAddress.getPort();
6162
if (logServerAddressString.contains("'")) {
6263
throw new IllegalArgumentException(ExaError.messageBuilder("F-UDJ-19")
6364
.message("Invalid address {{address}}. The address must not contain a quotes.",

src/test/java/com/exasol/udfdebugging/UdfTestSetupTest.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import static org.mockito.Mockito.*;
66

77
import java.sql.*;
8-
import java.util.Arrays;
98
import java.util.List;
109

1110
import org.itsallcode.junit.sysextensions.SystemOutGuard;
@@ -17,6 +16,8 @@
1716
import org.mockito.junit.jupiter.MockitoExtension;
1817

1918
import com.exasol.bucketfs.Bucket;
19+
import com.exasol.exasoltestsetup.ExasolTestSetup;
20+
import com.exasol.exasoltestsetup.ServiceAddress;
2021

2122
@ExtendWith(MockitoExtension.class)
2223
@ExtendWith(SystemOutGuard.class)
@@ -39,7 +40,7 @@ void before() {
3940
void testDebuggingEnabled() {
4041
System.setProperty(DEBUG_PROPERTY, "true");
4142
try (final UdfTestSetup udfTestSetup = getUdfTestSetup()) {
42-
final List<String> jvmOptions = Arrays.asList(udfTestSetup.getJvmOptions());
43+
final List<String> jvmOptions = List.of(udfTestSetup.getJvmOptions());
4344
assertThat(jvmOptions, hasItem(EXPECTED_DEBUG_JVM_OPTION));
4445
}
4546
}
@@ -48,11 +49,26 @@ private UdfTestSetup getUdfTestSetup() {
4849
return new UdfTestSetup("1.2.3.4", mock(Bucket.class), this.connection);
4950
}
5051

52+
@Test
53+
void testGetTestSetupForETAJ() {
54+
System.setProperty(COVERAGE_PROPERTY, "true");
55+
final ExasolTestSetup testSetup = mock(ExasolTestSetup.class);
56+
final Bucket bucket = mock(Bucket.class);
57+
when(testSetup.getDefaultBucket()).thenReturn(bucket);
58+
when(testSetup.makeLocalTcpServiceAccessibleFromDatabase(anyInt()))
59+
.thenReturn(new ServiceAddress("4.3.2.1", 123));
60+
try (final UdfTestSetup udfTestSetup = new UdfTestSetup(testSetup, this.connection)) {
61+
final List<String> jvmOptions = List.of(udfTestSetup.getJvmOptions());
62+
assertThat(jvmOptions, hasItem(
63+
"-javaagent:/buckets/null/null/org.jacoco.agent-runtime.jar=output=tcpclient,address=4.3.2.1,port=123"));
64+
}
65+
}
66+
5167
@Test
5268
void testCoverageEnabled() {
5369
System.setProperty(COVERAGE_PROPERTY, "true");
5470
try (final UdfTestSetup udfTestSetup = getUdfTestSetup()) {
55-
final List<String> jvmOptions = Arrays.asList(udfTestSetup.getJvmOptions());
71+
final List<String> jvmOptions = List.of(udfTestSetup.getJvmOptions());
5672
assertThat(jvmOptions, hasItem(
5773
"-javaagent:/buckets/null/null/org.jacoco.agent-runtime.jar=output=tcpclient,address=1.2.3.4,port=3002"));
5874
}
@@ -72,7 +88,7 @@ void testUdfLogsEnabled() throws SQLException {
7288
@Test
7389
void testAllModulesAreDisabledByDefault() {
7490
try (final UdfTestSetup udfTestSetup = getUdfTestSetup()) {
75-
final List<String> jvmOptions = Arrays.asList(udfTestSetup.getJvmOptions());
91+
final List<String> jvmOptions = List.of(udfTestSetup.getJvmOptions());
7692
assertThat(jvmOptions.isEmpty(), equalTo(true));
7793
}
7894
}
@@ -81,7 +97,7 @@ void testAllModulesAreDisabledByDefault() {
8197
void testDebuggingDisabled() {
8298
System.setProperty(DEBUG_PROPERTY, "false");
8399
try (final UdfTestSetup udfTestSetup = getUdfTestSetup()) {
84-
final List<String> jvmOptions = Arrays.asList(udfTestSetup.getJvmOptions());
100+
final List<String> jvmOptions = List.of(udfTestSetup.getJvmOptions());
85101
assertThat(jvmOptions, not(hasItem(EXPECTED_DEBUG_JVM_OPTION)));
86102
}
87103
}

0 commit comments

Comments
 (0)