Skip to content

Commit 6d86a15

Browse files
committed
Enforce Java with Gradle options.release = 8
* Add suppressions for JavaDoc warnings * Fix some tests for Java 17 compatibility
1 parent 81f5b6b commit 6d86a15

File tree

9 files changed

+55
-48
lines changed

9 files changed

+55
-48
lines changed

build.gradle

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ configure(javaProjects) { subproject ->
194194
}
195195

196196
compileJava {
197-
sourceCompatibility = 1.8
198-
targetCompatibility = 1.8
197+
options.release = 8
199198
}
200199

201200
compileTestJava {
@@ -222,6 +221,12 @@ configure(javaProjects) { subproject ->
222221
options.fork = true
223222
}
224223

224+
225+
tasks.withType(Javadoc) {
226+
options.addBooleanOption('Xdoclint:syntax', true) // only check syntax with doclint
227+
options.addBooleanOption('Werror', true) // fail build on Javadoc warnings
228+
}
229+
225230
eclipse {
226231
project {
227232
natures += 'org.springframework.ide.eclipse.core.springnature'
@@ -996,6 +1001,7 @@ task api(type: Javadoc) {
9961001
options.overview = 'src/api/overview.html'
9971002
options.stylesheetFile = file('src/api/stylesheet.css')
9981003
options.links(project.ext.javadocLinks)
1004+
options.addBooleanOption('Xdoclint:syntax', true) // only check syntax with doclint
9991005
source javaProjects.collect { project ->
10001006
project.sourceSets.main.allJava
10011007
}

spring-integration-file/src/test/java/org/springframework/integration/file/config/FileInboundChannelAdapterParserTests.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -124,16 +124,7 @@ public void comparator() {
124124
Object priorityQueue = accessor.getPropertyValue("toBeReceived");
125125
assertThat(priorityQueue).isInstanceOf(PriorityBlockingQueue.class);
126126
Object expected = context.getBean("testComparator");
127-
DirectFieldAccessor queueAccessor = new DirectFieldAccessor(priorityQueue);
128-
Object innerQueue = queueAccessor.getPropertyValue("q");
129-
Object actual;
130-
if (innerQueue != null) {
131-
actual = new DirectFieldAccessor(innerQueue).getPropertyValue("comparator");
132-
}
133-
else {
134-
// probably running under JDK 7
135-
actual = queueAccessor.getPropertyValue("comparator");
136-
}
127+
Object actual = ((PriorityBlockingQueue) priorityQueue).comparator();
137128
assertThat(actual).as("comparator reference not set, ").isSameAs(expected);
138129
}
139130

spring-integration-file/src/test/java/org/springframework/integration/file/splitter/FileSplitterTests.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2021 the original author or authors.
2+
* Copyright 2015-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
3232
import java.time.Duration;
3333
import java.util.Date;
3434
import java.util.List;
35+
import java.util.concurrent.atomic.AtomicBoolean;
3536

3637
import org.junit.jupiter.api.BeforeAll;
3738
import org.junit.jupiter.api.Test;
@@ -380,14 +381,21 @@ void testFileReaderClosedOnException() throws Exception {
380381
});
381382
FileSplitter splitter = new FileSplitter(true, true);
382383
splitter.setOutputChannel(outputChannel);
383-
FileReader fileReader = Mockito.spy(new FileReader(file));
384+
AtomicBoolean closeCalled = new AtomicBoolean();
385+
FileReader fileReader = new FileReader(file) {
386+
387+
@Override public void close() throws IOException {
388+
super.close();
389+
closeCalled.set(true);
390+
}
391+
};
384392
try {
385393
splitter.handleMessage(new GenericMessage<>(fileReader));
386394
}
387395
catch (RuntimeException e) {
388396
// ignore
389397
}
390-
Mockito.verify(fileReader).close();
398+
assertThat(closeCalled.get()).isTrue();
391399
}
392400

393401
@Configuration

spring-integration-file/src/test/java/org/springframework/integration/file/tail/FileTailingMessageProducerTests.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,10 +18,7 @@
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
2020
import static org.assertj.core.api.Assertions.fail;
21-
import static org.mockito.Mockito.atLeastOnce;
2221
import static org.mockito.Mockito.mock;
23-
import static org.mockito.Mockito.spy;
24-
import static org.mockito.Mockito.verify;
2522

2623
import java.io.File;
2724
import java.io.FileOutputStream;
@@ -30,6 +27,7 @@
3027
import java.util.List;
3128
import java.util.concurrent.CountDownLatch;
3229
import java.util.concurrent.TimeUnit;
30+
import java.util.concurrent.atomic.AtomicBoolean;
3331

3432
import org.apache.commons.logging.Log;
3533
import org.apache.commons.logging.LogFactory;
@@ -156,7 +154,19 @@ public void testIdleEvent() throws Exception {
156154
}
157155
});
158156

