Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 11 Compile Prototype #2953

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion azure-pipelines-static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
resources:
repositories:
- repository: templates
type: git
type: git
name: terracotta/terracotta

jobs:
- template: build-templates/gradle-common.yml@templates
parameters:
jdkVersion: '1.11'
gradleTasks: 'check'
15 changes: 2 additions & 13 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,13 @@ resources:
jobs:
- template: build-templates/gradle-common.yml@templates
parameters:
jdkVersion: '1.8'
jobName: 'LinuxJava8'

- template: build-templates/gradle-common.yml@templates
parameters:
jdkVersion: '1.8'
jdkVersion: '1.11'
options: '-PtestVM=java11Home'
jobName: 'LinuxJava11'

- template: build-templates/gradle-common.yml@templates
parameters:
vmImage: 'windows-latest'
jdkVersion: '1.8'
jobName: 'WindowsJava8'

- template: build-templates/gradle-common.yml@templates
parameters:
vmImage: 'windows-latest'
jdkVersion: '1.8'
jdkVersion: '1.11'
options: '-PtestVM=java11Home'
jobName: 'WindowsJava11'
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public void apply(Project project) {
project.getExtensions().getExtraProperties().set("testJava", testJava);

project.getExtensions().configure(JavaPluginExtension.class, java -> {
java.setSourceCompatibility(JavaVersion.VERSION_1_8);
java.setTargetCompatibility(JavaVersion.VERSION_1_8);
java.setSourceCompatibility(JavaVersion.VERSION_11);
java.setTargetCompatibility(JavaVersion.VERSION_11);
});

project.getTasks().withType(Jar.class).configureEach(jar -> {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ tasks.named('closeAndReleaseRepository') {
enabled = false;
}

assert (JavaVersion.current().isJava8Compatible()) : 'The Ehcache 3 build requires Java 8+ to run'
assert (JavaVersion.current().isJava11Compatible()) : 'The Ehcache 3 build requires Java 11+ to run'

dependencyCheck {
failBuildOnCVSS = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public Map.Entry<Long, Chain> next() {
}
}

@Override
@Override @SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
if (!lastBatch) {
entity.invokeAndWaitForReceive(new ServerStoreOpMessage.IteratorCloseMessage(iteratorId), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import org.ehcache.clustered.common.internal.ClusterTierManagerConfiguration;
import org.ehcache.clustered.common.internal.lock.LockMessaging.HoldType;
import org.ehcache.clustered.client.internal.lock.VoltronReadWriteLockClient;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import org.terracotta.connection.Connection;

import static org.hamcrest.MatcherAssert.assertThat;
Expand All @@ -47,6 +47,7 @@
import org.terracotta.exception.EntityConfigurationException;
import org.terracotta.exception.EntityNotFoundException;

@RunWith(MockitoJUnitRunner.class)
public class ClusterTierManagerClientEntityFactoryTest {

@Mock
Expand All @@ -56,11 +57,6 @@ public class ClusterTierManagerClientEntityFactoryTest {
@Mock
private Connection connection;

@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
}

@Test
public void testCreate() throws Exception {
when(getEntityRef(ClusterTierManagerClientEntity.class)).thenReturn(entityRef);
Expand Down Expand Up @@ -140,7 +136,6 @@ public void testRetrieveFailedValidate() throws Exception {
@SuppressWarnings("unchecked")
public void testRetrieveWhenNotExisting() throws Exception {
when(entityRef.fetchEntity(null)).thenThrow(EntityNotFoundException.class);
doThrow(EntityAlreadyExistsException.class).when(entityRef).create(any());
when(getEntityRef(ClusterTierManagerClientEntity.class)).thenReturn(entityRef);

addMockUnlockedLock(connection, "VoltronReadWriteLock-ClusterTierManagerClientEntityFactory-AccessLock-test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.math.BigInteger;
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
Expand All @@ -35,7 +34,6 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;

import org.ehcache.clustered.client.internal.lock.VoltronReadWriteLockEntityClientService;
import org.ehcache.clustered.client.internal.store.ClusterTierClientEntityService;
Expand All @@ -46,6 +44,8 @@
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terracotta.common.struct.Measure;
import org.terracotta.common.struct.MemoryUnit;
import org.terracotta.connection.Connection;
import org.terracotta.connection.ConnectionException;
import org.terracotta.connection.ConnectionPropertyNames;
Expand All @@ -62,15 +62,11 @@
import org.terracotta.exception.EntityNotProvidedException;
import org.terracotta.exception.PermanentEntityException;
import org.terracotta.offheapresource.OffHeapResourcesProvider;
import org.terracotta.offheapresource.config.MemoryUnit;
import org.terracotta.offheapresource.config.OffheapResourcesType;
import org.terracotta.offheapresource.config.ResourceType;
import org.terracotta.passthrough.IAsynchronousServerCrasher;
import org.terracotta.passthrough.PassthroughConnection;
import org.terracotta.passthrough.PassthroughServer;
import org.terracotta.passthrough.PassthroughServerRegistry;

import static java.util.stream.Collectors.toCollection;
import static java.util.stream.Collectors.toList;
import static org.mockito.Mockito.mock;

Expand Down Expand Up @@ -175,20 +171,6 @@ public static void removeStripe(String stripeName) {
stripeDescriptor.removeConnections();
}

public static OffheapResourcesType getOffheapResourcesType(String resourceName, int size, MemoryUnit unit) {
OffheapResourcesType resources = new OffheapResourcesType();
resources.getResource().add(getResource(resourceName, size, unit));
return resources;
}

private static ResourceType getResource(String resourceName, int size, MemoryUnit unit) {
final ResourceType resource = new ResourceType();
resource.setName(resourceName);
resource.setUnit(unit);
resource.setValue(BigInteger.valueOf((long)size));
return resource;
}

/**
* Adds a {@link PassthroughServer} if, and only if, a mapping for the URI supplied does not
* already exist. The server is started as it is added.
Expand Down Expand Up @@ -286,7 +268,7 @@ public static final class PassthroughServerBuilder {
private final Map<ServiceProvider, ServiceProviderConfiguration> serviceProviders =
new IdentityHashMap<>();

private final OffheapResourcesType resources = new OffheapResourcesType();
private final Map<String, Measure<MemoryUnit>> resources = new HashMap<>();

public PassthroughServerBuilder resource(String resourceName, int size, org.ehcache.config.units.MemoryUnit unit) {
return this.resource(resourceName, size, convert(unit));
Expand All @@ -299,7 +281,7 @@ private MemoryUnit convert(org.ehcache.config.units.MemoryUnit unit) {
convertedUnit = MemoryUnit.B;
break;
case KB:
convertedUnit = MemoryUnit.K_B;
convertedUnit = MemoryUnit.KB;
break;
case MB:
convertedUnit = MemoryUnit.MB;
Expand All @@ -320,7 +302,7 @@ private MemoryUnit convert(org.ehcache.config.units.MemoryUnit unit) {
}

private PassthroughServerBuilder resource(String resourceName, int size, MemoryUnit unit) {
this.resources.getResource().add(getResource(resourceName, size, unit));
this.resources.put(resourceName, Measure.of(size, unit));
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;

public class ClusteredLoaderWriterStoreTest {
Expand Down Expand Up @@ -117,8 +117,7 @@ public void testGetValuePresentInCache() throws Exception {
ClusteredLoaderWriterStore<Long, String> store = new ClusteredLoaderWriterStore<>(configuration, codec, resolver, storeProxy,
timeSource, loaderWriter, new DefaultStatisticsService());
assertThat(store.get(1L).get(), equalTo("one"));
verify(loaderWriter, times(0)).load(anyLong());
verifyZeroInteractions(loaderWriter);
verifyNoInteractions(loaderWriter);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

package org.ehcache.clustered.client.internal.lock;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.terracotta.connection.Connection;
import org.terracotta.connection.entity.EntityRef;

Expand All @@ -32,10 +32,12 @@
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.terracotta.exception.EntityAlreadyExistsException;

@RunWith(MockitoJUnitRunner.class)
public class VoltronReadWriteLockTest {

@Mock
Expand All @@ -47,11 +49,6 @@ public class VoltronReadWriteLockTest {
@Mock
private Connection connection;

@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
}

@Test
public void testCreateLockEntityWhenNotExisting() throws Exception {
when(entityRef.fetchEntity(null)).thenReturn(client);
Expand All @@ -66,7 +63,7 @@ public void testCreateLockEntityWhenNotExisting() throws Exception {

@Test
public void testFetchExistingLockEntityWhenExists() throws Exception {
doThrow(EntityAlreadyExistsException.class).when(entityRef).create(any(Void.class));
doThrow(EntityAlreadyExistsException.class).when(entityRef).create(any());
when(entityRef.fetchEntity(null)).thenReturn(client);

when(connection.<VoltronReadWriteLockClient, Void, Void>getEntityRef(VoltronReadWriteLockClient.class, 1, "VoltronReadWriteLock-TestLock")).thenReturn(entityRef);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.terracotta.common.struct.Measure;
import org.terracotta.common.struct.MemoryUnit;
import org.terracotta.offheapresource.OffHeapResourcesProvider;
import org.terracotta.offheapresource.config.MemoryUnit;
import org.terracotta.passthrough.PassthroughClusterControl;
import org.terracotta.passthrough.PassthroughTestHelpers;

import java.io.Serializable;
import java.lang.reflect.Field;
import java.net.URI;

import static java.util.Collections.singletonMap;
import static org.ehcache.clustered.client.config.builders.ClusteredResourcePoolBuilder.clusteredDedicated;
import static org.ehcache.clustered.client.internal.UnitTestConnectionService.getOffheapResourcesType;
import static org.ehcache.config.Eviction.noAdvice;
import static org.ehcache.config.builders.ExpiryPolicyBuilder.noExpiration;
import static org.ehcache.config.builders.ResourcePoolsBuilder.newResourcePoolsBuilder;
Expand All @@ -71,7 +72,7 @@ public void setUp() throws Exception {
server.registerClientEntityService(new ClusterTierClientEntityService());
server.registerServerEntityService(new VoltronReadWriteLockServerEntityService());
server.registerClientEntityService(new VoltronReadWriteLockEntityClientService());
server.registerExtendedConfiguration(new OffHeapResourcesProvider(getOffheapResourcesType("test", 32, MemoryUnit.MB)));
server.registerExtendedConfiguration(new OffHeapResourcesProvider(singletonMap("test", Measure.of(32, MemoryUnit.MB))));

UnitTestConnectionService.addServerToStripe(STRIPENAME, server);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
import org.ehcache.spi.service.MaintainableService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import org.terracotta.connection.Connection;
import org.terracotta.connection.entity.Entity;
import org.terracotta.connection.entity.EntityRef;
Expand All @@ -46,6 +47,7 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
Expand All @@ -54,6 +56,7 @@
/**
* DefaultClusteringServiceDestroyTest
*/
@RunWith(MockitoJUnitRunner.class)
public class DefaultClusteringServiceDestroyTest {

@Mock
Expand All @@ -67,7 +70,6 @@ public class DefaultClusteringServiceDestroyTest {

@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
MockConnectionService.mockConnection = connection;
}

Expand Down Expand Up @@ -167,7 +169,6 @@ public void testDestroyOnPartialDestroyState() throws Exception {
when(getEntityRef(ClusterTierManagerClientEntity.class)).thenReturn(managerEntityRef);
ClusterTierManagerClientEntity managerEntity = mock(ClusterTierManagerClientEntity.class);
when(managerEntityRef.fetchEntity(null)).thenReturn(managerEntity);
doThrow(new DestroyInProgressException("destroying")).when(managerEntity).validate(any());

Set<String> stores = new HashSet<>();
stores.add("store1");
Expand All @@ -194,15 +195,15 @@ private void mockLockForWriteLockSuccess() throws org.terracotta.exception.Entit
VoltronReadWriteLockClient lockClient = mock(VoltronReadWriteLockClient.class);
when(lockEntityRef.fetchEntity(null)).thenReturn(lockClient);

when(lockClient.tryLock(LockMessaging.HoldType.WRITE)).thenReturn(true);
lenient().when(lockClient.tryLock(LockMessaging.HoldType.WRITE)).thenReturn(true);
}

private void mockLockForReadLockSuccess() throws org.terracotta.exception.EntityNotProvidedException, org.terracotta.exception.EntityNotFoundException, org.terracotta.exception.EntityVersionMismatchException {
when(connection.<VoltronReadWriteLockClient, Object, Void>getEntityRef(same(VoltronReadWriteLockClient.class), eq(1L), any())).thenReturn(lockEntityRef);
VoltronReadWriteLockClient lockClient = mock(VoltronReadWriteLockClient.class);
when(lockEntityRef.fetchEntity(null)).thenReturn(lockClient);

when(lockClient.tryLock(LockMessaging.HoldType.READ)).thenReturn(true);
lenient().when(lockClient.tryLock(LockMessaging.HoldType.READ)).thenReturn(true);
}

private <E extends Entity> EntityRef<E, Object, Void> getEntityRef(Class<E> value) throws org.terracotta.exception.EntityNotProvidedException {
Expand Down
Loading