Skip to content

Commit a40caff

Browse files
committed
migrate to jdk25
Signed-off-by: neo <1100909+neowu@users.noreply.github.com>
1 parent e092470 commit a40caff

File tree

11 files changed

+42
-13
lines changed

11 files changed

+42
-13
lines changed

buildSrc/src/main/check/pmd.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<rule ref="category/java/bestpractices.xml/OneDeclarationPerLine"/>
2727
<rule ref="category/java/bestpractices.xml/PreserveStackTrace"/>
2828
<rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation"/>
29+
<rule ref="category/java/bestpractices.xml/RelianceOnDefaultCharset"/>
2930
<rule ref="category/java/bestpractices.xml/SimplifiableTestAssertion"/>
3031
<rule ref="category/java/bestpractices.xml/SystemPrintln"/>
3132
<rule ref="category/java/bestpractices.xml/UnnecessaryVarargsArrayCreation"/>
@@ -52,20 +53,21 @@
5253
<property name="ignoredAnnotations" value="org.junit.jupiter.api.Test"/>
5354
</properties>
5455
</rule>
56+
<rule ref="category/java/codestyle.xml/ModifierOrder"/>
5557
<rule ref="category/java/codestyle.xml/UnnecessaryAnnotationValueElement"/>
5658
<rule ref="category/java/codestyle.xml/UnnecessaryBoxing"/>
5759
<rule ref="category/java/codestyle.xml/UnnecessaryCast"/>
5860
<rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/>
5961
<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName"/>
6062
<rule ref="category/java/codestyle.xml/UnnecessaryImport"/>
61-
<rule ref="category/java/codestyle.xml/UnnecessaryLocalBeforeReturn"/>
6263
<rule ref="category/java/codestyle.xml/UnnecessaryModifier"/>
6364
<rule ref="category/java/codestyle.xml/UnnecessaryReturn"/>
6465
<rule ref="category/java/codestyle.xml/UnnecessarySemicolon"/>
6566
<rule ref="category/java/codestyle.xml/UseDiamondOperator"/>
6667
<rule ref="category/java/codestyle.xml/UselessParentheses"/>
6768
<rule ref="category/java/codestyle.xml/UselessQualifiedThis"/>
6869
<rule ref="category/java/codestyle.xml/UseShortArrayInitializer"/>
70+
<rule ref="category/java/codestyle.xml/VariableCanBeInlined"/>
6971

7072
<rule ref="category/java/design.xml/AbstractClassWithoutAnyMethod"/>
7173
<rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException"/>
@@ -86,7 +88,7 @@
8688
<rule ref="category/java/design.xml/SwitchDensity"/>
8789
<rule ref="category/java/design.xml/UselessOverridingMethod"/>
8890

89-
<rule ref="category/java/errorprone.xml/AssignmentInOperand"/>
91+
<!-- <rule ref="category/java/errorprone.xml/AssignmentInOperand"/>-->
9092
<rule ref="category/java/errorprone.xml/AssignmentToNonFinalStatic"/>
9193
<rule ref="category/java/errorprone.xml/AvoidAssertAsIdentifier"/>
9294
<rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop"/>
@@ -95,7 +97,6 @@
9597
<rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor"/>
9698
<rule ref="category/java/errorprone.xml/AvoidEnumAsIdentifier"/>
9799
<rule ref="category/java/errorprone.xml/AvoidInstanceofChecksInCatchClause"/>
98-
<rule ref="category/java/errorprone.xml/AvoidLosingExceptionInformation"/>
99100
<rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators"/>
100101
<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues"/>
101102
<rule ref="category/java/errorprone.xml/BrokenNullCheck"/>
@@ -121,6 +122,7 @@
121122
<rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>
122123
<rule ref="category/java/errorprone.xml/NonStaticInitializer"/>
123124
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/>
125+
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashCodeOnComparable"/>
124126
<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock"/>
125127
<rule ref="category/java/errorprone.xml/SingleMethodSingleton"/>
126128
<rule ref="category/java/errorprone.xml/SingletonClassReturningNewInstance"/>
@@ -135,7 +137,7 @@
135137
<rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals"/>
136138
<rule ref="category/java/errorprone.xml/UseCorrectExceptionLogging"/>
137139
<rule ref="category/java/errorprone.xml/UseEqualsToCompareStrings"/>
138-
<rule ref="category/java/errorprone.xml/UselessOperationOnImmutable"/>
140+
<!-- <rule ref="category/java/errorprone.xml/UselessPureMethodCall" />-->
139141
<rule ref="category/java/errorprone.xml/UseLocaleWithCaseConversions"/>
140142
<rule ref="category/java/errorprone.xml/UseProperClassLoader"/>
141143

buildSrc/src/main/check/spotbugs.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@
335335
DMI_INVOKING_TOSTRING_ON_ARRAY,
336336
DMI_INVOKING_TOSTRING_ON_ANONYMOUS_ARRAY,
337337
ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT,
338-
DMI_HARDCODED_ABSOLUTE_FILENAME,
339338
DMI_BAD_MONTH,
340339
DMI_USELESS_SUBSTRING,
341340
DMI_CALLING_NEXT_FROM_HASNEXT,

buildSrc/src/main/kotlin/check.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ apply(plugin = "jacoco-report-aggregation")
1616

1717
checkstyle {
1818
dependencies {
19-
checkstyle("com.puppycrawl.tools:checkstyle:10.26.1")
19+
checkstyle("com.puppycrawl.tools:checkstyle:11.0.1")
2020
checkstyle("com.github.sevntu-checkstyle:sevntu-checks:1.44.1")
2121
}
2222

@@ -44,7 +44,7 @@ checkstyle {
4444
pmd {
4545
ruleSets = listOf()
4646
ruleSetFiles = rootProject.files("buildSrc/src/main/check/pmd.xml")
47-
toolVersion = "7.16.0"
47+
toolVersion = "7.17.0"
4848
isConsoleOutput = true
4949

5050
tasks.withType<Pmd> {
@@ -57,7 +57,7 @@ spotbugs {
5757
spotbugsPlugins("com.mebigfatguy.sb-contrib:sb-contrib:7.6.12")
5858
}
5959

60-
toolVersion = "4.9.3"
60+
toolVersion = "4.9.6"
6161
reportLevel = Confidence.LOW
6262
extraArgs = listOf("-longBugCodes")
6363
includeFilter = rootProject.file("buildSrc/src/main/check/spotbugs.xml")

core-ng/src/main/java/core/framework/internal/web/controller/WebContextImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class WebContextImpl implements WebContext {
1616
private static final ThreadLocal<Context> CONTEXT = new ThreadLocal<>();
1717

1818
@Override
19-
public Object get(String key) {
19+
public @Nullable Object get(String key) {
2020
Context context = CONTEXT.get();
2121
if (context.context == null) return null;
2222
return context.context.get(key);
@@ -38,7 +38,7 @@ public Request request() {
3838
public void responseCookie(CookieSpec spec, @Nullable String value) {
3939
Context context = CONTEXT.get();
4040
if (context.responseCookies == null) context.responseCookies = new HashMap<>();
41-
context.responseCookies.put(spec, value);
41+
context.responseCookies.put(spec, value); // cookies map allows null, to remove cookie thru response cookie header, refer to core.framework.internal.web.response.ResponseHandler.cookie
4242
}
4343

4444
public void initialize(Request request) {
@@ -60,7 +60,9 @@ public void cleanup() {
6060

6161
static class Context {
6262
final Request request;
63+
@Nullable
6364
Map<String, Object> context;
65+
@Nullable
6466
Map<CookieSpec, String> responseCookies;
6567

6668
Context(Request request) {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@NullMarked
2+
package core.framework.internal.web.controller;
3+
4+
import org.jspecify.annotations.NullMarked;

core-ng/src/main/java/core/framework/internal/web/http/IPv6Ranges.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.Arrays;
44
import java.util.Comparator;
55
import java.util.List;
6+
import java.util.Objects;
67

78
public class IPv6Ranges implements IPRanges {
89
static boolean withinRanges(LongLong[] ranges, LongLong value) {
@@ -135,5 +136,17 @@ public int compareTo(LongLong other) {
135136
int result = Long.compare(high, other.high);
136137
return result != 0 ? result : Long.compare(low, other.low);
137138
}
139+
140+
@Override
141+
public boolean equals(Object o) {
142+
if (o == null || getClass() != o.getClass()) return false;
143+
LongLong longLong = (LongLong) o;
144+
return low == longLong.low && high == longLong.high;
145+
}
146+
147+
@Override
148+
public int hashCode() {
149+
return Objects.hash(high, low);
150+
}
138151
}
139152
}

core-ng/src/main/java/core/framework/internal/web/response/ResponseHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import io.undertow.server.handlers.CookieSameSiteMode;
1515
import io.undertow.util.HeaderMap;
1616
import io.undertow.util.HttpString;
17+
import org.jspecify.annotations.Nullable;
1718
import org.slf4j.Logger;
1819
import org.slf4j.LoggerFactory;
1920

@@ -75,7 +76,7 @@ private void putCookies(ResponseImpl response, HttpServerExchange exchange) {
7576
}
7677
}
7778

78-
CookieImpl cookie(CookieSpec spec, String value) {
79+
CookieImpl cookie(CookieSpec spec, @Nullable String value) {
7980
var cookie = new CookieImpl(spec.name);
8081
if (value == null) {
8182
cookie.setMaxAge(0);

core-ng/src/main/java/core/framework/internal/web/response/ResponseImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import core.framework.web.Response;
88
import io.undertow.util.Headers;
99
import io.undertow.util.HttpString;
10+
import org.jspecify.annotations.Nullable;
1011

1112
import java.util.Map;
1213
import java.util.Optional;
@@ -17,7 +18,9 @@
1718
public final class ResponseImpl implements Response {
1819
public final Body body;
1920
final Map<HttpString, String> headers = Maps.newHashMap();
21+
@Nullable
2022
Map<CookieSpec, String> cookies;
23+
@Nullable
2124
private ContentType contentType;
2225
private HTTPStatus status = HTTPStatus.OK;
2326

@@ -42,7 +45,7 @@ public Optional<String> header(String name) {
4245
}
4346

4447
@Override
45-
public Response header(String name, String value) {
48+
public Response header(String name, @Nullable String value) {
4649
if (Headers.CONTENT_TYPE.equalToString(name)) throw new Error("must not use header() to update content type, please use response.contentType()");
4750
headers.put(new HttpString(name), value);
4851
return this;
@@ -61,7 +64,7 @@ public Response contentType(ContentType contentType) {
6164
}
6265

6366
@Override
64-
public Response cookie(CookieSpec spec, String value) {
67+
public Response cookie(CookieSpec spec, @Nullable String value) {
6568
if (cookies == null) cookies = Maps.newHashMap();
6669
cookies.put(spec, value);
6770
return this;

core-ng/src/main/java/core/framework/internal/web/site/MimeTypes.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import core.framework.http.ContentType;
44
import core.framework.util.ASCII;
55
import core.framework.util.Maps;
6+
import org.jspecify.annotations.Nullable;
67

78
import java.util.Map;
89

@@ -49,6 +50,7 @@ final class MimeTypes {
4950
MIME_TYPES.put("zip", ContentType.create("application/zip", null));
5051
}
5152

53+
@Nullable
5254
static ContentType get(String fileName) {
5355
int index = fileName.lastIndexOf('.');
5456
if (index > 0 && index + 1 < fileName.length()) {

core-ng/src/main/java/core/framework/internal/web/site/StaticDirectoryController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import core.framework.web.Request;
66
import core.framework.web.Response;
77
import core.framework.web.exception.NotFoundException;
8+
import org.jspecify.annotations.Nullable;
89
import org.slf4j.Logger;
910
import org.slf4j.LoggerFactory;
1011

@@ -19,6 +20,7 @@
1920
public final class StaticDirectoryController implements StaticContentController {
2021
private final Logger logger = LoggerFactory.getLogger(StaticDirectoryController.class);
2122
private final Path contentDirectory;
23+
@Nullable
2224
String cacheHeader;
2325

2426
public StaticDirectoryController(Path contentDirectory) {

0 commit comments

Comments
 (0)