Skip to content

Commit

Permalink
Handle null in DataSourceUtil#isDefault
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed Sep 27, 2024
1 parent 8f72c96 commit 0baf232
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private AgroalDataSourceBuildUtil() {
}

public static AnnotationInstance qualifier(String dataSourceName) {
if (dataSourceName == null || DataSourceUtil.isDefault(dataSourceName)) {
if (DataSourceUtil.isDefault(dataSourceName)) {
return AnnotationInstance.builder(Default.class).build();
} else {
return AnnotationInstance.builder(DataSource.class).value(dataSourceName).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static String dataSourceName(Bean<? extends javax.sql.DataSource> bean) {
}

public static Annotation qualifier(String dataSourceName) {
if (dataSourceName == null || DataSourceUtil.isDefault(dataSourceName)) {
if (DataSourceUtil.isDefault(dataSourceName)) {
return Default.Literal.INSTANCE;
} else {
return new DataSource.DataSourceLiteral(dataSourceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ public final class DataSourceUtil {
public static final String DEFAULT_DATASOURCE_NAME = "<default>";

public static boolean isDefault(String dataSourceName) {
return DEFAULT_DATASOURCE_NAME.equals(dataSourceName);
return dataSourceName == null || DEFAULT_DATASOURCE_NAME.equals(dataSourceName);
}

public static boolean hasDefault(Collection<String> dataSourceNames) {
return dataSourceNames.contains(DEFAULT_DATASOURCE_NAME);
}

public static String dataSourcePropertyKey(String datasourceName, String radical) {
if (datasourceName == null || DataSourceUtil.isDefault(datasourceName)) {
if (DataSourceUtil.isDefault(datasourceName)) {
return "quarkus.datasource." + radical;
} else {
return "quarkus.datasource.\"" + datasourceName + "\"." + radical;
}
}

public static List<String> dataSourcePropertyKeys(String datasourceName, String radical) {
if (datasourceName == null || DataSourceUtil.isDefault(datasourceName)) {
if (DataSourceUtil.isDefault(datasourceName)) {
return List.of("quarkus.datasource." + radical);
} else {
// Two possible syntaxes: with or without quotes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static String dataSourceName(Bean<? extends Pool> bean) {
}

public static Annotation qualifier(String dataSourceName) {
if (dataSourceName == null || DataSourceUtil.isDefault(dataSourceName)) {
if (DataSourceUtil.isDefault(dataSourceName)) {
return Default.Literal.INSTANCE;
} else {
return new ReactiveDataSource.ReactiveDataSourceLiteral(dataSourceName);
Expand Down

0 comments on commit 0baf232

Please sign in to comment.