Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.sql.SQLException;
import java.util.Properties;

import org.jspecify.annotations.Nullable;

import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;

Expand Down Expand Up @@ -90,7 +92,7 @@ public DriverManagerDataSource(String url) {
* @param password the JDBC password to use for accessing the DriverManager
* @see java.sql.DriverManager#getConnection(String, String, String)
*/
public DriverManagerDataSource(String url, String username, String password) {
public DriverManagerDataSource(@Nullable String url, @Nullable String username, @Nullable String password) {
setUrl(url);
setUsername(username);
setPassword(password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public SingleConnectionDataSource() {
* close-suppressing proxy or the physical Connection
* @see java.sql.DriverManager#getConnection(String, String, String)
*/
public SingleConnectionDataSource(String url, String username, String password, boolean suppressClose) {
public SingleConnectionDataSource(@Nullable String url, @Nullable String username, @Nullable String password, boolean suppressClose) {
super(url, username, password);
this.suppressClose = suppressClose;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2002-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.jdbc.datasource

import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Test

class SingleConnectionDataSourceTest {

// The underlying AbstractDriverBasedDataSource.setUrl, setUsername and setPassword
// methods allow null, so ensure the SingleConnectionDataSource constructor does too.
@Test
fun `construct SingleConnectionDataSource with null properties`() {
val url: String? = null
val username: String? = null
val password: String? = null
val singleConnectionDataSource = SingleConnectionDataSource(url, username, password, false /* arbitrary */)
assertNotNull(singleConnectionDataSource)
}
}