Refactor the SpringBootApacheGeodeLocatorApplicationSmokeTests class.

Add test.properties to the application classpath to disable the use of direct (main memory) ByteBuffers in Java NIO.

Use of direct ByteBuffers results in the following Exception:

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public java.lang.Object java.nio.DirectByteBuffer.attachment() accessible: module java.base does not "opens java.nio" to unnamed module @2e0fa5d3
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
	at org.apache.geode.internal.net.BufferPool.getPoolableBuffer(BufferPool.java:343)
	... 69 more
This commit is contained in:
John Blum
2022-02-09 17:38:28 -08:00
parent d21f994fbd
commit 9b6d9f711b
3 changed files with 22 additions and 7 deletions

View File

@@ -7,7 +7,7 @@ dependencies {
implementation "org.assertj:assertj-core"
implementation project(':spring-geode-starter')
// implementation project(':spring-geode-starter-logging')
//implementation project(':spring-geode-starter-logging')
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'

View File

@@ -18,7 +18,6 @@ package example.app.geode.locator;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -70,18 +69,14 @@ public class SpringBootApacheGeodeLocatorApplicationSmokeTests extends ForkingCl
int locatorPort = findAvailablePort();
long waitTimeout = TimeUnit.SECONDS.toMillis(10);
startGemFireServer(ApacheGeodeLocator.class, String.valueOf(locatorPort));
waitForServerToStart(ApacheGeodeLocator.HOSTNAME_FOR_CLIENTS, locatorPort, waitTimeout);
System.setProperty(SPRING_DATA_GEMFIRE_LOCATORS_PROPERTY,
String.format("%1$s[%2$d]", ApacheGeodeLocator.HOSTNAME_FOR_CLIENTS, locatorPort));
}
@AfterClass
public static void stopGeodeLocator() {
stopGemFireServer();
public static void afterGeodeLocatorStop() {
System.clearProperty(SPRING_DATA_GEMFIRE_LOCATORS_PROPERTY);
}

View File

@@ -0,0 +1,20 @@
# Test Properties used to configure Spring Boot and Apache Geode during test execution.
# Setting the following Apache Geode "internal" System property ("gemfire.Buffer.useHeapBuffers") because Apache Geode
# is not fully Java 17 compatible and leads to the following error:
# Caused by: java.lang.reflect.InaccessibleObjectException:
# Unable to make public java.lang.Object java.nio.DirectByteBuffer.attachment() accessible:
# module java.base does not "opens java.nio" to unnamed module @2e0fa5d3
# at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
# at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
# at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
# at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
# at org.apache.geode.internal.net.BufferPool.getPoolableBuffer(BufferPool.java:343)
# ... 69 more
# The gemfire.BufferPool.useHeapBuffers property should technically be true, but due to an Apache Geode bug,
# it is ignore entirely due to the first condition (#sigh); see https://issues.apache.org/jira/browse/GEODE-10035.
#system.gemfire.BufferPool.useHeapBuffers=true
# Use this (GemFire) System property instead (effects the "first condition").
system.p2p.nodirectBuffers=true