Polish
This commit is contained in:
@@ -65,18 +65,38 @@ public class Sanitizer {
|
||||
DEFAULT_KEYS_TO_SANITIZE.addAll(URI_USERINFO_KEYS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Sanitizer} instance with a default set of keys to sanitize.
|
||||
*/
|
||||
public Sanitizer() {
|
||||
this(DEFAULT_KEYS_TO_SANITIZE.toArray(new String[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Sanitizer} instance with specific keys to sanitize.
|
||||
* @param keysToSanitize the keys to sanitize
|
||||
*/
|
||||
public Sanitizer(String... keysToSanitize) {
|
||||
this(Collections.emptyList(), keysToSanitize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Sanitizer} instance with a default set of keys to sanitize and
|
||||
* additional sanitizing functions.
|
||||
* @param sanitizingFunctions the sanitizing functions to apply
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public Sanitizer(Iterable<SanitizingFunction> sanitizingFunctions) {
|
||||
this(sanitizingFunctions, DEFAULT_KEYS_TO_SANITIZE.toArray(new String[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Sanitizer} instance with specific keys to sanitize and
|
||||
* additional sanitizing functions.
|
||||
* @param sanitizingFunctions the sanitizing functions to apply
|
||||
* @param keysToSanitize the keys to sanitize
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public Sanitizer(Iterable<SanitizingFunction> sanitizingFunctions, String... keysToSanitize) {
|
||||
sanitizingFunctions.forEach(this.sanitizingFunctions::add);
|
||||
this.sanitizingFunctions.add(getDefaultSanitizingFunction());
|
||||
|
||||
@@ -84,17 +84,13 @@ public abstract class AbstractHealthIndicator implements HealthIndicator {
|
||||
catch (Exception ex) {
|
||||
builder.down(ex);
|
||||
}
|
||||
logExceptionIfPresent(builder);
|
||||
logExceptionIfPresent(builder.getException());
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private void logExceptionIfPresent(Builder builder) {
|
||||
Throwable ex = builder.getException();
|
||||
private void logExceptionIfPresent(Throwable ex) {
|
||||
if (ex != null && this.logger.isWarnEnabled()) {
|
||||
String message = null;
|
||||
if (ex instanceof Exception) {
|
||||
message = this.healthCheckFailedMessage.apply((Exception) ex);
|
||||
}
|
||||
String message = (ex instanceof Exception) ? this.healthCheckFailedMessage.apply((Exception) ex) : null;
|
||||
this.logger.warn(StringUtils.hasText(message) ? message : DEFAULT_MESSAGE, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,15 +323,6 @@ public final class Health extends HealthComponent {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link Exception}.
|
||||
* @return the exception or {@code null} if the builder has no exception
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public Throwable getException() {
|
||||
return this.exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Health} instance with the previously specified code and
|
||||
* details.
|
||||
@@ -341,6 +332,14 @@ public final class Health extends HealthComponent {
|
||||
return new Health(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link Exception}.
|
||||
* @return the exception or {@code null} if the builder has no exception
|
||||
*/
|
||||
Throwable getException() {
|
||||
return this.exception;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user