Java 25+ is now required

This commit is contained in:
Athou
2026-01-05 07:19:27 +01:00
parent f7505298d7
commit 19663b0f38
11 changed files with 33 additions and 33 deletions

View File

@@ -11,8 +11,8 @@ import java.time.InstantSource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.SequencedMap;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
@@ -294,7 +294,7 @@ public class HttpGetter {
headers.add(new BasicHeader(HttpHeaders.PRAGMA, "No-cache")); headers.add(new BasicHeader(HttpHeaders.PRAGMA, "No-cache"));
headers.add(new BasicHeader(HttpHeaders.CACHE_CONTROL, "no-cache")); headers.add(new BasicHeader(HttpHeaders.CACHE_CONTROL, "no-cache"));
Map<String, InputStreamFactory> contentDecoderMap = new LinkedHashMap<>(); SequencedMap<String, InputStreamFactory> contentDecoderMap = new LinkedHashMap<>();
contentDecoderMap.put(ContentCoding.GZIP.token(), GZIPInputStream::new); contentDecoderMap.put(ContentCoding.GZIP.token(), GZIPInputStream::new);
contentDecoderMap.put(ContentCoding.DEFLATE.token(), DeflateInputStream::new); contentDecoderMap.put(ContentCoding.DEFLATE.token(), DeflateInputStream::new);
contentDecoderMap.put(ContentCoding.BROTLI.token(), BrotliInputStream::new); contentDecoderMap.put(ContentCoding.BROTLI.token(), BrotliInputStream::new);

View File

@@ -101,7 +101,7 @@ public class DefaultFaviconFetcher extends AbstractFaviconFetcher {
return null; return null;
} }
String href = icons.get(0).attr("abs:href"); String href = icons.getFirst().attr("abs:href");
if (StringUtils.isBlank(href)) { if (StringUtils.isBlank(href)) {
log.debug("No icon found in page"); log.debug("No icon found in page");
return null; return null;

View File

@@ -14,7 +14,7 @@ public class InPageReferenceFeedURLProvider implements FeedURLProvider {
@Override @Override
public List<String> get(String url, String urlContent) { public List<String> get(String url, String urlContent) {
Document doc = Jsoup.parse(urlContent, url); Document doc = Jsoup.parse(urlContent, url);
if (!"html".equals(doc.children().get(0).tagName())) { if (!"html".equals(doc.children().getFirst().tagName())) {
return List.of(); return List.of();
} }
return Stream.concat(doc.select("link[type=application/atom+xml]").stream(), doc.select("link[type=application/rss+xml]").stream()) return Stream.concat(doc.select("link[type=application/atom+xml]").stream(), doc.select("link[type=application/rss+xml]").stream())

View File

@@ -178,7 +178,7 @@ public class CategoryREST {
boolean hasMore = entries.getEntries().size() > limit; boolean hasMore = entries.getEntries().size() > limit;
if (hasMore) { if (hasMore) {
entries.setHasMore(true); entries.setHasMore(true);
entries.getEntries().remove(entries.getEntries().size() - 1); entries.getEntries().removeLast();
} }
entries.setTimestamp(System.currentTimeMillis()); entries.setTimestamp(System.currentTimeMillis());

View File

@@ -94,8 +94,8 @@ public class FeverREST {
@Operation(hidden = true) @Operation(hidden = true)
public FeverResponse formUrlencoded(@Context UriInfo uri, @PathParam("userId") Long userId, MultivaluedMap<String, String> form) { public FeverResponse formUrlencoded(@Context UriInfo uri, @PathParam("userId") Long userId, MultivaluedMap<String, String> form) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
uri.getQueryParameters().forEach((k, v) -> params.put(k, v.get(0))); uri.getQueryParameters().forEach((k, v) -> params.put(k, v.getFirst()));
form.forEach((k, v) -> params.put(k, v.get(0))); form.forEach((k, v) -> params.put(k, v.getFirst()));
return handle(userId, params); return handle(userId, params);
} }
@@ -107,7 +107,7 @@ public class FeverREST {
@Operation(hidden = true) @Operation(hidden = true)
public FeverResponse noForm(@Context UriInfo uri, @PathParam("userId") Long userId) { public FeverResponse noForm(@Context UriInfo uri, @PathParam("userId") Long userId) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
uri.getQueryParameters().forEach((k, v) -> params.put(k, v.get(0))); uri.getQueryParameters().forEach((k, v) -> params.put(k, v.getFirst()));
return handle(userId, params); return handle(userId, params);
} }
@@ -119,7 +119,7 @@ public class FeverREST {
@Operation(hidden = true) @Operation(hidden = true)
public FeverResponse get(@Context UriInfo uri, @PathParam("userId") Long userId) { public FeverResponse get(@Context UriInfo uri, @PathParam("userId") Long userId) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
uri.getQueryParameters().forEach((k, v) -> params.put(k, v.get(0))); uri.getQueryParameters().forEach((k, v) -> params.put(k, v.getFirst()));
return handle(userId, params); return handle(userId, params);
} }
@@ -132,7 +132,7 @@ public class FeverREST {
@Operation(hidden = true) @Operation(hidden = true)
public FeverResponse formData(@Context UriInfo uri, @PathParam("userId") Long userId, MultipartFormDataInput form) { public FeverResponse formData(@Context UriInfo uri, @PathParam("userId") Long userId, MultipartFormDataInput form) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
uri.getQueryParameters().forEach((k, v) -> params.put(k, v.get(0))); uri.getQueryParameters().forEach((k, v) -> params.put(k, v.getFirst()));
form.getValues().forEach((k, v) -> params.put(k, v.stream().map(FormValue::getValue).findFirst().orElse(null))); form.getValues().forEach((k, v) -> params.put(k, v.stream().map(FormValue::getValue).findFirst().orElse(null)));
return handle(userId, params); return handle(userId, params);
} }

View File

@@ -31,10 +31,10 @@ class FeedUtilsTest {
Assertions.assertEquals("Test Entry", syndEntry.getTitle()); Assertions.assertEquals("Test Entry", syndEntry.getTitle());
Assertions.assertEquals("Author Name", syndEntry.getAuthor()); Assertions.assertEquals("Author Name", syndEntry.getAuthor());
Assertions.assertEquals(1, syndEntry.getContents().size()); Assertions.assertEquals(1, syndEntry.getContents().size());
Assertions.assertEquals("This is a test entry content.", syndEntry.getContents().get(0).getValue()); Assertions.assertEquals("This is a test entry content.", syndEntry.getContents().getFirst().getValue());
Assertions.assertEquals(1, syndEntry.getEnclosures().size()); Assertions.assertEquals(1, syndEntry.getEnclosures().size());
Assertions.assertEquals("http://example.com/enclosure.mp3", syndEntry.getEnclosures().get(0).getUrl()); Assertions.assertEquals("http://example.com/enclosure.mp3", syndEntry.getEnclosures().getFirst().getUrl());
Assertions.assertEquals("audio/mpeg", syndEntry.getEnclosures().get(0).getType()); Assertions.assertEquals("audio/mpeg", syndEntry.getEnclosures().getFirst().getType());
Assertions.assertEquals("http://example.com/test-entry", syndEntry.getLink()); Assertions.assertEquals("http://example.com/test-entry", syndEntry.getLink());
Assertions.assertEquals(Date.from(Instant.ofEpochSecond(1)), syndEntry.getPublishedDate()); Assertions.assertEquals(Date.from(Instant.ofEpochSecond(1)), syndEntry.getPublishedDate());
} }

View File

@@ -188,7 +188,7 @@ class UserServiceTest {
void apiLoginShouldReturnUserIfUserFoundFromApikeyLookupNotDisabled() { void apiLoginShouldReturnUserIfUserFoundFromApikeyLookupNotDisabled() {
Mockito.when(userDAO.findByApiKey("apikey")).thenReturn(normalUser); Mockito.when(userDAO.findByApiKey("apikey")).thenReturn(normalUser);
Optional<User> returnedUser = userService.login("apikey"); Optional<User> returnedUser = userService.login("apikey");
Assertions.assertEquals(normalUser, returnedUser.get()); Assertions.assertEquals(Optional.of(normalUser), returnedUser);
} }
} }

View File

@@ -58,9 +58,9 @@ class CategoryIT extends BaseIT {
Category root = getRootCategory(); Category root = getRootCategory();
Assertions.assertEquals(2, root.getChildren().size()); Assertions.assertEquals(2, root.getChildren().size());
Assertions.assertEquals("test-category-1", root.getChildren().get(0).getName()); Assertions.assertEquals("test-category-1", root.getChildren().getFirst().getName());
Assertions.assertEquals(1, root.getChildren().get(0).getChildren().size()); Assertions.assertEquals(1, root.getChildren().getFirst().getChildren().size());
Assertions.assertEquals("modified-category-2", root.getChildren().get(0).getChildren().get(0).getName()); Assertions.assertEquals("modified-category-2", root.getChildren().getFirst().getChildren().getFirst().getName());
request = new CategoryModificationRequest(); request = new CategoryModificationRequest();
request.setId(Long.valueOf(category3Id)); request.setId(Long.valueOf(category3Id));
@@ -79,7 +79,7 @@ class CategoryIT extends BaseIT {
Category root = getRootCategory(); Category root = getRootCategory();
Assertions.assertEquals(1, root.getChildren().size()); Assertions.assertEquals(1, root.getChildren().size());
Assertions.assertTrue(root.getChildren().get(0).isExpanded()); Assertions.assertTrue(root.getChildren().getFirst().isExpanded());
CollapseRequest request = new CollapseRequest(); CollapseRequest request = new CollapseRequest();
request.setId(Long.valueOf(categoryId)); request.setId(Long.valueOf(categoryId));
@@ -88,7 +88,7 @@ class CategoryIT extends BaseIT {
root = getRootCategory(); root = getRootCategory();
Assertions.assertEquals(1, root.getChildren().size()); Assertions.assertEquals(1, root.getChildren().size());
Assertions.assertFalse(root.getChildren().get(0).isExpanded()); Assertions.assertFalse(root.getChildren().getFirst().isExpanded());
} }
@Test @Test
@@ -178,7 +178,7 @@ class CategoryIT extends BaseIT {
Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl()); Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl());
Assertions.assertEquals(0, getCategoryEntries(CategoryREST.STARRED).getEntries().size()); Assertions.assertEquals(0, getCategoryEntries(CategoryREST.STARRED).getEntries().size());
Entry entry = getFeedEntries(subscriptionId).getEntries().get(0); Entry entry = getFeedEntries(subscriptionId).getEntries().getFirst();
StarRequest starRequest = new StarRequest(); StarRequest starRequest = new StarRequest();
starRequest.setId(entry.getId()); starRequest.setId(entry.getId());
@@ -188,7 +188,7 @@ class CategoryIT extends BaseIT {
Entries starredEntries = getCategoryEntries(CategoryREST.STARRED); Entries starredEntries = getCategoryEntries(CategoryREST.STARRED);
Assertions.assertEquals(1, starredEntries.getEntries().size()); Assertions.assertEquals(1, starredEntries.getEntries().size());
Assertions.assertEquals(entry.getId(), starredEntries.getEntries().get(0).getId()); Assertions.assertEquals(entry.getId(), starredEntries.getEntries().getFirst().getId());
} }
@Test @Test
@@ -196,7 +196,7 @@ class CategoryIT extends BaseIT {
Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl()); Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl());
Assertions.assertEquals(0, getTaggedEntries("my-tag").getEntries().size()); Assertions.assertEquals(0, getTaggedEntries("my-tag").getEntries().size());
Entry entry = getFeedEntries(subscriptionId).getEntries().get(0); Entry entry = getFeedEntries(subscriptionId).getEntries().getFirst();
TagRequest tagRequest = new TagRequest(); TagRequest tagRequest = new TagRequest();
tagRequest.setEntryId(Long.valueOf(entry.getId())); tagRequest.setEntryId(Long.valueOf(entry.getId()));
@@ -205,7 +205,7 @@ class CategoryIT extends BaseIT {
Entries taggedEntries = getTaggedEntries("my-tag"); Entries taggedEntries = getTaggedEntries("my-tag");
Assertions.assertEquals(1, taggedEntries.getEntries().size()); Assertions.assertEquals(1, taggedEntries.getEntries().size());
Assertions.assertEquals(entry.getId(), taggedEntries.getEntries().get(0).getId()); Assertions.assertEquals(entry.getId(), taggedEntries.getEntries().getFirst().getId());
} }
@Test @Test

View File

@@ -80,7 +80,7 @@ class FeverIT extends BaseIT {
FeverResponse feverResponse = client.execute("items"); FeverResponse feverResponse = client.execute("items");
Assertions.assertEquals(2, feverResponse.getItems().size()); Assertions.assertEquals(2, feverResponse.getItems().size());
FeverItem item = feverResponse.getItems().get(0); FeverItem item = feverResponse.getItems().getFirst();
Assertions.assertEquals(subscriptionId, item.getFeedId()); Assertions.assertEquals(subscriptionId, item.getFeedId());
Assertions.assertEquals("Item 2", item.getTitle()); Assertions.assertEquals("Item 2", item.getTitle());
Assertions.assertEquals("Item 2 description", item.getHtml()); Assertions.assertEquals("Item 2 description", item.getHtml());
@@ -92,7 +92,7 @@ class FeverIT extends BaseIT {
@Test @Test
void entriesByIds() { void entriesByIds() {
Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl()); Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl());
Entry entry = getFeedEntries(subscriptionId).getEntries().get(0); Entry entry = getFeedEntries(subscriptionId).getEntries().getFirst();
FeverResponse feverResponse = client.execute("items", new Param("with_ids", entry.getId())); FeverResponse feverResponse = client.execute("items", new Param("with_ids", entry.getId()));
Assertions.assertEquals(1, feverResponse.getItems().size()); Assertions.assertEquals(1, feverResponse.getItems().size());
@@ -101,7 +101,7 @@ class FeverIT extends BaseIT {
@Test @Test
void savedEntries() { void savedEntries() {
Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl()); Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl());
Entry entry = getFeedEntries(subscriptionId).getEntries().get(0); Entry entry = getFeedEntries(subscriptionId).getEntries().getFirst();
StarRequest starRequest = new StarRequest(); StarRequest starRequest = new StarRequest();
starRequest.setId(entry.getId()); starRequest.setId(entry.getId());
@@ -116,7 +116,7 @@ class FeverIT extends BaseIT {
@Test @Test
void markEntry() { void markEntry() {
Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl()); Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl());
Entry entry = getFeedEntries(subscriptionId).getEntries().get(0); Entry entry = getFeedEntries(subscriptionId).getEntries().getFirst();
client.execute("_", new Param("mark", "item"), new Param("id", entry.getId()), new Param("as", "read")); client.execute("_", new Param("mark", "item"), new Param("id", entry.getId()), new Param("as", "read"));
Assertions.assertEquals(1, getFeedEntries(subscriptionId).getEntries().stream().filter(Entry::isRead).count()); Assertions.assertEquals(1, getFeedEntries(subscriptionId).getEntries().stream().filter(Entry::isRead).count());
@@ -147,7 +147,7 @@ class FeverIT extends BaseIT {
@Test @Test
void tagEntry() { void tagEntry() {
Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl()); Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl());
Entry entry = getFeedEntries(subscriptionId).getEntries().get(0); Entry entry = getFeedEntries(subscriptionId).getEntries().getFirst();
client.execute("_", new Param("mark", "item"), new Param("id", entry.getId()), new Param("as", "saved")); client.execute("_", new Param("mark", "item"), new Param("id", entry.getId()), new Param("as", "saved"));
Assertions.assertEquals(1, getFeedEntries(subscriptionId).getEntries().stream().filter(Entry::isStarred).count()); Assertions.assertEquals(1, getFeedEntries(subscriptionId).getEntries().stream().filter(Entry::isStarred).count());
@@ -161,7 +161,7 @@ class FeverIT extends BaseIT {
createCategory("category-1"); createCategory("category-1");
FeverResponse feverResponse = client.execute("groups"); FeverResponse feverResponse = client.execute("groups");
Assertions.assertEquals(1, feverResponse.getGroups().size()); Assertions.assertEquals(1, feverResponse.getGroups().size());
Assertions.assertEquals("category-1", feverResponse.getGroups().get(0).getTitle()); Assertions.assertEquals("category-1", feverResponse.getGroups().getFirst().getTitle());
} }
@Test @Test

View File

@@ -48,12 +48,12 @@ class UserIT extends BaseIT {
List<MailMessage> mails = mailbox.getMailMessagesSentTo("admin@commafeed.com"); List<MailMessage> mails = mailbox.getMailMessagesSentTo("admin@commafeed.com");
Assertions.assertEquals(1, mails.size()); Assertions.assertEquals(1, mails.size());
MailMessage message = mails.get(0); MailMessage message = mails.getFirst();
Assertions.assertEquals("CommaFeed - Password recovery", message.getSubject()); Assertions.assertEquals("CommaFeed - Password recovery", message.getSubject());
Assertions.assertTrue(message.getHtml().startsWith("You asked for password recovery for account 'admin'")); Assertions.assertTrue(message.getHtml().startsWith("You asked for password recovery for account 'admin'"));
Assertions.assertEquals("admin@commafeed.com", message.getTo().get(0)); Assertions.assertEquals("admin@commafeed.com", message.getTo().getFirst());
Element a = Jsoup.parse(message.getHtml()).select("a").get(0); Element a = Jsoup.parse(message.getHtml()).select("a").getFirst();
String link = a.attr("href"); String link = a.attr("href");
String newPasswordResponse = RestAssured.given().urlEncodingEnabled(false).get(link).then().statusCode(200).extract().asString(); String newPasswordResponse = RestAssured.given().urlEncodingEnabled(false).get(link).then().statusCode(200).extract().asString();
Assertions.assertTrue(newPasswordResponse.contains("Your new password is:")); Assertions.assertTrue(newPasswordResponse.contains("Your new password is:"));

View File

@@ -11,7 +11,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release> <maven.compiler.release>25</maven.compiler.release>
</properties> </properties>
<build> <build>