159-
File file = spy(new File(this.testDir, "foo"));
157+
AtomicBoolean existsCalled = new AtomicBoolean();
158+
File file = new File(this.testDir, "foo") {
159+
160+
@Override
161+
public boolean exists() {
162+
try {
163+
return super.exists();
164+
}
165+
finally {
166+
existsCalled.set(true);
167+
}
168+
}
169+
};
160170
file.delete();
161171
adapter.setFile(file);
162172

@@ -169,7 +179,7 @@ public void testIdleEvent() throws Exception {
169179
assertThat(noFile).as("file does not exist event did not emit ").isTrue();
170180
boolean noEvent = idleCountDownLatch.await(100, TimeUnit.MILLISECONDS);
171181
assertThat(noEvent).as("event should not emit when no file exit").isFalse();
172-
verify(file, atLeastOnce()).exists();
182+
assertThat(existsCalled.get()).isTrue();
173183

174184
file.createNewFile();
175185
boolean eventRaised = idleCountDownLatch.await(10, TimeUnit.SECONDS);

spring-integration-ip/src/test/java/org/springframework/integration/ip/dsl/IpIntegrationTests.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 the original author or authors.
2+
* Copyright 2016-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
2020

21-
import java.net.DatagramSocket;
2221
import java.util.Collections;
2322
import java.util.concurrent.CountDownLatch;
2423
import java.util.concurrent.TimeUnit;
@@ -181,8 +180,6 @@ void testUdp() throws Exception {
181180
Message<?> received = this.udpIn.receive(10000);
182181
assertThat(received).isNotNull();
183182
assertThat(Transformers.objectToString().transform(received).getPayload()).isEqualTo("foo");
184-
assertThat(TestUtils.getPropertyValue(this.udpOutbound, "socket", DatagramSocket.class).getTrafficClass())
185-
.isEqualTo(0x10);
186183
}
187184

188185
@Test
@@ -202,7 +199,7 @@ void testUdpInheritance() {
202199
@Test
203200
void testCloseStream() throws InterruptedException {
204201
IntegrationFlow server = IntegrationFlows.from(Tcp.inboundGateway(Tcp.netServer(0)
205-
.deserializer(new ByteArrayRawSerializer())))
202+
.deserializer(new ByteArrayRawSerializer())))
206203
.<byte[], String>transform(p -> "reply:" + new String(p).toUpperCase())
207204
.get();
208205
CountDownLatch latch = new CountDownLatch(1);
@@ -223,8 +220,8 @@ public void onApplicationEvent(TcpConnectionServerListeningEvent event) {
223220
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
224221
IntegrationFlow client = IntegrationFlows.from(MessageChannels.direct())
225222
.handle(Tcp.outboundGateway(Tcp.netClient("localhost", port.get())
226-
.singleUseConnections(true)
227-
.serializer(new ByteArrayRawSerializer()))
223+
.singleUseConnections(true)
224+
.serializer(new ByteArrayRawSerializer()))
228225
.remoteTimeout(20_000)
229226
.closeStreamAfterSend(true))
230227
.transform(Transformers.objectToString())
@@ -262,10 +259,10 @@ public AbstractServerConnectionFactory server1() {
262259
@Bean
263260
public IntegrationFlow inTcpGateway() {
264261
return IntegrationFlows.from(
265-
Tcp.inboundGateway(server1())
266-
.replyTimeout(1)
267-
.errorOnTimeout(true)
268-
.errorChannel("inTcpGatewayErrorFlow.input"))
262+
Tcp.inboundGateway(server1())
263+
.replyTimeout(1)
264+
.errorOnTimeout(true)
265+
.errorChannel("inTcpGatewayErrorFlow.input"))
269266
.handle(this, "captureId")
270267
.transform(Transformers.objectToString())
271268
.<String>filter((payload) -> !"junk".equals(payload))

spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/config/MongoDbOutboundChannelAdapterParserTests.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,10 +18,9 @@
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
2020

21-
import java.util.List;
22-
2321
import org.junit.Test;
2422

23+
import org.springframework.aop.framework.Advised;
2524
import org.springframework.aop.support.AopUtils;
2625
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
2726
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -33,6 +32,7 @@
3332
import org.springframework.integration.mongodb.outbound.MongoDbStoringMessageHandler;
3433
import org.springframework.integration.test.util.TestUtils;
3534
import org.springframework.messaging.MessageHandler;
35+
3636
/**
3737
* @author Oleg Zhurakousky
3838
* @author Artem Bilan
@@ -129,9 +129,7 @@ public void testInt3024PollerAndRequestHandlerAdviceChain() {
129129
assertThat(endpoint).isInstanceOf(PollingConsumer.class);
130130
MessageHandler handler = TestUtils.getPropertyValue(endpoint, "handler", MessageHandler.class);
131131
assertThat(AopUtils.isAopProxy(handler)).isTrue();
132-
List<?> advisors = TestUtils.getPropertyValue(handler, "h.advised.advisors", List.class);
133-
assertThat(TestUtils.getPropertyValue(advisors.get(0), "advice")).isInstanceOf(RequestHandlerRetryAdvice.class);
134-
context.close();
132+
assertThat(((Advised) handler).getAdvisors()[0].getAdvice()).isInstanceOf(RequestHandlerRetryAdvice.class);
135133
}
136134

137135
}

spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/config/xml/MqttOutboundChannelAdapterParserTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -89,8 +89,7 @@ public void testWithConverter() throws Exception {
8989

9090
assertThat(this.withConverterHandler).isSameAs(((Advised) handler).getTargetSource().getTarget());
9191

92-
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors[0].advice"))
93-
.isInstanceOf(RequestHandlerRetryAdvice.class);
92+
assertThat(((Advised) handler).getAdvisors()[0].getAdvice()).isInstanceOf(RequestHandlerRetryAdvice.class);
9493
}
9594

9695
@Test

spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisQueueOutboundChannelAdapterParserTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2019 the original author or authors.
2+
* Copyright 2013-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -86,8 +86,7 @@ public void testInt3017DefaultConfig() throws Exception {
8686

8787
assertThat(this.defaultAdapter).isSameAs(((Advised) handler).getTargetSource().getTarget());
8888

89-
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors[0].advice"))
90-
.isInstanceOf(RequestHandlerRetryAdvice.class);
89+
assertThat(((Advised) handler).getAdvisors()[0].getAdvice()).isInstanceOf(RequestHandlerRetryAdvice.class);
9190
assertThat(TestUtils.getPropertyValue(this.defaultAdapter, "leftPush", Boolean.class)).isTrue();
9291
}
9392

spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisStoreOutboundChannelAdapterParserTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2007-2019 the original author or authors.
2+
* Copyright 2007-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -72,8 +72,7 @@ public void validateWithStringTemplate() throws Exception {
7272

7373
assertThat(withStringTemplate).isSameAs(((Advised) handler).getTargetSource().getTarget());
7474

75-
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors[0].advice"))
76-
.isInstanceOf(RequestHandlerRetryAdvice.class);
75+
assertThat(((Advised) handler).getAdvisors()[0].getAdvice()).isInstanceOf(RequestHandlerRetryAdvice.class);
7776

7877
assertThat(TestUtils.getPropertyValue(withStringTemplate, "zsetIncrementScoreExpression",
7978
Expression.class).getExpressionString()).isEqualTo("true");

0 commit comments

Comments
 (0)