Skip to content

Commit 5be36ce

Browse files
committed
Specify generic type nullness in spring-r2dbc
See spring-projectsgh-34140
1 parent 2f8ff7e commit 5be36ce

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

spring-r2dbc/src/main/java/org/springframework/r2dbc/core/BeanPropertyRowMapper.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -125,7 +125,7 @@ public BeanPropertyRowMapper(Class<T> mappedClass, ConversionService conversionS
125125
* Remove the specified property from the mapped properties.
126126
* @param propertyName the property name (as used by property descriptors)
127127
*/
128-
protected void suppressProperty(String propertyName) {
128+
protected void suppressProperty(@Nullable String propertyName) {
129129
this.mappedProperties.remove(lowerCaseName(propertyName));
130130
this.mappedProperties.remove(underscoreName(propertyName));
131131
}
@@ -136,7 +136,10 @@ protected void suppressProperty(String propertyName) {
136136
* @param name the original name
137137
* @return the converted name
138138
*/
139-
protected String lowerCaseName(String name) {
139+
protected String lowerCaseName(@Nullable String name) {
140+
if (!StringUtils.hasLength(name)) {
141+
return "";
142+
}
140143
return name.toLowerCase(Locale.US);
141144
}
142145

@@ -147,7 +150,7 @@ protected String lowerCaseName(String name) {
147150
* @return the converted name
148151
* @see #lowerCaseName
149152
*/
150-
protected String underscoreName(String name) {
153+
protected String underscoreName(@Nullable String name) {
151154
if (!StringUtils.hasLength(name)) {
152155
return "";
153156
}

spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DataClassRowMapper.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
2121

2222
import io.r2dbc.spi.Readable;
2323
import io.r2dbc.spi.ReadableMetadata;
24+
import org.jspecify.annotations.Nullable;
2425

2526
import org.springframework.beans.BeanUtils;
2627
import org.springframework.beans.TypeConverter;
@@ -66,7 +67,7 @@ public class DataClassRowMapper<T> extends BeanPropertyRowMapper<T> {
6667

6768
private final Constructor<T> mappedConstructor;
6869

69-
private final String[] constructorParameterNames;
70+
private final @Nullable String[] constructorParameterNames;
7071

7172
private final TypeDescriptor[] constructorParameterTypes;
7273

@@ -98,7 +99,7 @@ public DataClassRowMapper(Class<T> mappedClass, ConversionService conversionServ
9899

99100
@Override
100101
protected T constructMappedInstance(Readable readable, List<? extends ReadableMetadata> itemMetadatas, TypeConverter tc) {
101-
Object[] args = new Object[this.constructorParameterNames.length];
102+
@Nullable Object[] args = new Object[this.constructorParameterNames.length];
102103
for (int i = 0; i < args.length; i++) {
103104
String name = this.constructorParameterNames[i];
104105
int index = findIndex(itemMetadatas, lowerCaseName(name));

0 commit comments

Comments
 (0)