Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
philwebb committed Jul 22, 2024
1 parent 000600c commit 8848066
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,17 @@ public Ssl getSsl() {
public static class Ssl {

/**
* Whether to enable SSL support. If enabled, {@code mail.<protocol>.ssl.enable}
* property is set to {@code true}.
* Whether to enable SSL support. If enabled, 'mail.(protocol).ssl.enable'
* property is set to 'true'.
*/
private boolean enabled = false;

/**
* SSL bundle name. If not null, {@code mail.<protocol>.ssl.socketFactory}
* property is set to a {@code SSLSocketFactory} obtained from the corresponding
* SSL bundle.
* SSL bundle name. If set, 'mail.(protocol).ssl.socketFactory' property is set to
* an SSLSocketFactory obtained from the corresponding SSL bundle.
* <p>
* Note that the {@code STARTTLS} command can use the corresponding
* {@code SSLSocketFactory}, even if {@code mail.<protocol>.ssl.enable} property
* is not set.
* Note that the STARTTLS command can use the corresponding SSLSocketFactory, even
* if the 'mail.(protocol).ssl.enable' property is not set.
*/
private String bundle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ private void applyProperties(MailProperties properties, JavaMailSenderImpl sende
}
Properties javaMailProperties = asProperties(properties.getProperties());
String protocol = properties.getProtocol();
if (!StringUtils.hasLength(protocol)) {
protocol = "smtp";
}
protocol = (!StringUtils.hasLength(protocol)) ? "smtp" : protocol;
Ssl ssl = properties.getSsl();
if (ssl.isEnabled()) {
javaMailProperties.setProperty("mail." + protocol + ".ssl.enable", "true");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@

package org.springframework.boot.autoconfigure.r2dbc;

import io.r2dbc.proxy.ProxyConnectionFactory;
import io.r2dbc.proxy.ProxyConnectionFactory.Builder;

/**
* Callback interface that can be used to customize a
* {@link ProxyConnectionFactory.Builder}.
* Callback interface that can be used to customize a {@link Builder}.
*
* @author Tadaya Tsuyukubo
* @since 3.4.0
*/
@FunctionalInterface
public interface ProxyConnectionFactoryCustomizer {

/**
* Callback to customize a {@link ProxyConnectionFactory.Builder} instance.
* Callback to customize a {@link Builder} instance.
* @param builder the builder to customize
*/
void customize(ProxyConnectionFactory.Builder builder);
void customize(Builder builder);

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,28 @@ public enum StartCommand {
/**
* Start using {@code docker compose up}.
*/
UP {
@Override
void applyTo(DockerCompose dockerCompose, LogLevel logLevel, List<String> arguments) {
dockerCompose.up(logLevel, arguments);
}
},
UP(DockerCompose::up),

/**
* Start using {@code docker compose start}.
*/
START {
@Override
void applyTo(DockerCompose dockerCompose, LogLevel logLevel, List<String> arguments) {
dockerCompose.start(logLevel, arguments);
}
};

abstract void applyTo(DockerCompose dockerCompose, LogLevel logLevel, List<String> arguments);
START(DockerCompose::start);

private final Command command;

StartCommand(Command command) {
this.command = command;
}

void applyTo(DockerCompose dockerCompose, LogLevel logLevel, List<String> arguments) {
this.command.applyTo(dockerCompose, logLevel, arguments);
}

@FunctionalInterface
private interface Command {

void applyTo(DockerCompose dockerCompose, LogLevel logLevel, List<String> arguments);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,28 @@ public enum StopCommand {
/**
* Stop using {@code docker compose down}.
*/
DOWN {
@Override
void applyTo(DockerCompose dockerCompose, Duration timeout, List<String> arguments) {
dockerCompose.down(timeout, arguments);
}
},
DOWN(DockerCompose::down),

/**
* Stop using {@code docker compose stop}.
*/
STOP {
@Override
void applyTo(DockerCompose dockerCompose, Duration timeout, List<String> arguments) {
dockerCompose.stop(timeout, arguments);
}
};

abstract void applyTo(DockerCompose dockerCompose, Duration timeout, List<String> arguments);
STOP(DockerCompose::stop);

private final Command command;

StopCommand(Command command) {
this.command = command;
}

void applyTo(DockerCompose dockerCompose, Duration timeout, List<String> arguments) {
this.command.applyTo(dockerCompose, timeout, arguments);
}

@FunctionalInterface
private interface Command {

void applyTo(DockerCompose dockerCompose, Duration timeout, List<String> arguments);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ class PostgresEnvironment {
}

private String extractPassword(Map<String, String> env) {
if (hasTrustHostAuthMethod(env)) {
if (isUsingTrustHostAuthMethod(env)) {
return null;
}
String password = env.getOrDefault("POSTGRES_PASSWORD", env.get("POSTGRESQL_PASSWORD"));
Assert.state(StringUtils.hasLength(password), "PostgreSQL password must be provided");
return password;
}

private Boolean hasTrustHostAuthMethod(Map<String, String> env) {
private boolean isUsingTrustHostAuthMethod(Map<String, String> env) {
String hostAuthMethod = env.get("POSTGRES_HOST_AUTH_METHOD");
return "trust".equals(hostAuthMethod);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public BuildRequest withBuilder(ImageReference builder) {
* @param trustBuilder {@code true} if the builder should be treated as trusted,
* {@code false} otherwise
* @return an updated build request
* @since 3.4.0
*/
public BuildRequest withTrustBuilder(boolean trustBuilder) {
return new BuildRequest(this.name, this.applicationContent, this.builder, this.runImage, this.creator, this.env,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
*
* @author Stephane Nicoll
* @author Phillip Webb
* @author Jared Bates
* @since 1.2.0
*/
@Target({ ElementType.FIELD, ElementType.RECORD_COMPONENT, ElementType.METHOD })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@
* pooling.
*
* @author Stephane Nicoll
* @since 6.4.0
* @since 3.4.0
*/
public abstract class ConnectionFactoryUnwrapper {
public final class ConnectionFactoryUnwrapper {

private ConnectionFactoryUnwrapper() {
}

/**
* Return the native {@link ConnectionFactory} by unwrapping it from a cache or pool
Expand All @@ -38,17 +41,17 @@ public abstract class ConnectionFactoryUnwrapper {
* @return the native connection factory that it wraps, if any
*/
public static ConnectionFactory unwrap(ConnectionFactory connectionFactory) {
if (connectionFactory instanceof CachingConnectionFactory ccf) {
return unwrap(ccf.getTargetConnectionFactory());
if (connectionFactory instanceof CachingConnectionFactory cachingConnectionFactory) {
return unwrap(cachingConnectionFactory.getTargetConnectionFactory());
}
ConnectionFactory unwrapedConnectionFactory = unwrapFromJmsPoolConnectionFactory(connectionFactory);
return (unwrapedConnectionFactory != null) ? unwrap(unwrapedConnectionFactory) : connectionFactory;
}

private static ConnectionFactory unwrapFromJmsPoolConnectionFactory(ConnectionFactory connectionFactory) {
try {
if (connectionFactory instanceof JmsPoolConnectionFactory poolConnectionFactory) {
return (ConnectionFactory) poolConnectionFactory.getConnectionFactory();
if (connectionFactory instanceof JmsPoolConnectionFactory jmsPoolConnectionFactory) {
return (ConnectionFactory) jmsPoolConnectionFactory.getConnectionFactory();
}
}
catch (Throwable ex) {
Expand Down

0 comments on commit 8848066

Please sign in to comment.