Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit aa64149

Browse files
Merge branch 'spring-projects:main' into main
2 parents fe7da9a + 887ef75 commit aa64149

File tree

7 files changed

+23
-20
lines changed

7 files changed

+23
-20
lines changed

‎build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
id 'com.github.bjornvester.xjc' version '1.8.2' apply false
77
id 'io.github.goooler.shadow' version '8.1.8' apply false
88
id 'me.champeau.jmh' version '0.7.2' apply false
9-
id "io.spring.nullability" version "0.0.1" apply false
9+
id 'io.spring.nullability' version '0.0.4' apply false
1010
}
1111

1212
ext {

‎spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfoFactory.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import java.beans.IntrospectionException;
2121
import java.lang.reflect.Method;
2222

23-
import org.jspecify.annotations.NonNull;
24-
2523
import org.springframework.core.Ordered;
2624

2725
/**
@@ -44,7 +42,7 @@
4442
public class ExtendedBeanInfoFactory extends StandardBeanInfoFactory {
4543

4644
@Override
47-
public @NonNullBeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
45+
public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
4846
BeanInfo beanInfo = super.getBeanInfo(beanClass);
4947
return (supports(beanClass) ? new ExtendedBeanInfo(beanInfo) : beanInfo);
5048
}

‎spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotations.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.stream.Stream;
3030
import java.util.stream.StreamSupport;
3131

32-
import org.jspecify.annotations.NonNull;
3332
import org.jspecify.annotations.Nullable;
3433

3534
/**
@@ -483,7 +482,7 @@ private void addAggregateAnnotations(List<Annotation> aggregateAnnotations, @Nul
483482
}
484483

485484
@Override
486-
public @NonNullList<Aggregate> finish(@Nullable List<Aggregate> processResult) {
485+
public List<Aggregate> finish(@Nullable List<Aggregate> processResult) {
487486
return this.aggregates;
488487
}
489488
}

‎spring-core/src/main/java/org/springframework/util/ObjectUtils.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public static <E extends Enum<?>> E caseInsensitiveValueOf(E[] enumValues, Strin
255255
* @param obj the object to append
256256
* @return the new array (of the same component type; never {@code null})
257257
*/
258-
public static <A, O extends A> A[] addObjectToArray(A @Nullable [] array, @NullableO obj) {
258+
public static <A, O extends A> A[] addObjectToArray(A @Nullable [] array, O obj) {
259259
return addObjectToArray(array, obj, (array != null ? array.length : 0));
260260
}
261261

@@ -268,17 +268,18 @@ public static <A, O extends A> A[] addObjectToArray(A @Nullable [] array, @Nulla
268268
* @return the new array (of the same component type; never {@code null})
269269
* @since 6.0
270270
*/
271-
public static <A, O extends A> @NullableA[] addObjectToArray(A @Nullable [] array,@Nullable O obj, int position) {
271+
public static <A, O extends A> A[] addObjectToArray(A @Nullable [] array, O obj, int position) {
272272
Class<?> componentType = Object.class;
273273
if (array != null) {
274274
componentType = array.getClass().componentType();
275275
}
276+
// Defensive code for use cases not following the declared nullability
276277
else if (obj != null) {
277278
componentType = obj.getClass();
278279
}
279280
int newArrayLength = (array != null ? array.length + 1 : 1);
280281
@SuppressWarnings("unchecked")
281-
@NullableA[] newArray = (A[]) Array.newInstance(componentType, newArrayLength);
282+
A[] newArray = (A[]) Array.newInstance(componentType, newArrayLength);
282283
if (array != null) {
283284
System.arraycopy(array, 0, newArray, 0, position);
284285
System.arraycopy(array, position, newArray, position + 1, array.length - position);

‎spring-core/src/test/java/org/springframework/core/annotation/AnnotationsScannerTests.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.function.Predicate;
3030
import java.util.stream.Stream;
3131

32-
import org.jspecify.annotations.NonNull;
3332
import org.jspecify.annotations.Nullable;
3433
import org.junit.jupiter.api.Test;
3534

@@ -470,13 +469,13 @@ void scanWhenProcessorReturnsFromDoWithAggregateExitsEarly() {
470469
new AnnotationsProcessor<Object, String>() {
471470

472471
@Override
473-
public @NonNullString doWithAggregate(Object context, int aggregateIndex) {
472+
public String doWithAggregate(Object context, int aggregateIndex) {
474473
return "";
475474
}
476475

477476
@Override
478-
public @NonNullString doWithAnnotations(Object context, int aggregateIndex,
479-
@Nullable Object source, @Nullable Annotation@Nullable[] annotations) {
477+
public String doWithAnnotations(Object context, int aggregateIndex,
478+
@Nullable Object source, @Nullable Annotation[] annotations) {
480479
throw new IllegalStateException("Should not call");
481480
}
482481

@@ -502,13 +501,13 @@ void scanWhenProcessorHasFinishMethodUsesFinishResult() {
502501
new AnnotationsProcessor<Object, String>() {
503502

504503
@Override
505-
public @NonNullString doWithAnnotations(Object context, int aggregateIndex,
506-
@Nullable Object source, @Nullable Annotation@Nullable[] annotations) {
504+
public String doWithAnnotations(Object context, int aggregateIndex,
505+
@Nullable Object source, @Nullable Annotation[] annotations) {
507506
return "K";
508507
}
509508

510509
@Override
511-
public @NonNullString finish(@Nullable String result) {
510+
public String finish(@Nullable String result) {
512511
return "O" + result;
513512
}
514513

‎spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ else if (param.getResultSetExtractor() != null) {
14131413
* @return the RowMapper to use
14141414
* @see SingleColumnRowMapper
14151415
*/
1416-
protected <T> RowMapper<@Nullable T> getSingleColumnRowMapper(Class<T> requiredType) {
1416+
protected <Textends@Nullable Object> RowMapper<T> getSingleColumnRowMapper(Class<T> requiredType) {
14171417
return new SingleColumnRowMapper<>(requiredType);
14181418
}
14191419

‎spring-tx/src/main/java/org/springframework/dao/support/DataAccessUtils.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ public abstract class DataAccessUtils {
116116
* element has been found in the given Collection
117117
* @since 6.1
118118
*/
119-
public static <T extends @Nullable Object> Optional<@NonNull T> optionalResult(@Nullable Collection<T> results) throws IncorrectResultSizeDataAccessException {
119+
public static <T extends @Nullable Object> Optional<@NonNull T> optionalResult(@Nullable Collection<T> results)
120+
throws IncorrectResultSizeDataAccessException {
121+
120122
return Optional.ofNullable(singleResult(results));
121123
}
122124

@@ -159,7 +161,9 @@ public static <T> Optional<T> optionalResult(@Nullable Iterator<T> results) thro
159161
* @throws EmptyResultDataAccessException if no element at all
160162
* has been found in the given Collection
161163
*/
162-
public static <T extends @Nullable Object> @NonNull T requiredSingleResult(@Nullable Collection<T> results) throws IncorrectResultSizeDataAccessException {
164+
public static <T extends @Nullable Object> @NonNull T requiredSingleResult(@Nullable Collection<T> results)
165+
throws IncorrectResultSizeDataAccessException {
166+
163167
if (CollectionUtils.isEmpty(results)) {
164168
throw new EmptyResultDataAccessException(1);
165169
}
@@ -185,7 +189,9 @@ public static <T> Optional<T> optionalResult(@Nullable Iterator<T> results) thro
185189
* has been found in the given Collection
186190
* @since 5.0.2
187191
*/
188-
public static <T extends @Nullable Object> T nullableSingleResult(@Nullable Collection<T> results) throws IncorrectResultSizeDataAccessException {
192+
public static <T extends @Nullable Object> T nullableSingleResult(@Nullable Collection<T> results)
193+
throws IncorrectResultSizeDataAccessException {
194+
189195
// This is identical to the requiredSingleResult implementation but differs in the
190196
// semantics of the incoming Collection (which we currently can't formally express)
191197
if (CollectionUtils.isEmpty(results)) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /