commit
16f1414e5c
20
build.gradle
20
build.gradle
|
|
@ -33,7 +33,7 @@ configure(allprojects) { project ->
|
|||
mavenBom "org.junit:junit-bom:5.6.2"
|
||||
}
|
||||
dependencies {
|
||||
dependencySet(group: 'org.apache.logging.log4j', version: '2.13.2') {
|
||||
dependencySet(group: 'org.apache.logging.log4j', version: '2.13.3') {
|
||||
entry 'log4j-api'
|
||||
entry 'log4j-core'
|
||||
entry 'log4j-slf4j-impl'
|
||||
|
|
@ -86,11 +86,11 @@ configure(allprojects) { project ->
|
|||
dependency "org.yaml:snakeyaml:1.26"
|
||||
|
||||
dependency "com.h2database:h2:1.4.200"
|
||||
dependency "com.github.ben-manes.caffeine:caffeine:2.8.1"
|
||||
dependency "com.github.librepdf:openpdf:1.3.14"
|
||||
dependency "com.github.ben-manes.caffeine:caffeine:2.8.3"
|
||||
dependency "com.github.librepdf:openpdf:1.3.17"
|
||||
dependency "com.rometools:rome:1.12.2"
|
||||
dependency "commons-io:commons-io:2.5"
|
||||
dependency "io.vavr:vavr:0.10.2"
|
||||
dependency "io.vavr:vavr:0.10.3"
|
||||
dependency "net.sf.jopt-simple:jopt-simple:5.0.4"
|
||||
dependencySet(group: 'org.apache.activemq', version: '5.8.0') {
|
||||
entry 'activemq-broker'
|
||||
|
|
@ -141,7 +141,7 @@ configure(allprojects) { project ->
|
|||
}
|
||||
}
|
||||
|
||||
dependencySet(group: 'com.squareup.okhttp3', version: '3.14.7') {
|
||||
dependencySet(group: 'com.squareup.okhttp3', version: '3.14.9') {
|
||||
entry 'okhttp'
|
||||
entry 'mockwebserver'
|
||||
}
|
||||
|
|
@ -180,7 +180,7 @@ configure(allprojects) { project ->
|
|||
dependency "org.testng:testng:7.1.0"
|
||||
dependency "org.hamcrest:hamcrest:2.1"
|
||||
dependency "org.awaitility:awaitility:3.1.6"
|
||||
dependency "org.assertj:assertj-core:3.16.0"
|
||||
dependency "org.assertj:assertj-core:3.16.1"
|
||||
dependencySet(group: 'org.xmlunit', version: '2.6.2') {
|
||||
entry 'xmlunit-assertj'
|
||||
entry('xmlunit-matchers') {
|
||||
|
|
@ -195,10 +195,10 @@ configure(allprojects) { project ->
|
|||
}
|
||||
dependency "io.mockk:mockk:1.10.0"
|
||||
|
||||
dependency("net.sourceforge.htmlunit:htmlunit:2.39.1") {
|
||||
dependency("net.sourceforge.htmlunit:htmlunit:2.40.0") {
|
||||
exclude group: "commons-logging", name: "commons-logging"
|
||||
}
|
||||
dependency("org.seleniumhq.selenium:htmlunit-driver:2.39.0") {
|
||||
dependency("org.seleniumhq.selenium:htmlunit-driver:2.40.0") {
|
||||
exclude group: "commons-logging", name: "commons-logging"
|
||||
}
|
||||
dependency("org.seleniumhq.selenium:selenium-java:3.141.59") {
|
||||
|
|
@ -224,8 +224,8 @@ configure(allprojects) { project ->
|
|||
}
|
||||
|
||||
dependency "com.ibm.websphere:uow:6.0.2.17"
|
||||
dependency "com.jamonapi:jamon:2.81"
|
||||
dependency "joda-time:joda-time:2.10.5"
|
||||
dependency "com.jamonapi:jamon:2.82"
|
||||
dependency "joda-time:joda-time:2.10.6"
|
||||
dependency "org.eclipse.persistence:org.eclipse.persistence.jpa:2.7.6"
|
||||
dependency "org.javamoney:moneta:1.3"
|
||||
|
||||
|
|
|
|||
|
|
@ -47,10 +47,10 @@ import org.springframework.lang.Nullable;
|
|||
*/
|
||||
public class ServerSentEventHttpMessageReader implements HttpMessageReader<Object> {
|
||||
|
||||
private static final DataBufferFactory bufferFactory = new DefaultDataBufferFactory();
|
||||
|
||||
private static final ResolvableType STRING_TYPE = ResolvableType.forClass(String.class);
|
||||
|
||||
private static final DataBufferFactory bufferFactory = new DefaultDataBufferFactory();
|
||||
|
||||
|
||||
@Nullable
|
||||
private final Decoder<?> decoder;
|
||||
|
|
@ -58,8 +58,6 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
|
|||
private final StringDecoder lineDecoder = StringDecoder.textPlainOnly();
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor without a {@code Decoder}. In this mode only {@code String}
|
||||
* is supported as the data of an event.
|
||||
|
|
@ -171,11 +169,11 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
|
|||
}
|
||||
}
|
||||
|
||||
Object decodedData = (data != null ? decodeData(data.toString(), valueType, hints) : null);
|
||||
Object decodedData = (data != null ? decodeData(data, valueType, hints) : null);
|
||||
|
||||
if (shouldWrap) {
|
||||
if (comment != null) {
|
||||
sseBuilder.comment(comment.toString().substring(0, comment.length() - 1));
|
||||
sseBuilder.comment(comment.substring(0, comment.length() - 1));
|
||||
}
|
||||
if (decodedData != null) {
|
||||
sseBuilder.data(decodedData);
|
||||
|
|
@ -183,19 +181,19 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
|
|||
return sseBuilder.build();
|
||||
}
|
||||
else {
|
||||
return (decodedData);
|
||||
return decodedData;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object decodeData(String data, ResolvableType dataType, Map<String, Object> hints) {
|
||||
private Object decodeData(StringBuilder data, ResolvableType dataType, Map<String, Object> hints) {
|
||||
if (String.class == dataType.resolve()) {
|
||||
return data.substring(0, data.length() - 1);
|
||||
}
|
||||
if (this.decoder == null) {
|
||||
throw new CodecException("No SSE decoder configured and the data is not String.");
|
||||
}
|
||||
byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] bytes = data.toString().getBytes(StandardCharsets.UTF_8);
|
||||
DataBuffer buffer = bufferFactory.wrap(bytes); // wrapping only, no allocation
|
||||
return this.decoder.decode(buffer, dataType, MediaType.TEXT_EVENT_STREAM, hints);
|
||||
}
|
||||
|
|
@ -221,7 +219,6 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
|
|||
|
||||
private int accumulated = 0;
|
||||
|
||||
|
||||
public void afterLineParsed(String line) {
|
||||
if (getMaxInMemorySize() < 0) {
|
||||
return;
|
||||
|
|
@ -242,8 +239,7 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
|
|||
|
||||
private void raiseLimitException() {
|
||||
// Do not release here, it's likely down via doOnDiscard..
|
||||
throw new DataBufferLimitException(
|
||||
"Exceeded limit on max bytes to buffer : " + getMaxInMemorySize());
|
||||
throw new DataBufferLimitException("Exceeded limit on max bytes to buffer : " + getMaxInMemorySize());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
|
|||
result = Flux.just(encodeText(sb + (String) data + "\n\n", mediaType, factory));
|
||||
}
|
||||
else {
|
||||
result = encodeEvent(sb.toString(), data, dataType, mediaType, factory, hints);
|
||||
result = encodeEvent(sb, data, dataType, mediaType, factory, hints);
|
||||
}
|
||||
|
||||
return result.doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release);
|
||||
|
|
@ -161,7 +161,7 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> Flux<DataBuffer> encodeEvent(String eventContent, T data, ResolvableType dataType,
|
||||
private <T> Flux<DataBuffer> encodeEvent(StringBuilder eventContent, T data, ResolvableType dataType,
|
||||
MediaType mediaType, DataBufferFactory factory, Map<String, Object> hints) {
|
||||
|
||||
if (this.encoder == null) {
|
||||
|
|
@ -174,16 +174,13 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
|
|||
}
|
||||
|
||||
private void writeField(String fieldName, Object fieldValue, StringBuilder sb) {
|
||||
sb.append(fieldName);
|
||||
sb.append(':');
|
||||
sb.append(fieldValue.toString());
|
||||
sb.append("\n");
|
||||
sb.append(fieldName).append(':').append(fieldValue).append("\n");
|
||||
}
|
||||
|
||||
private DataBuffer encodeText(CharSequence text, MediaType mediaType, DataBufferFactory bufferFactory) {
|
||||
Assert.notNull(mediaType.getCharset(), "Expected MediaType with charset");
|
||||
byte[] bytes = text.toString().getBytes(mediaType.getCharset());
|
||||
return bufferFactory.wrap(bytes); // wrapping, not allocating
|
||||
return bufferFactory.wrap(bytes); // wrapping, not allocating
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue