Skip to content

Commit

Permalink
Java 21 Support (#1440)
Browse files Browse the repository at this point in the history
* Switch back to Mojo aspectj plugin for Java 21 support

* Update AspectJ

* Update Jacoco plugin to support Java 21

* Update to Mockito 5 for Java 21 support

* update dependencies

* feat: use java 21 image

* Update spring framework dependency

* Explicitly enable annotation processing during compilation.

[INFO] Annotation processing is enabled because one or more processors were found
  on the class path. A future release of javac may disable annotation processing
  unless at least one processor is specified by name (-processor), or a search
  path is specified (--processor-path, --processor-module-path), or annotation
  processing is enabled explicitly (-proc:only, -proc:full).
  Use -Xlint:-options to suppress this message.
  Use -proc:none to disable annotation processing.

* Mock and Spy integration test components

* Rename duplicate classes

* Fix Tag import

* Use MockFactoryBean everywhere

* Upgraded shedlock to latest

"If you are using JDK >17 and up-to-date libraries like Spring 6, use version 5.1.0 (Release Notes)" according to https://github.com/lukas-krecan/ShedLock

* Shedlock breaks with latest Spring

* Specify aspectj mode for cache configuration

* Specify aspectj mode for scheduler config

* Updated Spring by applying AOP workaround suggested in spring-projects/spring-framework#32882 (comment)

"These problems come from mixed AspectJ weaving and proxying. In your scenario, you seem to be using @EnableTransactionManagement in AspectJ mode but @EnableCaching in proxy mode. For the time being, you could try to switch @EnableCaching and any other aspect-related functionality to AspectJ mode as well and remove any variant of@EnableAspectJAutoProxy completely, if that is feasible for your application."

* Replace deprecated thread.getId() with threadId().

* use whois-build:v0.0.5 - java21, amazoncorretto, node18, firefox114

---------

Co-authored-by: mherran <mherran@ripe.net>
  • Loading branch information
eshryane and MiguelAHM authored Jun 4, 2024
1 parent 9c309d0 commit d114d80
Show file tree
Hide file tree
Showing 35 changed files with 137 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: $CI_REGISTRY/swe-database-team/gitlab-ci/whois-build:21fc0efa
image: $CI_REGISTRY/swe-database-team/gitlab-ci/whois-build:v0.0.5

variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
Expand Down
19 changes: 10 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<!-- JAVA version -->
<java.version>17</java.version>
<java.version>21</java.version>

<!-- dependencies -->

<aspectj.version>1.9.21.1</aspectj.version>
<aspectj.version>1.9.22.1</aspectj.version>
<awaitility.version>4.2.0</awaitility.version>

<bouncycastle.version>1.77</bouncycastle.version>
Expand Down Expand Up @@ -80,7 +80,7 @@
<mail.version>2.0.3</mail.version>
<!-- TODO: update mariadb to 3.x -->
<mariadb-java-client.version>2.7.12</mariadb-java-client.version>
<mockito.version>3.12.4</mockito.version>
<mockito.version>5.12.0</mockito.version>

<netty.version>4.1.107.Final</netty.version>

Expand All @@ -89,10 +89,10 @@
<proprot.version>1.0</proprot.version>

<sentry.version>6.26.0</sentry.version>
<shedlock.version>4.46.0</shedlock.version>
<shedlock.version>5.13.0</shedlock.version>
<slf4j.version>2.0.12</slf4j.version>
<solrj.version>1.4.1</solrj.version>
<spring.version>6.1.4</spring.version>
<spring.version>6.1.8</spring.version>
<spock.version>2.3-groovy-3.0</spock.version>
<stax-utils.version>20070216</stax-utils.version>

Expand Down Expand Up @@ -818,7 +818,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<version>0.8.12</version>
<executions>
<execution>
<id>before-unit-test-execution</id>
Expand Down Expand Up @@ -926,6 +926,8 @@
<arg>-Xlint:-processing</arg>
<arg>--add-modules</arg>
<arg>java.sql,java.xml</arg>
<!-- explicitly enable annotation processing. -->
<arg>-proc:full</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
Expand Down Expand Up @@ -1036,10 +1038,9 @@
</executions>
</plugin>
<plugin>
<!-- Plugin forked from mojohaus project to add Java 11 support -->
<groupId>io.starter</groupId>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.12.9</version>
<version>1.15.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
Expand Down
4 changes: 2 additions & 2 deletions whois-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@
</resources>
<plugins>
<plugin>
<groupId>io.starter</groupId>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.12.9</version>
<version>1.15.0</version>
<configuration>
<aspectLibraries>
<aspectLibrary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public MailMessageDaoJdbc(
@CheckForNull
public String claimMessage() {
final String uuid = UUID.randomUUID().toString();
LOGGER.debug("[{}] about to claim message with uuid {}", Thread.currentThread().getId(), uuid);
LOGGER.debug("[{}] about to claim message with uuid {}", Thread.currentThread().threadId(), uuid);
final int rows = jdbcTemplate.update("" +
"update mailupdates " +
"set status = ?, changed = ?, claim_host = ?, claim_uuid = ? " +
Expand All @@ -62,7 +62,7 @@ public String claimMessage() {
case 0:
return null;
case 1:
LOGGER.debug("[{}] claimed message with uuid {}", Thread.currentThread().getId(), uuid);
LOGGER.debug("[{}] claimed message with uuid {}", Thread.currentThread().threadId(), uuid);
return uuid;
default:
throw new IllegalStateException("Should never claim more than 1 row");
Expand All @@ -88,7 +88,7 @@ public void addMessage(final MimeMessage message) {

@Override
public MimeMessage getMessage(final String messageUuid) {
LOGGER.debug("[{}] get message with uuid {}", Thread.currentThread().getId(), messageUuid);
LOGGER.debug("[{}] get message with uuid {}", Thread.currentThread().threadId(), messageUuid);

final byte[] bytes = jdbcTemplate.queryForObject("select message from mailupdates where claim_uuid = ?", byte[].class, messageUuid);

Expand All @@ -101,7 +101,7 @@ public MimeMessage getMessage(final String messageUuid) {

@Override
public void deleteMessage(final String messageUuid) {
LOGGER.debug("[{}] delete message with uuid {}", Thread.currentThread().getId(), messageUuid);
LOGGER.debug("[{}] delete message with uuid {}", Thread.currentThread().threadId(), messageUuid);

int rows = jdbcTemplate.update("delete from mailupdates where claim_uuid = ?", messageUuid);
if (rows != 1) {
Expand All @@ -111,7 +111,7 @@ public void deleteMessage(final String messageUuid) {

@Override
public void setStatus(final String messageUuid, final DequeueStatus status) {
LOGGER.debug("[{}] set status uuid {} status {}", Thread.currentThread().getId(), messageUuid, status);
LOGGER.debug("[{}] set status uuid {} status {}", Thread.currentThread().threadId(), messageUuid, status);

final int rows = jdbcTemplate.update(
"update mailupdates set status = ?, changed = ? where claim_uuid = ?",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
location="classpath:whois.version.properties,classpath:whois.properties"
system-properties-mode="OVERRIDE"/>

<bean id="messageDequeue" class="org.mockito.Mockito" factory-method="mock" primary="true">
<constructor-arg value="net.ripe.db.whois.api.mail.dequeue.MessageDequeue"/>
<bean id="messageDequeue" class="net.ripe.db.whois.query.support.MockFactoryBean" primary="true">
<constructor-arg name="mock" value="net.ripe.db.whois.api.mail.dequeue.MessageDequeue" />
</bean>


</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
location="classpath:whois.version.properties,classpath:whois.properties"
system-properties-mode="OVERRIDE"/>

<bean id="updateRequestHandler" class="org.mockito.Mockito" factory-method="mock" primary="true">
<constructor-arg value="net.ripe.db.whois.update.handler.UpdateRequestHandler"/>
<bean id="updateRequestHandler" class="net.ripe.db.whois.query.support.MockFactoryBean" primary="true">
<constructor-arg name="mock" value="net.ripe.db.whois.update.handler.UpdateRequestHandler" />
</bean>

</beans>
2 changes: 1 addition & 1 deletion whois-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<version>0.8.12</version>
<!-- TODO: Including this in jacoco plugin throws Can't add different class with same name: org/apache/commons/collections/ArrayStack
I tried to exclude this file, package and dependency also still from some other dependency tree it gets included
-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:cache="http://www.springframework.org/schema/cache" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd">
http://www.springframework.org/schema/cache/spring-cache.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd">

<!-- TODO: this is loaded many many times on context init, which slows down startup process -->
<!-- @Transactional CAN be used on private methods with mode="aspectj". However, annotations on interfaces will NOT work! -->
Expand All @@ -21,7 +21,9 @@
<context:component-scan base-package="net.ripe.db.whois.common"/>

<context:annotation-config/>
<cache:annotation-driven/>
<cache:annotation-driven mode="aspectj"/>

<!-- <aop:aspectj-autoproxy proxy-target-class="true"/>-->

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="sourceAwareDataSource"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.concurrent.atomic.AtomicInteger;

@Component
@RetryFor(value = IOException.class, attempts = RetryForAspectIntegrationTest.ATTEMPTS, intervalMs = 0)
@RetryFor(value = IOException.class, attempts = RetryForAspectMethodTypeIntegrationTest.ATTEMPTS, intervalMs = 0)
class RetryForAspectMethodImpl implements RetryForAspectMethod {
@Override
public void incrementAndThrowException(final AtomicInteger counter, final Exception e) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static org.junit.jupiter.api.Assertions.fail;

@Tag("IntegrationTest")
public class RetryForAspectIntegrationTest extends AbstractDaoIntegrationTest {
public class RetryForAspectMethodTypeIntegrationTest extends AbstractDaoIntegrationTest {
static final int ATTEMPTS = 5;

AtomicInteger attemptCounter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
import java.util.concurrent.atomic.AtomicInteger;

public interface RetryForAspectType {
@RetryFor(value = IOException.class, attempts = RetryForAspectIntegrationTest.ATTEMPTS, intervalMs = 0)
@RetryFor(value = IOException.class, attempts = RetryForAspectMethodTypeIntegrationTest.ATTEMPTS, intervalMs = 0)
void incrementAndThrowException(AtomicInteger counter, Exception e) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@Component
class RetryForAspectTypeImpl implements RetryForAspectType {
@Override
@RetryFor(value = IOException.class, attempts = RetryForAspectIntegrationTest.ATTEMPTS, intervalMs = 0)
@RetryFor(value = IOException.class, attempts = RetryForAspectMethodTypeIntegrationTest.ATTEMPTS, intervalMs = 0)
public void incrementAndThrowException(final AtomicInteger counter, final Exception e) throws Exception {
counter.incrementAndGet();
throw e;
Expand Down
4 changes: 2 additions & 2 deletions whois-db/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@
<build>
<plugins>
<plugin>
<groupId>io.starter</groupId>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.12.9</version>
<version>1.15.0</version>
<configuration>
<aspectLibraries>
<aspectLibrary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

@Tag("IntegrationTest")
@ContextConfiguration(locations = {"classpath:applicationContext-whois-test.xml"})
public class RetryForAspectIntegrationTest extends AbstractDaoIntegrationTest {
public class RetryForAspectClassIntegrationTest extends AbstractDaoIntegrationTest {
static final int ATTEMPTS = 5;

AtomicInteger attemptCounter;
Expand Down Expand Up @@ -90,7 +90,7 @@ private void retryForAnnotatedType(final Exception e, final int expectedAttempts
assertThat(attemptCounter.get(), is(expectedAttempts));
}

@RetryFor(value = IOException.class, attempts = RetryForAspectIntegrationTest.ATTEMPTS, intervalMs = 0)
@RetryFor(value = IOException.class, attempts = RetryForAspectClassIntegrationTest.ATTEMPTS, intervalMs = 0)
public void incrementAndThrowException(final AtomicInteger counter, final Exception e) throws Exception {
counter.incrementAndGet();
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.concurrent.atomic.AtomicInteger;

@Component
@RetryFor(value = IOException.class, attempts = RetryForAspectIntegrationTest.ATTEMPTS, intervalMs = 0)
@RetryFor(value = IOException.class, attempts = RetryForAspectClassIntegrationTest.ATTEMPTS, intervalMs = 0)
class RetryForAspectOnClass {
public void incrementAndThrowException(final AtomicInteger counter, final Exception e) throws Exception {
counter.incrementAndGet();
Expand Down
4 changes: 2 additions & 2 deletions whois-endtoend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@
<build>
<plugins>
<plugin>
<groupId>io.starter</groupId>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.12.9</version>
<version>1.15.0</version>
<configuration>
<skip>true</skip>
<aspectLibraries>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package net.ripe.db.whois.spec.update.lireditable


import net.ripe.db.whois.spec.BaseQueryUpdateSpec
import org.junit.jupiter.api.Tag

@org.junit.jupiter.api.Tag("IntegrationTest")
@Tag("IntegrationTest")
class BaseLirEditableAttributes extends BaseQueryUpdateSpec {

def createMandatory(String type,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package net.ripe.db.whois.spec.update.lireditable

import org.junit.jupiter.api.Tag


@org.junit.jupiter.api.Tag("IntegrationTest")
@Tag("IntegrationTest")
class LirEditableAllocation6AttributeValidationSpec extends BaseLirEditableAttributeValidation {

// data for tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package net.ripe.db.whois.spec.update.lireditable

import org.junit.jupiter.api.Tag


@org.junit.jupiter.api.Tag("IntegrationTest")
@Tag("IntegrationTest")
class LirEditableAllocationAttributeValidationSpec extends BaseLirEditableAttributeValidation {

// data for tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package net.ripe.db.whois.spec.update.lireditable

import org.junit.jupiter.api.Tag


@org.junit.jupiter.api.Tag("IntegrationTest")
@Tag("IntegrationTest")
class LirEditableInet6numAssignedAttributeValidationSpec extends BaseLirEditableAttributeValidation {

// data for tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package net.ripe.db.whois.spec.update.lireditable

import org.junit.jupiter.api.Tag


@org.junit.jupiter.api.Tag("IntegrationTest")
@Tag("IntegrationTest")
class LirEditableInet6numAssignedPiAttributeValidationSpec extends BaseLirEditableAttributeValidation {

// data for tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.ripe.db.whois.spec.update.lireditable

@org.junit.jupiter.api.Tag("IntegrationTest")
import org.junit.jupiter.api.Tag

@Tag("IntegrationTest")
class LirEditableInetnumAssignedPaAttributeValidationSpec extends BaseLirEditableAttributeValidation {

// data for tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package net.ripe.db.whois.spec.update.lireditable

import org.junit.jupiter.api.Tag


@org.junit.jupiter.api.Tag("IntegrationTest")
@Tag("IntegrationTest")
class LirEditableInetnumAssignedPiAttributeValidationSpec extends BaseLirEditableAttributeValidation {

// data for tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package net.ripe.db.whois.spec.update.lireditable

import org.junit.jupiter.api.Tag


@org.junit.jupiter.api.Tag("IntegrationTest")
@Tag("IntegrationTest")
class LirEditableLegacyAttributeValidationSpec extends BaseLirEditableAttributeValidation {

// data for tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package net.ripe.db.whois.spec.update.lireditable


import net.ripe.db.whois.spec.BaseQueryUpdateSpec
import org.junit.jupiter.api.Tag


@org.junit.jupiter.api.Tag("IntegrationTest")
@Tag("IntegrationTest")
class LirEditableOrganisationAttributeValidationSpec extends BaseQueryUpdateSpec {

@Override
Expand Down
4 changes: 2 additions & 2 deletions whois-nrtm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@
</resources>
<plugins>
<plugin>
<groupId>io.starter</groupId>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.12.9</version>
<version>1.15.0</version>
<configuration>
<aspectLibraries>
<aspectLibrary>
Expand Down
4 changes: 2 additions & 2 deletions whois-nrtm4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
<build>
<plugins>
<plugin>
<groupId>io.starter</groupId>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.12.9</version>
<version>1.15.0</version>
<configuration>
<aspectLibraries>
<aspectLibrary>
Expand Down
Loading

0 comments on commit d114d80

Please sign in to comment.