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.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.SequencedMap;
import java.util.concurrent.ExecutionException;
import java.util.stream.Stream;
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.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.DEFLATE.token(), DeflateInputStream::new);
contentDecoderMap.put(ContentCoding.BROTLI.token(), BrotliInputStream::new);

View File

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

View File

@@ -14,7 +14,7 @@ public class InPageReferenceFeedURLProvider implements FeedURLProvider {
@Override
public List<String> get(String url, String urlContent) {
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 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;
if (hasMore) {
entries.setHasMore(true);
entries.getEntries().remove(entries.getEntries().size() - 1);
entries.getEntries().removeLast();
}
entries.setTimestamp(System.currentTimeMillis());

View File

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

View File

@@ -31,10 +31,10 @@ class FeedUtilsTest {
Assertions.assertEquals("Test Entry", syndEntry.getTitle());
Assertions.assertEquals("Author Name", syndEntry.getAuthor());
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("http://example.com/enclosure.mp3", syndEntry.getEnclosures().get(0).getUrl());
Assertions.assertEquals("audio/mpeg", syndEntry.getEnclosures().get(0).getType());
Assertions.assertEquals("http://example.com/enclosure.mp3", syndEntry.getEnclosures().getFirst().getUrl());
Assertions.assertEquals("audio/mpeg", syndEntry.getEnclosures().getFirst().getType());
Assertions.assertEquals("http://example.com/test-entry", syndEntry.getLink());
Assertions.assertEquals(Date.from(Instant.ofEpochSecond(1)), syndEntry.getPublishedDate());
}

View File

@@ -188,7 +188,7 @@ class UserServiceTest {
void apiLoginShouldReturnUserIfUserFoundFromApikeyLookupNotDisabled() {
Mockito.when(userDAO.findByApiKey("apikey")).thenReturn(normalUser);
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();
Assertions.assertEquals(2, root.getChildren().size());
Assertions.assertEquals("test-category-1", root.getChildren().get(0).getName());
Assertions.assertEquals(1, root.getChildren().get(0).getChildren().size());
Assertions.assertEquals("modified-category-2", root.getChildren().get(0).getChildren().get(0).getName());
Assertions.assertEquals("test-category-1", root.getChildren().getFirst().getName());
Assertions.assertEquals(1, root.getChildren().getFirst().getChildren().size());
Assertions.assertEquals("modified-category-2", root.getChildren().getFirst().getChildren().getFirst().getName());
request = new CategoryModificationRequest();
request.setId(Long.valueOf(category3Id));
@@ -79,7 +79,7 @@ class CategoryIT extends BaseIT {
Category root = getRootCategory();
Assertions.assertEquals(1, root.getChildren().size());
Assertions.assertTrue(root.getChildren().get(0).isExpanded());
Assertions.assertTrue(root.getChildren().getFirst().isExpanded());
CollapseRequest request = new CollapseRequest();
request.setId(Long.valueOf(categoryId));
@@ -88,7 +88,7 @@ class CategoryIT extends BaseIT {
root = getRootCategory();
Assertions.assertEquals(1, root.getChildren().size());
Assertions.assertFalse(root.getChildren().get(0).isExpanded());
Assertions.assertFalse(root.getChildren().getFirst().isExpanded());
}
@Test
@@ -178,7 +178,7 @@ class CategoryIT extends BaseIT {
Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl());
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.setId(entry.getId());
@@ -188,7 +188,7 @@ class CategoryIT extends BaseIT {
Entries starredEntries = getCategoryEntries(CategoryREST.STARRED);
Assertions.assertEquals(1, starredEntries.getEntries().size());
Assertions.assertEquals(entry.getId(), starredEntries.getEntries().get(0).getId());
Assertions.assertEquals(entry.getId(), starredEntries.getEntries().getFirst().getId());
}
@Test
@@ -196,7 +196,7 @@ class CategoryIT extends BaseIT {
Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl());
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.setEntryId(Long.valueOf(entry.getId()));
@@ -205,7 +205,7 @@ class CategoryIT extends BaseIT {
Entries taggedEntries = getTaggedEntries("my-tag");
Assertions.assertEquals(1, taggedEntries.getEntries().size());
Assertions.assertEquals(entry.getId(), taggedEntries.getEntries().get(0).getId());
Assertions.assertEquals(entry.getId(), taggedEntries.getEntries().getFirst().getId());
}
@Test

View File

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

View File

@@ -48,12 +48,12 @@ class UserIT extends BaseIT {
List<MailMessage> mails = mailbox.getMailMessagesSentTo("admin@commafeed.com");
Assertions.assertEquals(1, mails.size());
MailMessage message = mails.get(0);
MailMessage message = mails.getFirst();
Assertions.assertEquals("CommaFeed - Password recovery", message.getSubject());
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 newPasswordResponse = RestAssured.given().urlEncodingEnabled(false).get(link).then().statusCode(200).extract().asString();
Assertions.assertTrue(newPasswordResponse.contains("Your new password is:"));

View File

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