Merge branch '5.2.x'

This commit is contained in:
Juergen Hoeller 2020-09-18 18:16:33 +02:00
commit bbe74635eb
8 changed files with 28 additions and 30 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -46,7 +46,7 @@ public abstract class FreeMarkerTemplateUtils {
public static String processTemplateIntoString(Template template, Object model) public static String processTemplateIntoString(Template template, Object model)
throws IOException, TemplateException { throws IOException, TemplateException {
StringWriter result = new StringWriter(); StringWriter result = new StringWriter(1024);
template.process(model, result); template.process(model, result);
return result.toString(); return result.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -37,10 +37,11 @@ import org.springframework.lang.Nullable;
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 4.0 * @since 4.0
* @see javax.enterprise.concurrent.ManagedScheduledExecutorService
*/ */
public class DefaultManagedTaskScheduler extends ConcurrentTaskScheduler implements InitializingBean { public class DefaultManagedTaskScheduler extends ConcurrentTaskScheduler implements InitializingBean {
private JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate(); private final JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate();
@Nullable @Nullable
private String jndiName = "java:comp/DefaultManagedScheduledExecutorService"; private String jndiName = "java:comp/DefaultManagedScheduledExecutorService";

View File

@ -218,7 +218,7 @@ public abstract class FileCopyUtils {
return ""; return "";
} }
StringWriter out = new StringWriter(); StringWriter out = new StringWriter(BUFFER_SIZE);
copy(in, out); copy(in, out);
return out.toString(); return out.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -275,7 +275,7 @@ public class MappingJackson2MessageConverter implements SmartMessageConverter, B
protected TextMessage mapToTextMessage(Object object, Session session, ObjectWriter objectWriter) protected TextMessage mapToTextMessage(Object object, Session session, ObjectWriter objectWriter)
throws JMSException, IOException { throws JMSException, IOException {
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter(1024);
objectWriter.writeValue(writer, object); objectWriter.writeValue(writer, object);
return session.createTextMessage(writer.toString()); return session.createTextMessage(writer.toString());
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -48,8 +48,6 @@ import org.springframework.util.Assert;
* @author Arjen Poutsma * @author Arjen Poutsma
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 3.0 * @since 3.0
* @see org.springframework.jms.core.JmsTemplate#convertAndSend
* @see org.springframework.jms.core.JmsTemplate#receiveAndConvert
*/ */
public class MarshallingMessageConverter implements MessageConverter, InitializingBean { public class MarshallingMessageConverter implements MessageConverter, InitializingBean {
@ -215,7 +213,7 @@ public class MarshallingMessageConverter implements MessageConverter, Initializi
protected TextMessage marshalToTextMessage(Object object, Session session, Marshaller marshaller) protected TextMessage marshalToTextMessage(Object object, Session session, Marshaller marshaller)
throws JMSException, IOException, XmlMappingException { throws JMSException, IOException, XmlMappingException {
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter(1024);
Result result = new StreamResult(writer); Result result = new StreamResult(writer);
marshaller.marshal(object, result); marshaller.marshal(object, result);
return session.createTextMessage(writer.toString()); return session.createTextMessage(writer.toString());

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -209,9 +209,11 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter {
JavaType javaType = getJavaType(targetClass, conversionHint); JavaType javaType = getJavaType(targetClass, conversionHint);
Object payload = message.getPayload(); Object payload = message.getPayload();
Class<?> view = getSerializationView(conversionHint); Class<?> view = getSerializationView(conversionHint);
// Note: in the view case, calling withType instead of forType for compatibility with Jackson <2.5
try { try {
if (payload instanceof byte[]) { if (targetClass.isInstance(payload)) {
return payload;
}
else if (payload instanceof byte[]) {
if (view != null) { if (view != null) {
return this.objectMapper.readerWithView(view).forType(javaType).readValue((byte[]) payload); return this.objectMapper.readerWithView(view).forType(javaType).readValue((byte[]) payload);
} }
@ -219,10 +221,8 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter {
return this.objectMapper.readValue((byte[]) payload, javaType); return this.objectMapper.readValue((byte[]) payload, javaType);
} }
} }
else if (targetClass.isInstance(payload)) {
return payload;
}
else { else {
// Assuming a text-based source payload
if (view != null) { if (view != null) {
return this.objectMapper.readerWithView(view).forType(javaType).readValue(payload.toString()); return this.objectMapper.readerWithView(view).forType(javaType).readValue(payload.toString());
} }
@ -271,7 +271,8 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter {
payload = out.toByteArray(); payload = out.toByteArray();
} }
else { else {
Writer writer = new StringWriter(); // Assuming a text-based target payload
Writer writer = new StringWriter(1024);
if (view != null) { if (view != null) {
this.objectMapper.writerWithView(view).writeValue(writer, payload); this.objectMapper.writerWithView(view).writeValue(writer, payload);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -172,13 +172,13 @@ public class MarshallingMessageConverter extends AbstractMessageConverter {
Assert.notNull(this.marshaller, "Property 'marshaller' is required"); Assert.notNull(this.marshaller, "Property 'marshaller' is required");
try { try {
if (byte[].class == getSerializedPayloadClass()) { if (byte[].class == getSerializedPayloadClass()) {
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
Result result = new StreamResult(out); Result result = new StreamResult(out);
this.marshaller.marshal(payload, result); this.marshaller.marshal(payload, result);
payload = out.toByteArray(); payload = out.toByteArray();
} }
else { else {
Writer writer = new StringWriter(); Writer writer = new StringWriter(1024);
Result result = new StreamResult(writer); Result result = new StreamResult(writer);
this.marshaller.marshal(payload, result); this.marshaller.marshal(payload, result);
payload = writer.toString(); payload = writer.toString();

View File

@ -130,15 +130,13 @@ class ReactorClientHttpResponse implements ClientHttpResponse {
public MultiValueMap<String, ResponseCookie> getCookies() { public MultiValueMap<String, ResponseCookie> getCookies() {
MultiValueMap<String, ResponseCookie> result = new LinkedMultiValueMap<>(); MultiValueMap<String, ResponseCookie> result = new LinkedMultiValueMap<>();
this.response.cookies().values().stream().flatMap(Collection::stream) this.response.cookies().values().stream().flatMap(Collection::stream)
.forEach(c -> .forEach(c -> result.add(c.name(), ResponseCookie.fromClientResponse(c.name(), c.value())
.domain(c.domain())
result.add(c.name(), ResponseCookie.fromClientResponse(c.name(), c.value()) .path(c.path())
.domain(c.domain()) .maxAge(c.maxAge())
.path(c.path()) .secure(c.isSecure())
.maxAge(c.maxAge()) .httpOnly(c.isHttpOnly())
.secure(c.isSecure()) .build()));
.httpOnly(c.isHttpOnly())
.build()));
return CollectionUtils.unmodifiableMultiValueMap(result); return CollectionUtils.unmodifiableMultiValueMap(result);
} }