Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ private OpenApiViolation buildOpenApiViolation(
private boolean isViolationExcluded(OpenApiViolation openApiViolation) {
return
violationExclusions.isExcluded(openApiViolation)
// JSON parse errors should be ignored as it can't be compared to the schema then (this also prevents logging personal data!)
|| openApiViolation.getMessage().startsWith("Unable to parse JSON")
// If it matches more than 1, then we don't want to log a validation error
|| openApiViolation.getMessage().matches(
".*\\[Path '[^']+'] Instance failed to match exactly one schema \\(matched [1-9][0-9]* out of \\d\\).*");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
import org.springframework.lang.NonNull;
import reactor.core.publisher.Flux;
import reactor.core.publisher.SignalType;

public class BodyCachingServerHttpRequestDecorator extends ServerHttpRequestDecorator {
private final TrafficSelector trafficSelector;
Expand Down Expand Up @@ -38,11 +39,17 @@ public Flux<DataBuffer> getBody() {
return super.getBody();
}

return super.getBody().doOnNext(dataBuffer -> {
cachedBody = dataBuffer.toString(StandardCharsets.UTF_8);
if (onBodyCachedListener != null) {
onBodyCachedListener.run();
}
});
return super.getBody()
.doOnNext(dataBuffer -> {
if (cachedBody == null) {
cachedBody = "";
}
cachedBody += dataBuffer.toString(StandardCharsets.UTF_8);
})
.doFinally(signalType -> {
if (signalType == SignalType.ON_COMPLETE && onBodyCachedListener != null) {
onBodyCachedListener.run();
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
import org.springframework.lang.NonNull;
import reactor.core.publisher.Flux;
import reactor.core.publisher.SignalType;

public class BodyCachingServerHttpRequestDecorator extends ServerHttpRequestDecorator {
private final TrafficSelector trafficSelector;
Expand Down Expand Up @@ -38,11 +39,17 @@ public Flux<DataBuffer> getBody() {
return super.getBody();
}

return super.getBody().doOnNext(dataBuffer -> {
cachedBody = dataBuffer.toString(StandardCharsets.UTF_8);
if (onBodyCachedListener != null) {
onBodyCachedListener.run();
}
});
return super.getBody()
.doOnNext(dataBuffer -> {
if (cachedBody == null) {
cachedBody = "";
}
cachedBody += dataBuffer.toString(StandardCharsets.UTF_8);
})
.doFinally(signalType -> {
if (signalType == SignalType.ON_COMPLETE && onBodyCachedListener != null) {
onBodyCachedListener.run();
}
});
}
}