Skip to content

Commit

Permalink
The connection pool name is no longer required
Browse files Browse the repository at this point in the history
  • Loading branch information
Valxrie committed May 9, 2021
1 parent 23a2b22 commit a162e01
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.glyart</groupId>
<artifactId>Mystral</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.1-SNAPSHOT</version>

<name>Mystral</name>

Expand Down
16 changes: 7 additions & 9 deletions src/main/java/com/glyart/mystral/database/Credentials.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ public class Credentials {
@Nullable
private String schema;

@NotNull
private final String poolName;
@Nullable
private String poolName;

protected Credentials(@NotNull String hostname, @NotNull String username, @NotNull String poolName) {
protected Credentials(@NotNull String hostname, @NotNull String username) {
this.hostname = hostname;
this.username = username;
this.poolName = poolName;
}
/**
* Creates a new builder for Credentials.
Expand Down Expand Up @@ -91,7 +90,7 @@ public String getSchema() {
* Gets the name of the connection pool.
* @return the name of the pool
*/
@NotNull
@Nullable
public String getPoolName() {
return poolName;
}
Expand Down Expand Up @@ -172,9 +171,7 @@ public CredentialsBuilder schema(@Nullable String schema) {
* @param poolName the name of the pool
* @return this builder instance
*/
public CredentialsBuilder pool(@NotNull String poolName) {
Preconditions.checkArgument(!Preconditions.checkNotNull(poolName, "Pool name cannot be null.").isEmpty(),
"Pool name cannot be empty.");
public CredentialsBuilder pool(@Nullable String poolName) {
this.poolName = poolName;
return this;
}
Expand All @@ -187,11 +184,12 @@ public CredentialsBuilder pool(@NotNull String poolName) {
*/
@NotNull
public Credentials build() {
Credentials credentials = new Credentials(hostname, username, poolName);
Credentials credentials = new Credentials(hostname, username);

credentials.port = port;
credentials.password = password;
credentials.schema = schema;
credentials.poolName = poolName;

return credentials;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ public HikariDataSource newDataSource() throws DataSourceInitException {
hikariConfig.setJdbcUrl(String.format(TEMPLATE_URL, "mysql", credentials.getHostname(), credentials.getPort(), credentials.getSchema()));
hikariConfig.setUsername(credentials.getUsername());
hikariConfig.setPassword(credentials.getPassword());
if (credentials.getPoolName() != null)
hikariConfig.setPoolName(credentials.getPoolName());
}
PROPS.forEach(hikariConfig::addDataSourceProperty);
hikariConfig.setMaximumPoolSize(MAXIMUM_POOL_SIZE);
Expand Down

0 comments on commit a162e01

Please sign in to comment.