Switch defaults and model for logging sensitive data
Issue: SPR-17029
This commit is contained in:
@@ -54,7 +54,7 @@ public class ByteArrayEncoder extends AbstractEncoder<byte[]> {
|
||||
|
||||
return Flux.from(inputStream).map(bytes -> {
|
||||
DataBuffer dataBuffer = bufferFactory.wrap(bytes);
|
||||
if (logger.isDebugEnabled() && !Hints.suppressLogging(hints)) {
|
||||
if (logger.isDebugEnabled() && !Hints.isLoggingSuppressed(hints)) {
|
||||
String logPrefix = Hints.getLogPrefix(hints);
|
||||
logger.debug(logPrefix + "Writing " + dataBuffer.readableByteCount() + " bytes");
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ByteBufferEncoder extends AbstractEncoder<ByteBuffer> {
|
||||
|
||||
return Flux.from(inputStream).map(byteBuffer -> {
|
||||
DataBuffer dataBuffer = bufferFactory.wrap(byteBuffer);
|
||||
if (logger.isDebugEnabled() && !Hints.suppressLogging(hints)) {
|
||||
if (logger.isDebugEnabled() && !Hints.isLoggingSuppressed(hints)) {
|
||||
String logPrefix = Hints.getLogPrefix(hints);
|
||||
logger.debug(logPrefix + "Writing " + dataBuffer.readableByteCount() + " bytes");
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public final class CharSequenceEncoder extends AbstractEncoder<CharSequence> {
|
||||
Charset charset = getCharset(mimeType);
|
||||
|
||||
return Flux.from(inputStream).map(charSequence -> {
|
||||
if (logger.isDebugEnabled() && !Hints.suppressLogging(hints)) {
|
||||
if (logger.isDebugEnabled() && !Hints.isLoggingSuppressed(hints)) {
|
||||
String logPrefix = Hints.getLogPrefix(hints);
|
||||
logger.debug(logPrefix + "Writing '" + charSequence + "'");
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class DataBufferEncoder extends AbstractEncoder<DataBuffer> {
|
||||
|
||||
Flux<DataBuffer> flux = Flux.from(inputStream);
|
||||
|
||||
if (logger.isDebugEnabled() && !Hints.suppressLogging(hints)) {
|
||||
if (logger.isDebugEnabled() && !Hints.isLoggingSuppressed(hints)) {
|
||||
flux = flux.doOnNext(buffer -> {
|
||||
String logPrefix = Hints.getLogPrefix(hints);
|
||||
logger.debug(logPrefix + "Writing " + buffer.readableByteCount() + " bytes");
|
||||
|
||||
@@ -99,7 +99,7 @@ public abstract class Hints {
|
||||
* @param hints the hints map
|
||||
* @return whether logging of data is allowed
|
||||
*/
|
||||
public static boolean suppressLogging(@Nullable Map<String, Object> hints) {
|
||||
public static boolean isLoggingSuppressed(@Nullable Map<String, Object> hints) {
|
||||
return hints != null && (boolean) hints.getOrDefault(SUPPRESS_LOGGING_HINT, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ResourceEncoder extends AbstractSingleValueEncoder<Resource> {
|
||||
protected Flux<DataBuffer> encode(Resource resource, DataBufferFactory dataBufferFactory,
|
||||
ResolvableType type, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {
|
||||
|
||||
if (logger.isDebugEnabled() && !Hints.suppressLogging(hints)) {
|
||||
if (logger.isDebugEnabled() && !Hints.isLoggingSuppressed(hints)) {
|
||||
String logPrefix = Hints.getLogPrefix(hints);
|
||||
logger.debug(logPrefix + "Writing [" + resource + "]");
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public class ResourceRegionEncoder extends AbstractEncoder<ResourceRegion> {
|
||||
long position = region.getPosition();
|
||||
long count = region.getCount();
|
||||
|
||||
if (logger.isDebugEnabled() && !Hints.suppressLogging(hints)) {
|
||||
if (logger.isDebugEnabled() && !Hints.isLoggingSuppressed(hints)) {
|
||||
logger.debug(Hints.getLogPrefix(hints) +
|
||||
"Writing region " + position + "-" + (position + count) + " of [" + resource + "]");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user