Skip to content

Commit a2f9c7f

Browse files
committed
[#2845] Bump Spring boot to 4.x
Notes: 1. (!) Eclipselink shall be migrated to 5.0 (in 4.0.8 there are incompatible classes, e.g EJBQueryImpl doesn't implement some newer methods). In the moment is with beta (5.0.0-B12) - JUST for testing! 2. (!) Ethlo plugin doesn't work with Eclipselink 5.0, it builds with Eclipselink 4.0.8 (could be a problem) 3. Dependencies - new starters, test starters changes, some dependencies refactoring 4. Auto-configs split - package changes, some properties classes changes 5. Spring nullable org.springframework.lang.Nullable/NonNull are depecated and replaced with jspcify -> org.jspecify.annotations.Nullable/NonNull (NullMarked) 6. Lombok config - adding lombok.addNullAnnotations=jspecify - to do not mess annotations 7. Distributed lock table changes - SP_LOCK table db migration 8. Spring Retry replaced with Spring Core Retry - does repace retry in hawkbit 9. Specifications -> added Update/Delete(/Predicate) Specifications and JpaSpecificationExecutor changed 10. HawkbitBaseRepositoryFactoryBean modified to register properly 11. Jackson - 2 -> 3, package migrations, finals are not deserialized by default(enable finals deserialization, consider make non-final), too ‘smart’ tries to set complex objects instead of using non args constructor (-> @JsonIgnore), some other default configs made Signed-off-by: Avgustin Marinov <[email protected]>
1 parent 5a698ff commit a2f9c7f

File tree

173 files changed

+1238
-1057
lines changed

Some content is hidden

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

173 files changed

+1238
-1057
lines changed

hawkbit-artifact/hawkbit-artifact-api/pom.xml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,5 @@
2727
<artifactId>hawkbit-core</artifactId>
2828
<version>${project.version}</version>
2929
</dependency>
30-
31-
<dependency>
32-
<groupId>org.springframework.boot</groupId>
33-
<artifactId>spring-boot</artifactId>
34-
</dependency>
35-
<dependency>
36-
<groupId>org.springframework.security</groupId>
37-
<artifactId>spring-security-config</artifactId>
38-
</dependency>
39-
40-
<dependency>
41-
<groupId>jakarta.validation</groupId>
42-
<artifactId>jakarta.validation-api</artifactId>
43-
</dependency>
44-
45-
<!-- TEST -->
46-
<dependency>
47-
<groupId>io.github.classgraph</groupId>
48-
<artifactId>classgraph</artifactId>
49-
<scope>test</scope>
50-
</dependency>
5130
</dependencies>
5231
</project>

hawkbit-artifact/hawkbit-artifact-fs/pom.xml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,5 @@
2727
<artifactId>hawkbit-artifact-api</artifactId>
2828
<version>${project.version}</version>
2929
</dependency>
30-
31-
<dependency>
32-
<groupId>org.springframework</groupId>
33-
<artifactId>spring-core</artifactId>
34-
</dependency>
35-
<dependency>
36-
<groupId>org.springframework.boot</groupId>
37-
<artifactId>spring-boot-autoconfigure</artifactId>
38-
</dependency>
39-
<dependency>
40-
<groupId>commons-io</groupId>
41-
<artifactId>commons-io</artifactId>
42-
</dependency>
4330
</dependencies>
4431
</project>

hawkbit-artifact/hawkbit-artifact-fs/src/main/java/org/eclipse/hawkbit/artifact/fs/FileArtifactStorage.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.nio.file.Path;
2020
import java.nio.file.Paths;
2121

22-
import org.apache.commons.io.FileUtils;
2322
import org.eclipse.hawkbit.artifact.AbstractArtifactStorage;
2423
import org.eclipse.hawkbit.artifact.ArtifactStorage;
2524
import org.eclipse.hawkbit.artifact.exception.ArtifactBinaryNotFoundException;
@@ -47,7 +46,7 @@ public FileArtifactStorage(final FileArtifactProperties artifactResourceProperti
4746

4847
@Override
4948
public void deleteBySha1(final String tenant, final String sha1) {
50-
FileUtils.deleteQuietly(getFile(tenant, sha1));
49+
deleteSilent(getFile(tenant, sha1));
5150
}
5251

5352
@Override
@@ -65,7 +64,7 @@ public InputStream getBySha1(final String tenant, final String sha1) {
6564

6665
@Override
6766
public void deleteByTenant(final String tenant) {
68-
FileUtils.deleteQuietly(Paths.get(artifactResourceProperties.getPath(), sanitizeTenant(tenant)).toFile());
67+
deleteSilent(Paths.get(artifactResourceProperties.getPath(), sanitizeTenant(tenant)).toFile());
6968
}
7069

7170
@Override
@@ -78,7 +77,7 @@ protected void store(final String tenant, final ArtifactHashes base16Hashes, fin
7877
throws IOException {
7978
final File fileSHA1Naming = getFile(tenant, base16Hashes.sha1());
8079
if (fileSHA1Naming.exists()) {
81-
FileUtils.deleteQuietly(tempFile);
80+
deleteSilent(tempFile);
8281
} else {
8382
Files.move(tempFile.toPath(), fileSHA1Naming.toPath());
8483
}
@@ -107,4 +106,24 @@ private Path getSha1DirectoryPath(final String tenant, final String sha1) {
107106
final String folder2 = sha1.substring(length - 2, length);
108107
return Paths.get(artifactResourceProperties.getPath(), sanitizeTenant(tenant), folder1, folder2);
109108
}
109+
110+
@SuppressWarnings({ "java:S899", "java:S4042" }) // just ignore the result - silent
111+
private static void deleteSilent(final File file) {
112+
if (file.exists()) {
113+
if (file.isDirectory()) {
114+
// delete children
115+
final File[] children = file.listFiles();
116+
if (children != null) {
117+
for (final File child : children) {
118+
deleteSilent(child);
119+
}
120+
}
121+
}
122+
try {
123+
file.delete(); // silent
124+
} catch (final Exception ignored) {
125+
// ignore
126+
}
127+
}
128+
}
110129
}

hawkbit-artifact/hawkbit-artifact-fs/src/test/java/org/eclipse/hawkbit/artifact/fs/FileArtifactStorageTest.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
import java.io.ByteArrayInputStream;
1616
import java.io.File;
1717
import java.io.IOException;
18+
import java.io.InputStream;
19+
import java.nio.file.Files;
1820
import java.util.Random;
1921

2022
import lombok.extern.slf4j.Slf4j;
21-
import org.apache.commons.io.FileUtils;
22-
import org.apache.commons.io.IOUtils;
2323
import org.assertj.core.api.Assertions;
2424
import org.eclipse.hawkbit.artifact.AbstractArtifactStorage;
2525
import org.eclipse.hawkbit.artifact.exception.ArtifactBinaryNotFoundException;
@@ -54,7 +54,7 @@ static void setup() {
5454
static void afterClass() {
5555
if (new File(artifactResourceProperties.getPath()).exists()) {
5656
try {
57-
FileUtils.deleteDirectory(new File(artifactResourceProperties.getPath()));
57+
delete(new File(artifactResourceProperties.getPath()));
5858
} catch (final IOException | IllegalArgumentException e) {
5959
log.warn("Cannot delete file-directory", e);
6060
}
@@ -69,9 +69,10 @@ void storeSuccessfully() throws IOException {
6969
final byte[] fileContent = randomBytes();
7070
final StoredArtifactInfo artifact = storeRandomArtifact(fileContent);
7171

72-
final byte[] readContent = new byte[fileContent.length];
73-
IOUtils.read(artifactFilesystemRepository.getBySha1(TENANT, artifact.getHashes().sha1()), readContent);
74-
assertThat(readContent).isEqualTo(fileContent);
72+
try (final InputStream is = artifactFilesystemRepository.getBySha1(TENANT, artifact.getHashes().sha1())) {
73+
final byte[] readContent = is.readAllBytes();
74+
assertThat(readContent).isEqualTo(fileContent);
75+
}
7576
}
7677

7778
/**
@@ -141,4 +142,20 @@ private StoredArtifactInfo storeRandomArtifact(final byte[] fileContent) throws
141142
return artifactFilesystemRepository.store(TENANT, inputStream, "filename.tmp", "application/txt", null);
142143
}
143144
}
145+
146+
private static void delete(final File file) throws IOException {
147+
if (file.exists()) {
148+
if (file.isDirectory()) {
149+
// delete children
150+
final File[] children = file.listFiles();
151+
if (children != null) {
152+
for (final File child : children) {
153+
delete(child);
154+
}
155+
}
156+
}
157+
158+
Files.delete(file.toPath());
159+
}
160+
}
144161
}

hawkbit-autoconfigure/pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@
4444
<artifactId>protostuff-core</artifactId>
4545
<optional>true</optional>
4646
</dependency>
47-
48-
<dependency>
49-
<groupId>jakarta.servlet</groupId>
50-
<artifactId>jakarta.servlet-api</artifactId>
51-
<scope>provided</scope>
52-
</dependency>
53-
5447
<dependency>
5548
<groupId>io.protostuff</groupId>
5649
<artifactId>protostuff-runtime</artifactId>

hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
import org.eclipse.hawkbit.tenancy.TenantAwareUserProperties;
1919
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2020
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
21-
import org.springframework.boot.autoconfigure.security.SecurityProperties;
2221
import org.springframework.boot.context.properties.EnableConfigurationProperties;
22+
import org.springframework.boot.security.autoconfigure.SecurityProperties;
2323
import org.springframework.context.annotation.Bean;
2424
import org.springframework.context.annotation.Configuration;
2525
import org.springframework.context.annotation.Import;

hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/StaticUserManagementAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
import org.eclipse.hawkbit.auth.StaticAuthenticationProvider;
1313
import org.eclipse.hawkbit.tenancy.TenantAwareUserProperties;
14-
import org.springframework.boot.autoconfigure.security.SecurityProperties;
1514
import org.springframework.boot.context.properties.EnableConfigurationProperties;
15+
import org.springframework.boot.security.autoconfigure.SecurityProperties;
1616
import org.springframework.context.annotation.Configuration;
1717
import org.springframework.core.Ordered;
1818
import org.springframework.core.annotation.Order;

hawkbit-core/pom.xml

Lines changed: 16 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,72 +24,43 @@
2424
<dependencies>
2525
<dependency>
2626
<groupId>org.springframework.boot</groupId>
27-
<artifactId>spring-boot</artifactId>
28-
</dependency>
29-
<dependency>
30-
<groupId>org.springframework.security</groupId>
31-
<artifactId>spring-security-config</artifactId>
27+
<artifactId>spring-boot-starter-security</artifactId>
3228
</dependency>
3329
<dependency>
3430
<groupId>org.springframework.boot</groupId>
35-
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
36-
</dependency>
37-
<dependency>
38-
<groupId>org.springframework</groupId>
39-
<artifactId>spring-web</artifactId>
31+
<artifactId>spring-boot-starter-security-oauth2-client</artifactId>
4032
</dependency>
4133
<dependency>
42-
<groupId>org.springframework.data</groupId>
43-
<artifactId>spring-data-commons</artifactId>
44-
</dependency>
45-
<dependency>
46-
<groupId>org.springframework</groupId>
47-
<artifactId>spring-context-support</artifactId>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-starter-cache</artifactId>
4836
</dependency>
4937
<dependency>
50-
<groupId>org.springframework.security</groupId>
51-
<artifactId>spring-security-oauth2-core</artifactId>
38+
<groupId>org.springframework.boot</groupId>
39+
<artifactId>spring-boot-starter-webmvc</artifactId>
40+
<optional>true</optional>
5241
</dependency>
5342
<dependency>
54-
<groupId>org.springframework.security</groupId>
55-
<artifactId>spring-security-aspects</artifactId>
43+
<groupId>org.springframework.boot</groupId>
44+
<artifactId>spring-boot-starter-data-jpa</artifactId>
45+
<optional>true</optional>
5646
</dependency>
5747
<dependency>
58-
<groupId>org.springframework.security</groupId>
59-
<artifactId>spring-security-web</artifactId>
60-
<!-- needed for web MDC filter -->
48+
<groupId>org.springframework.boot</groupId>
49+
<artifactId>spring-boot-starter-actuator</artifactId>
6150
<optional>true</optional>
6251
</dependency>
6352

6453
<dependency>
65-
<groupId>jakarta.validation</groupId>
66-
<artifactId>jakarta.validation-api</artifactId>
67-
</dependency>
68-
<dependency>
69-
<groupId>jakarta.servlet</groupId>
70-
<artifactId>jakarta.servlet-api</artifactId>
54+
<groupId>tools.jackson.core</groupId>
55+
<artifactId>jackson-databind</artifactId>
7156
</dependency>
7257
<dependency>
73-
<groupId>io.micrometer</groupId>
74-
<artifactId>micrometer-core</artifactId>
58+
<groupId>jakarta.validation</groupId>
59+
<artifactId>jakarta.validation-api</artifactId>
7560
</dependency>
7661
<dependency>
7762
<groupId>com.github.ben-manes.caffeine</groupId>
7863
<artifactId>caffeine</artifactId>
7964
</dependency>
80-
81-
<dependency>
82-
<groupId>com.fasterxml.jackson.core</groupId>
83-
<artifactId>jackson-databind</artifactId>
84-
<!-- needed for JSON context serialization -->
85-
<optional>true</optional>
86-
</dependency>
87-
88-
<!-- TEST -->
89-
<dependency>
90-
<groupId>io.github.classgraph</groupId>
91-
<artifactId>classgraph</artifactId>
92-
<scope>test</scope>
93-
</dependency>
9465
</dependencies>
9566
</project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*/
10+
package org.eclipse.hawkbit;
11+
12+
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
13+
import org.springframework.context.annotation.Configuration;
14+
import org.springframework.context.annotation.Import;
15+
import org.springframework.context.annotation.PropertySource;
16+
17+
/**
18+
* The {@link HawkbitAutoConfiguration} brings some default configurations needed for hawkbit. It does:
19+
* <ul>
20+
* <li>Import {@link JacksonAutoConfiguration} and applies hawkbit-jackson-defaults.properties in order to configure the {@link tools.jackson.databind.json.JsonMapper}.</li>
21+
* </ul>
22+
*/
23+
@Configuration
24+
@Import(JacksonAutoConfiguration.class)
25+
@PropertySource("classpath:/hawkbit-jackson-defaults.properties")
26+
public class HawkbitAutoConfiguration {}

hawkbit-core/src/main/java/org/eclipse/hawkbit/auth/StaticAuthenticationProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.eclipse.hawkbit.tenancy.TenantAwareAuthenticationDetails;
2121
import org.eclipse.hawkbit.tenancy.TenantAwareUser;
2222
import org.eclipse.hawkbit.tenancy.TenantAwareUserProperties;
23-
import org.springframework.boot.autoconfigure.security.SecurityProperties;
23+
import org.springframework.boot.security.autoconfigure.SecurityProperties;
2424
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
2525
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
2626
import org.springframework.security.core.Authentication;

0 commit comments

Comments
 (0)