Skip to content

Commit 547c334

Browse files
- Upgrade slf4j-api from 1.7.36 to 2.0.17 (required by logback 1.5.26) and add slf4j exclusions on Terracotta dependencies (statistics, offheap-store, sizeof, terracotta-utilities-tools) that declare the conflicting 1.7 range
- Fix Java deprecation/removal warnings treated as errors by -Werror - Add missing javax.xml.bind:jaxb-api to xjcToolJakarta configuration to fix ClassNotFoundException during Jakarta XJC code generation - Add javadocAdd/jakartaJavadocAdd classpath configurations in ehcache/build.gradle (spotbugs-annotations, jaxb-api) and clustered/ehcache-clustered/build.gradle (ehcache-common-api, ehcache-common) required for javadocJar tasks in the assemble chain - Backport of TDB-19854 (master/3.12): upgrade SpotBugs to 4.9.8, AssertJ to 3.27.7, Mockito to 5.12.0, ByteBuddy to 1.18.3; rewrite demos to use embedded Jetty 12 instead of Gretty; refactor SPI tests to use JUnit 4 rules; update Mockito 5 API usage (MockitoAnnotations, ArgumentMatchers); fix SpotBugs annotation usages - Address compilation errors and test failures introduced by upgrading slf4j from 1.7.x to 2.0.17 - PR build with java 17
1 parent 3245746 commit 547c334

94 files changed

Lines changed: 564 additions & 356 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

azure-pipelines.yml

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,25 @@ resources:
2525
name: terracotta/terracotta
2626

2727
jobs:
28-
- template: build-templates/gradle-common.yml@templates
29-
parameters:
30-
jdkVersion: '1.8'
31-
jobName: 'LinuxJava8'
32-
gradleTasks: 'check -x dependencyCheckAggregate'
33-
34-
- template: build-templates/gradle-common.yml@templates
35-
parameters:
36-
jdkVersion: '1.8'
37-
options: '-PtestVM=java11Home'
38-
jobName: 'LinuxJava11'
39-
gradleTasks: 'check -x dependencyCheckAggregate'
40-
41-
- template: build-templates/gradle-common.yml@templates
42-
parameters:
43-
jdkVersion: '1.8'
44-
options: '-PtestVM=java17Home'
45-
jobName: 'LinuxJava17'
46-
gradleTasks: 'check -x dependencyCheckAggregate'
47-
48-
- template: build-templates/gradle-common.yml@templates
49-
parameters:
50-
jdkVersion: '1.8'
51-
options: '-PtestVM=java21Home'
52-
jobName: 'LinuxJava21'
53-
gradleTasks: 'check -x dependencyCheckAggregate'
54-
55-
- template: build-templates/gradle-common.yml@templates
56-
parameters:
57-
vmImage: 'windows-latest'
58-
jdkVersion: '1.8'
59-
jobName: 'WindowsJava8'
60-
gradleTasks: 'check -x dependencyCheckAggregate'
61-
62-
- template: build-templates/gradle-common.yml@templates
63-
parameters:
64-
vmImage: 'windows-latest'
65-
jdkVersion: '1.8'
66-
options: '-PtestVM=java21Home'
67-
jobName: 'WindowsJava21'
68-
gradleTasks: 'check -x dependencyCheckAggregate'
28+
- template: build-templates/gradle-common.yml@templates
29+
parameters:
30+
jdkVersion: '17'
31+
options: '-PtestVM=java17Home'
32+
jobName: 'LinuxJava17'
33+
gradleTasks: 'check -x dependencyCheckAggregate'
34+
35+
- template: build-templates/gradle-common.yml@templates
36+
parameters:
37+
jdkVersion: '17'
38+
options: '-PtestVM=java21Home'
39+
jobName: 'LinuxJava21'
40+
gradleTasks: 'check -x dependencyCheckAggregate'
41+
42+
43+
- template: build-templates/gradle-common.yml@templates
44+
parameters:
45+
vmImage: 'windows-latest'
46+
jdkVersion: '17'
47+
options: '-PtestVM=java21Home'
48+
jobName: 'WindowsJava21'
49+
gradleTasks: 'check -x dependencyCheckAggregate'

build-logic/src/main/java/org/ehcache/build/conventions/CheckstyleConvention.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,28 @@ public void apply(Project project) {
1313
project.getPlugins().apply(CheckstylePlugin.class);
1414

1515
project.getExtensions().configure(CheckstyleExtension.class, checkstyle -> {
16+
checkstyle.setToolVersion("10.18.1");
1617
checkstyle.setConfigFile(project.getRootProject().file("config/checkstyle.xml"));
1718
Map<String, Object> properties = checkstyle.getConfigProperties();
1819
properties.put("projectDir", project.getProjectDir());
1920
properties.put("rootDir", project.getRootDir());
2021
});
22+
23+
project.getConfigurations().named("checkstyle", config -> {
24+
config.getResolutionStrategy().dependencySubstitution(subs -> {
25+
subs.substitute(subs.module("org.codehaus.plexus:plexus-utils:3.1.1"))
26+
.using(subs.module("org.codehaus.plexus:plexus-utils:3.3.0"))
27+
.because("Checkstyle 10.18.1 pulls mismatched plexus-utils versions");
28+
subs.substitute(subs.module("org.apache.commons:commons-lang3:3.7"))
29+
.using(subs.module("org.apache.commons:commons-lang3:3.8.1"))
30+
.because("Checkstyle transitives mix commons-lang3 versions");
31+
subs.substitute(subs.module("org.apache.httpcomponents:httpcore:4.4.13"))
32+
.using(subs.module("org.apache.httpcomponents:httpcore:4.4.14"))
33+
.because("Align httpcore to latest bugfix release");
34+
subs.substitute(subs.module("commons-codec:commons-codec:1.11"))
35+
.using(subs.module("commons-codec:commons-codec:1.15"))
36+
.because("Checkstyle transitive dependencies depend on different commons-codec versions");
37+
});
38+
});
2139
}
2240
}

build-logic/src/main/java/org/ehcache/build/conventions/JavaConvention.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package org.ehcache.build.conventions;
22

3+
import java.util.Map;
34
import org.gradle.api.Plugin;
45
import org.gradle.api.Project;
6+
import org.gradle.api.artifacts.ModuleDependency;
57
import org.gradle.api.artifacts.dsl.DependencyHandler;
68
import org.gradle.api.plugins.JavaPlugin;
79

@@ -20,16 +22,29 @@ public void apply(Project project) {
2022

2123
dependencies.add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "junit:junit:" + project.property("junitVersion"));
2224
dependencies.add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.assertj:assertj-core:" + project.property("assertjVersion"));
25+
dependencies.add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "net.bytebuddy:byte-buddy:" + project.property("byteBuddyVersion"));
26+
dependencies.add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "net.bytebuddy:byte-buddy-agent:" + project.property("byteBuddyVersion"));
2327
dependencies.add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.hamcrest:hamcrest:" + project.property("hamcrestVersion"));
2428
dependencies.add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.mockito:mockito-core:" + project.property("mockitoVersion"));
25-
dependencies.add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.terracotta:terracotta-utilities-test-tools:" + project.property("terracottaUtilitiesVersion"));
29+
ModuleDependency md = (ModuleDependency)dependencies.add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, "org.terracotta:terracotta-utilities-test-tools:" + project.property("terracottaUtilitiesVersion"));
30+
if (md != null) {
31+
md.exclude(Map.of("group", "org.slf4j"));
32+
}
2633

2734
project.getConfigurations().all(config -> {
2835
config.getResolutionStrategy().dependencySubstitution(subs -> {
2936
subs.substitute(subs.module("org.hamcrest:hamcrest-core:1.3")).with(subs.module("org.hamcrest:hamcrest-core:" + project.property("hamcrestVersion")));
3037
subs.substitute(subs.module("org.hamcrest:hamcrest-library:1.3")).with(subs.module("org.hamcrest:hamcrest-library:" + project.property("hamcrestVersion")));
3138
subs.substitute(subs.module("junit:junit:4.12")).using(subs.module("junit:junit:4.13.1"));
3239
});
40+
config.getResolutionStrategy().eachDependency(details -> {
41+
String group = details.getRequested().getGroup();
42+
String name = details.getRequested().getName();
43+
if ("net.bytebuddy".equals(group) && ("byte-buddy".equals(name) || "byte-buddy-agent".equals(name))) {
44+
details.useVersion(project.property("byteBuddyVersion").toString());
45+
details.because("Align Byte Buddy family versions across AssertJ and Mockito");
46+
}
47+
});
3348
});
3449
}
3550
}

