Enforce Java with Gradle options.release = 8

* Add suppressions for JavaDoc warnings
* Fix some tests for Java 17 compatibility
This commit is contained in:
Artem Bilan
2022-03-28 11:28:43 -04:00
parent 81f5b6bbbd
commit 6d86a15221
9 changed files with 55 additions and 48 deletions

View File

@@ -194,8 +194,7 @@ configure(javaProjects) { subproject ->
}
compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
options.release = 8
}
compileTestJava {
@@ -222,6 +221,12 @@ configure(javaProjects) { subproject ->
options.fork = true
}
tasks.withType(Javadoc) {
options.addBooleanOption('Xdoclint:syntax', true) // only check syntax with doclint
options.addBooleanOption('Werror', true) // fail build on Javadoc warnings
}
eclipse {
project {
natures += 'org.springframework.ide.eclipse.core.springnature'
@@ -996,6 +1001,7 @@ task api(type: Javadoc) {
options.overview = 'src/api/overview.html'
options.stylesheetFile = file('src/api/stylesheet.css')
options.links(project.ext.javadocLinks)
options.addBooleanOption('Xdoclint:syntax', true) // only check syntax with doclint
source javaProjects.collect { project ->
project.sourceSets.main.allJava
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -124,16 +124,7 @@ public class FileInboundChannelAdapterParserTests {
Object priorityQueue = accessor.getPropertyValue("toBeReceived");
assertThat(priorityQueue).isInstanceOf(PriorityBlockingQueue.class);
Object expected = context.getBean("testComparator");
DirectFieldAccessor queueAccessor = new DirectFieldAccessor(priorityQueue);
Object innerQueue = queueAccessor.getPropertyValue("q");
Object actual;
if (innerQueue != null) {
actual = new DirectFieldAccessor(innerQueue).getPropertyValue("comparator");
}
else {
// probably running under JDK 7
actual = queueAccessor.getPropertyValue("comparator");
}
Object actual = ((PriorityBlockingQueue) priorityQueue).comparator();
assertThat(actual).as("comparator reference not set, ").isSameAs(expected);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2021 the original author or authors.
* Copyright 2015-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@ import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Date;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -380,14 +381,21 @@ public class FileSplitterTests {
});
FileSplitter splitter = new FileSplitter(true, true);
splitter.setOutputChannel(outputChannel);
FileReader fileReader = Mockito.spy(new FileReader(file));
AtomicBoolean closeCalled = new AtomicBoolean();
FileReader fileReader = new FileReader(file) {
@Override public void close() throws IOException {
super.close();
closeCalled.set(true);
}
};
try {
splitter.handleMessage(new GenericMessage<>(fileReader));
}
catch (RuntimeException e) {
// ignore
}
Mockito.verify(fileReader).close();
assertThat(closeCalled.get()).isTrue();
}
@Configuration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,10 +18,7 @@ package org.springframework.integration.file.tail;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import java.io.File;
import java.io.FileOutputStream;
@@ -30,6 +27,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -156,7 +154,19 @@ public class FileTailingMessageProducerTests {
}
});
File file = spy(new File(this.testDir, "foo"));
AtomicBoolean existsCalled = new AtomicBoolean();
File file = new File(this.testDir, "foo") {
@Override
public boolean exists() {
try {
return super.exists();
}
finally {
existsCalled.set(true);
}
}
};
file.delete();
adapter.setFile(file);
@@ -169,7 +179,7 @@ public class FileTailingMessageProducerTests {
assertThat(noFile).as("file does not exist event did not emit ").isTrue();
boolean noEvent = idleCountDownLatch.await(100, TimeUnit.MILLISECONDS);
assertThat(noEvent).as("event should not emit when no file exit").isFalse();
verify(file, atLeastOnce()).exists();
assertThat(existsCalled.get()).isTrue();
file.createNewFile();
boolean eventRaised = idleCountDownLatch.await(10, TimeUnit.SECONDS);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 the original author or authors.
* Copyright 2016-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.springframework.integration.ip.dsl;
import static org.assertj.core.api.Assertions.assertThat;
import java.net.DatagramSocket;
import java.util.Collections;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -181,8 +180,6 @@ public class IpIntegrationTests {
Message<?> received = this.udpIn.receive(10000);
assertThat(received).isNotNull();
assertThat(Transformers.objectToString().transform(received).getPayload()).isEqualTo("foo");
assertThat(TestUtils.getPropertyValue(this.udpOutbound, "socket", DatagramSocket.class).getTrafficClass())
.isEqualTo(0x10);
}
@Test
@@ -202,7 +199,7 @@ public class IpIntegrationTests {
@Test
void testCloseStream() throws InterruptedException {
IntegrationFlow server = IntegrationFlows.from(Tcp.inboundGateway(Tcp.netServer(0)
.deserializer(new ByteArrayRawSerializer())))
.deserializer(new ByteArrayRawSerializer())))
.<byte[], String>transform(p -> "reply:" + new String(p).toUpperCase())
.get();
CountDownLatch latch = new CountDownLatch(1);
@@ -223,8 +220,8 @@ public class IpIntegrationTests {
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
IntegrationFlow client = IntegrationFlows.from(MessageChannels.direct())
.handle(Tcp.outboundGateway(Tcp.netClient("localhost", port.get())
.singleUseConnections(true)
.serializer(new ByteArrayRawSerializer()))
.singleUseConnections(true)
.serializer(new ByteArrayRawSerializer()))
.remoteTimeout(20_000)
.closeStreamAfterSend(true))
.transform(Transformers.objectToString())
@@ -262,10 +259,10 @@ public class IpIntegrationTests {
@Bean
public IntegrationFlow inTcpGateway() {
return IntegrationFlows.from(
Tcp.inboundGateway(server1())
.replyTimeout(1)
.errorOnTimeout(true)
.errorChannel("inTcpGatewayErrorFlow.input"))
Tcp.inboundGateway(server1())
.replyTimeout(1)
.errorOnTimeout(true)
.errorChannel("inTcpGatewayErrorFlow.input"))
.handle(this, "captureId")
.transform(Transformers.objectToString())
.<String>filter((payload) -> !"junk".equals(payload))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,10 +18,9 @@ package org.springframework.integration.mongodb.config;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import org.junit.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -33,6 +32,7 @@ import org.springframework.integration.handler.advice.RequestHandlerRetryAdvice;
import org.springframework.integration.mongodb.outbound.MongoDbStoringMessageHandler;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.MessageHandler;
/**
* @author Oleg Zhurakousky
* @author Artem Bilan
@@ -129,9 +129,7 @@ public class MongoDbOutboundChannelAdapterParserTests {
assertThat(endpoint).isInstanceOf(PollingConsumer.class);
MessageHandler handler = TestUtils.getPropertyValue(endpoint, "handler", MessageHandler.class);
assertThat(AopUtils.isAopProxy(handler)).isTrue();
List<?> advisors = TestUtils.getPropertyValue(handler, "h.advised.advisors", List.class);
assertThat(TestUtils.getPropertyValue(advisors.get(0), "advice")).isInstanceOf(RequestHandlerRetryAdvice.class);
context.close();
assertThat(((Advised) handler).getAdvisors()[0].getAdvice()).isInstanceOf(RequestHandlerRetryAdvice.class);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -89,8 +89,7 @@ public class MqttOutboundChannelAdapterParserTests {
assertThat(this.withConverterHandler).isSameAs(((Advised) handler).getTargetSource().getTarget());
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors[0].advice"))
.isInstanceOf(RequestHandlerRetryAdvice.class);
assertThat(((Advised) handler).getAdvisors()[0].getAdvice()).isInstanceOf(RequestHandlerRetryAdvice.class);
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 the original author or authors.
* Copyright 2013-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -86,8 +86,7 @@ public class RedisQueueOutboundChannelAdapterParserTests {
assertThat(this.defaultAdapter).isSameAs(((Advised) handler).getTargetSource().getTarget());
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors[0].advice"))
.isInstanceOf(RequestHandlerRetryAdvice.class);
assertThat(((Advised) handler).getAdvisors()[0].getAdvice()).isInstanceOf(RequestHandlerRetryAdvice.class);
assertThat(TestUtils.getPropertyValue(this.defaultAdapter, "leftPush", Boolean.class)).isTrue();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2007-2019 the original author or authors.
* Copyright 2007-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -72,8 +72,7 @@ public class RedisStoreOutboundChannelAdapterParserTests {
assertThat(withStringTemplate).isSameAs(((Advised) handler).getTargetSource().getTarget());
assertThat(TestUtils.getPropertyValue(handler, "h.advised.advisors[0].advice"))
.isInstanceOf(RequestHandlerRetryAdvice.class);
assertThat(((Advised) handler).getAdvisors()[0].getAdvice()).isInstanceOf(RequestHandlerRetryAdvice.class);
assertThat(TestUtils.getPropertyValue(withStringTemplate, "zsetIncrementScoreExpression",
Expression.class).getExpressionString()).isEqualTo("true");