Skip to content

Commit 04a8475

Browse files
authored
Merge pull request #3623 from ebean-orm/feature/readOnly-DataSource-mark-nullable
Explicitly mark Database.readOnlyDataSource() as @nullable
2 parents 3c4b04a + c56345f commit 04a8475

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

ebean-api/src/main/java/io/ebean/Database.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ static DatabaseBuilder builder() {
137137
/**
138138
* Return the associated read only DataSource for this Database instance (can be null).
139139
*/
140+
@Nullable
140141
DataSource readOnlyDataSource();
141142

142143
/**

ebean-core/src/main/java/io/ebeaninternal/server/core/DefaultServer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ public DataSource dataSource() {
278278
}
279279

280280
@Override
281+
@Nullable
281282
public DataSource readOnlyDataSource() {
282283
return transactionManager.readOnlyDataSource();
283284
}

ebean-core/src/main/java/io/ebeaninternal/server/transaction/DataSourceSupplier.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.ebeaninternal.server.transaction;
22

3+
import org.jspecify.annotations.Nullable;
4+
35
import javax.sql.DataSource;
46
import java.sql.Connection;
57
import java.sql.SQLException;
@@ -25,6 +27,7 @@ public interface DataSourceSupplier {
2527
* This can return null meaning that no read only DataSource (with autoCommit)
2628
* is available for use so normal transactions with explicit commit should be used.
2729
*/
30+
@Nullable
2831
DataSource readOnlyDataSource();
2932

3033
/**

ebean-core/src/main/java/io/ebeaninternal/server/transaction/TransactionManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import io.ebean.cache.ServerCacheNotify;
1111
import io.ebean.config.CurrentTenantProvider;
1212
import io.ebean.config.dbplatform.DatabasePlatform;
13+
import io.ebean.datasource.DataSourcePool;
1314
import io.ebean.event.changelog.ChangeLogListener;
1415
import io.ebean.event.changelog.ChangeLogPrepare;
1516
import io.ebean.event.changelog.ChangeSet;
@@ -30,6 +31,8 @@
3031
import io.ebeanservice.docstore.api.DocStoreUpdates;
3132

3233
import jakarta.persistence.PersistenceException;
34+
import org.jspecify.annotations.Nullable;
35+
3336
import javax.sql.DataSource;
3437
import java.sql.Connection;
3538
import java.sql.SQLException;
@@ -257,6 +260,7 @@ public final DataSource dataSource() {
257260
}
258261

259262
@Override
263+
@Nullable
260264
public final DataSource readOnlyDataSource() {
261265
return dataSourceSupplier.readOnlyDataSource();
262266
}

0 commit comments

Comments
 (0)