build-logic/src/main/java/org/ehcache/build/conventions/SpotbugsConvention.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public void apply(Project project) {
1717
SpotBugsExtension spotbugs = project.getExtensions().getByType(SpotBugsExtension.class);
1818

1919
spotbugs.getIgnoreFailures().set(false);
20-
// Later versions of Spotbugs have stupid heuristics for EI_EXPOSE_REP*
21-
spotbugs.getToolVersion().set("4.2.3");
20+
spotbugs.getToolVersion().set("4.9.8");
21+
spotbugs.getOmitVisitors().addAll("FindReturnRef", "ConstructorThrow");
2222

2323
project.getPlugins().withType(JavaBasePlugin.class).configureEach(plugin -> {
2424

@@ -46,6 +46,12 @@ public void apply(Project project) {
4646
subs.substitute(subs.module("org.apache.commons:commons-lang3:3.11"))
4747
.using(subs.module("org.apache.commons:commons-lang3:3.12.0"))
4848
.because("Spotbugs has dependency divergences");
49+
subs.substitute(subs.module("org.apache.commons:commons-lang3:3.18.0"))
50+
.using(subs.module("org.apache.commons:commons-lang3:3.19.0"))
51+
.because("Spotbugs 4.9.8 has dependency divergences");
52+
subs.substitute(subs.module("org.apache.logging.log4j:log4j-core:2.25.2"))
53+
.using(subs.module("org.apache.logging.log4j:log4j-core:2.25.3"))
54+
.because("Security vulnerability fix");
4955
});
5056
});
5157

clustered/ehcache-client/build.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ dependencies {
3737
implementation "org.terracotta:lease-api:$terracottaPlatformVersion"
3838
implementation "org.terracotta.dynamic-config.entities:dynamic-config-topology-entity-client:$terracottaPlatformVersion"
3939
implementation "org.terracotta:connection-api:$terracottaApisVersion"
40-
implementation "org.terracotta:terracotta-utilities-tools:$terracottaUtilitiesVersion"
40+
implementation ("org.terracotta:terracotta-utilities-tools:$terracottaUtilitiesVersion") {
41+
exclude group: 'org.slf4j'
42+
}
4143

4244
compileOnly 'org.osgi:org.osgi.service.component.annotations:1.3.0'
4345

@@ -60,5 +62,7 @@ dependencies {
6062
exclude group:'org.slf4j', module:'slf4j-api'
6163
}
6264
testImplementation testFixtures(project(':ehcache-xml'))
63-
testImplementation ("org.terracotta:statistics:$parent.statisticVersion")
65+
testImplementation ("org.terracotta:statistics:$parent.statisticVersion") {
66+
exclude group: 'org.slf4j', module: 'slf4j-api'
67+
}
6468
}

clustered/ehcache-client/src/main/java/org/ehcache/clustered/client/internal/service/DefaultClusteringService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ public ConnectionState getConnectionState() {
377377
return connectionState;
378378
}
379379

380+
@SuppressWarnings("removal")
380381
private static ExecutorService createAsyncWorker() {
381382
SecurityManager s = System.getSecurityManager();
382383
ThreadGroup initialGroup = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();

clustered/ehcache-client/src/main/java/org/ehcache/clustered/client/internal/store/CommonServerStoreProxy.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ public Map.Entry<Long, Chain> next() {
232232
}
233233

234234
@Override
235+
@SuppressWarnings("deprecation")
235236
protected void finalize() throws Throwable {
236237
if (!lastBatch) {
237238
entity.invokeAndWaitForReceive(new ServerStoreOpMessage.IteratorCloseMessage(iteratorId), false);

clustered/ehcache-client/src/test/java/org/ehcache/clustered/client/internal/service/DefaultClusteringServiceDestroyTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
import static org.mockito.Mockito.when;
5656
import static org.mockito.Mockito.withSettings;
5757

58+
import org.mockito.quality.Strictness;
59+
5860
/**
5961
* DefaultClusteringServiceDestroyTest
6062
*/
@@ -194,7 +196,7 @@ public void testDestroyOnPartialDestroyState() throws Exception {
194196

195197
private void mockLockForWriteLockSuccess() throws org.terracotta.exception.EntityNotProvidedException, org.terracotta.exception.EntityNotFoundException, org.terracotta.exception.EntityVersionMismatchException {
196198
when(connection.<VoltronReadWriteLockClient, Object, Void>getEntityRef(same(VoltronReadWriteLockClient.class), eq(1L), any())).thenReturn(lockEntityRef);
197-
VoltronReadWriteLockClient lockClient = mock(VoltronReadWriteLockClient.class, withSettings().lenient());
199+
VoltronReadWriteLockClient lockClient = mock(VoltronReadWriteLockClient.class, withSettings().strictness(Strictness.LENIENT));
198200
when(lockEntityRef.fetchEntity(null)).thenReturn(lockClient);
199201

200202
when(lockClient.tryLock(LockMessaging.HoldType.WRITE)).thenReturn(true);
@@ -203,7 +205,7 @@ private void mockLockForWriteLockSuccess() throws org.terracotta.exception.Entit
203205

204206
private void mockLockForReadLockSuccess() throws org.terracotta.exception.EntityNotProvidedException, org.terracotta.exception.EntityNotFoundException, org.terracotta.exception.EntityVersionMismatchException {
205207
when(connection.<VoltronReadWriteLockClient, Object, Void>getEntityRef(same(VoltronReadWriteLockClient.class), eq(1L), any())).thenReturn(lockEntityRef);
206-
VoltronReadWriteLockClient lockClient = mock(VoltronReadWriteLockClient.class, withSettings().lenient());
208+
VoltronReadWriteLockClient lockClient = mock(VoltronReadWriteLockClient.class, withSettings().strictness(Strictness.LENIENT));
207209
when(lockEntityRef.fetchEntity(null)).thenReturn(lockClient);
208210

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

clustered/ehcache-client/src/test/java/org/ehcache/clustered/client/internal/service/StateRepositoryWhitelistingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ public void testWhitelistingForPrimitiveClass() throws Exception {
166166
StateHolder<Integer, Integer> testMap = stateRepository.getPersistentStateHolder("testMap", Integer.class, Integer.class,
167167
Arrays.asList(Child.class)::contains, null);
168168

169-
testMap.putIfAbsent(new Integer(10), new Integer(20));
169+
testMap.putIfAbsent(Integer.valueOf(10), Integer.valueOf(20));
170170

171-
assertThat(testMap.get(new Integer(10)), is(new Integer(20)));
171+
assertThat(testMap.get(Integer.valueOf(10)), is(Integer.valueOf(20)));
172172
assertThat(testMap.entrySet(), hasSize(1));
173173
}
174174

clustered/ehcache-client/src/test/java/org/ehcache/clustered/client/internal/store/ClusteredStoreTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public void testGetThrowsOnlySAE() throws Exception {
231231
@SuppressWarnings("unchecked")
232232
public void testGetTimeout() throws Exception {
233233
ServerStoreProxy proxy = mock(ServerStoreProxy.class);
234-
long longKey = HashUtils.intHashToLong(new Long(1L).hashCode());
234+
long longKey = HashUtils.intHashToLong(Long.valueOf(1L).hashCode());
235235
when(proxy.get(longKey)).thenThrow(TimeoutException.class);
236236
ClusteredStore<Long, String> store = new ClusteredStore<>(config,null, null, proxy, null, null, new DefaultStatisticsService());
237237
assertThat(store.get(1L), nullValue());
@@ -630,7 +630,7 @@ public void testSingleChainSingleValue() throws StoreAccessException {
630630

631631
@Test
632632
public void testSingleChainMultipleValues() throws StoreAccessException {
633-
assertThat(Long.hashCode(1L), is(Long.hashCode(~1L)));
633+
assertThat(Long.valueOf(1L).hashCode(), is(Long.valueOf(~1L).hashCode()));
634634

635635
store.put(1L, "foo");
636636
store.put(~1L, "bar");

0 commit comments

Comments
 (0)