From 505c917d23b9f39d99980f97a082fb4310922e3f Mon Sep 17 00:00:00 2001 From: David Gerber Date: Thu, 21 Nov 2024 21:26:13 +0100 Subject: [PATCH] Upgrade Gradle and Spring Boot --- app/src/main/java/io/xeres/app/api/DefaultHandler.java | 10 ++-------- app/src/main/resources/application-dev.properties | 5 +---- .../app/database/model/location/LocationFakes.java | 8 ++++++++ .../xeres/app/database/model/profile/ProfileFakes.java | 5 +++++ .../repository/GxsClientUpdateRepositoryTest.java | 8 ++++---- .../database/repository/LocationRepositoryTest.java | 8 ++++---- .../app/database/repository/ProfileRepositoryTest.java | 6 +++--- build.gradle | 6 +++--- gradle.properties | 1 + gradle/wrapper/gradle-wrapper.properties | 2 +- 10 files changed, 32 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/io/xeres/app/api/DefaultHandler.java b/app/src/main/java/io/xeres/app/api/DefaultHandler.java index f356a9dfb..30cc57f8b 100644 --- a/app/src/main/java/io/xeres/app/api/DefaultHandler.java +++ b/app/src/main/java/io/xeres/app/api/DefaultHandler.java @@ -25,6 +25,7 @@ import io.swagger.v3.oas.annotations.info.License; import io.xeres.app.api.exception.UnprocessableEntityException; import io.xeres.common.AppName; +import jakarta.annotation.Nonnull; import jakarta.persistence.EntityNotFoundException; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.exception.ExceptionUtils; @@ -36,7 +37,6 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.context.request.WebRequest; -import org.springframework.web.context.request.async.AsyncRequestNotUsableException; import org.springframework.web.server.ResponseStatusException; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; @@ -111,15 +111,9 @@ public ResponseEntity handleResponseStatusException(ResponseStatusExceptio return new ResponseEntity<>(e.getStatusCode()); } - @ExceptionHandler(AsyncRequestNotUsableException.class) - public void handleAsyncRequestNotUsableException(AsyncRequestNotUsableException ignored) - { - // We ignore those because they happen when scrolling images (we abort useless loads when scrolling quickly). - } - // This one has to use an override @Override - protected ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatusCode status, WebRequest request) + protected ResponseEntity handleMethodArgumentNotValid(@Nonnull MethodArgumentNotValidException ex, @Nonnull HttpHeaders headers, HttpStatusCode status, @Nonnull WebRequest request) { var problemDetail = handleValidationException(ex); return ResponseEntity.status(status.value()).body(problemDetail); diff --git a/app/src/main/resources/application-dev.properties b/app/src/main/resources/application-dev.properties index 2cead72a7..582217234 100644 --- a/app/src/main/resources/application-dev.properties +++ b/app/src/main/resources/application-dev.properties @@ -80,16 +80,13 @@ logging.level.io.xeres.app.xrs.service.turtle=DEBUG ### Other settings -## Flyway -spring.flyway.clean-on-validation-error=false - ## Swagger UI springdoc.swagger-ui.tags-sorter=alpha ## Actuator info.java.vm.vendor=${java.vm.vendor} info.java.version=${java.version} -management.endpoint.shutdown.enabled=true +management.endpoint.shutdown.access=unrestricted management.endpoints.web.exposure.include=* management.endpoints.web.base-path=/api/v1/actuator management.info.java.enabled=true diff --git a/app/src/test/java/io/xeres/app/database/model/location/LocationFakes.java b/app/src/test/java/io/xeres/app/database/model/location/LocationFakes.java index bf54b7c9b..081315048 100644 --- a/app/src/test/java/io/xeres/app/database/model/location/LocationFakes.java +++ b/app/src/test/java/io/xeres/app/database/model/location/LocationFakes.java @@ -58,6 +58,14 @@ public static Location createLocation(String name, Profile profile) return createLocation(name, profile, new LocationId(getRandomArray())); } + public static Location createFreshLocation(String name, Profile profile) + { + var location = new Location(0L, name, profile, new LocationId(getRandomArray())); + location.setNetMode(NetMode.UPNP); + location.setVersion("Xeres 0.1.1"); + return location; + } + public static Location createLocation(String name, Profile profile, LocationId locationId) { var location = new Location(getUniqueId(), name, profile, locationId); diff --git a/app/src/test/java/io/xeres/app/database/model/profile/ProfileFakes.java b/app/src/test/java/io/xeres/app/database/model/profile/ProfileFakes.java index 5c3bf158d..3ea85efcb 100644 --- a/app/src/test/java/io/xeres/app/database/model/profile/ProfileFakes.java +++ b/app/src/test/java/io/xeres/app/database/model/profile/ProfileFakes.java @@ -46,6 +46,11 @@ public static Profile createProfile() return createProfile(StringFakes.createNickname(), ThreadLocalRandom.current().nextLong()); } + public static Profile createFreshProfile(String name, long pgpIdentifier) + { + return new Profile(0L, name, pgpIdentifier, Instant.now(), new ProfileFingerprint(getRandomArray(20)), getRandomArray(200)); + } + public static Profile createProfile(String name, long pgpIdentifier) { return createProfile(name, pgpIdentifier, new ProfileFingerprint(getRandomArray(20)), getRandomArray(200)); diff --git a/app/src/test/java/io/xeres/app/database/repository/GxsClientUpdateRepositoryTest.java b/app/src/test/java/io/xeres/app/database/repository/GxsClientUpdateRepositoryTest.java index bdddf17e0..92dec913f 100644 --- a/app/src/test/java/io/xeres/app/database/repository/GxsClientUpdateRepositoryTest.java +++ b/app/src/test/java/io/xeres/app/database/repository/GxsClientUpdateRepositoryTest.java @@ -43,9 +43,9 @@ class GxsClientUpdateRepositoryTest @Test void CRUD_Success() { - var profile = ProfileFakes.createProfile("profile1", 1); + var profile = ProfileFakes.createFreshProfile("profile1", 1); profile = profileRepository.save(profile); - var location = LocationFakes.createLocation("location1", profile); + var location = LocationFakes.createFreshLocation("location1", profile); profile.addLocation(location); profile = profileRepository.save(profile); @@ -89,9 +89,9 @@ void CRUD_Success() @Test void CRUD_Messages_Success() { - var profile = ProfileFakes.createProfile("profile1", 1); + var profile = ProfileFakes.createFreshProfile("profile1", 1); profile = profileRepository.save(profile); - var location = LocationFakes.createLocation("location1", profile); + var location = LocationFakes.createFreshLocation("location1", profile); profile.addLocation(location); profile = profileRepository.save(profile); diff --git a/app/src/test/java/io/xeres/app/database/repository/LocationRepositoryTest.java b/app/src/test/java/io/xeres/app/database/repository/LocationRepositoryTest.java index fea2b014f..1747acb18 100644 --- a/app/src/test/java/io/xeres/app/database/repository/LocationRepositoryTest.java +++ b/app/src/test/java/io/xeres/app/database/repository/LocationRepositoryTest.java @@ -38,13 +38,13 @@ class LocationRepositoryTest @Test void CRUD_Success() { - var profile = ProfileFakes.createProfile("test", 1); + var profile = ProfileFakes.createFreshProfile("test", 1); profile = profileRepository.save(profile); - var location1 = LocationFakes.createLocation("test1", profile); - var location2 = LocationFakes.createLocation("test2", profile); - var location3 = LocationFakes.createLocation("test3", profile); + var location1 = LocationFakes.createFreshLocation("test1", profile); + var location2 = LocationFakes.createFreshLocation("test2", profile); + var location3 = LocationFakes.createFreshLocation("test3", profile); profile.addLocation(location1); profile.addLocation(location2); diff --git a/app/src/test/java/io/xeres/app/database/repository/ProfileRepositoryTest.java b/app/src/test/java/io/xeres/app/database/repository/ProfileRepositoryTest.java index 464bb0786..005e12c51 100644 --- a/app/src/test/java/io/xeres/app/database/repository/ProfileRepositoryTest.java +++ b/app/src/test/java/io/xeres/app/database/repository/ProfileRepositoryTest.java @@ -35,9 +35,9 @@ class ProfileRepositoryTest @Test void CRUD_Success() { - var profile1 = ProfileFakes.createProfile("test1", 1); - var profile2 = ProfileFakes.createProfile("test2", 2); - var profile3 = ProfileFakes.createProfile("test3", 3); + var profile1 = ProfileFakes.createFreshProfile("test1", 1); + var profile2 = ProfileFakes.createFreshProfile("test2", 2); + var profile3 = ProfileFakes.createFreshProfile("test3", 3); var savedProfile = profileRepository.save(profile1); profileRepository.save(profile2); diff --git a/build.gradle b/build.gradle index bec3248a4..6e911e0f0 100644 --- a/build.gradle +++ b/build.gradle @@ -32,15 +32,15 @@ buildscript { } plugins { - id 'org.springframework.boot' version '3.3.5' apply false - id 'org.flywaydb.flyway' version '10.10.0' apply false // Keep the version in sync with spring-boot from time to time + id 'org.springframework.boot' version '3.4.0' apply false + id 'org.flywaydb.flyway' version '10.20.0' apply false // Keep the version in sync with spring-boot from time to time id 'org.panteleyev.jpackageplugin' version '1.6.0' apply false id 'org.sonarqube' version '6.0.0.5145' } // To upgrade Gradle, change the version here, refresh, then run the 'build setup/wrapper' task wrapper { - gradleVersion = '8.10.2' + gradleVersion = '8.11.1' } // This gives a git-like version for git builds but a proper version diff --git a/gradle.properties b/gradle.properties index a61adacb5..20b85c6bf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,5 +18,6 @@ # org.gradle.parallel=true org.gradle.configuration-cache=true +org.gradle.configuration-cache.parallel=true org.gradle.caching=true org.gradle.configureondemand=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index df97d72b8..e2847c820 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME