Skip to content

Commit ec8689d

Browse files
committed
Merge branch '5.1.x'
2 parents fc8d5c0 + 84266d7 commit ec8689d

File tree

6 files changed

+39
-26
lines changed

6 files changed

+39
-26
lines changed

spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -199,7 +199,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
199199
private String remoteHost = DEFAULT_REMOTE_HOST;
200200

201201
/** List of locales in descending order. */
202-
private final List<Locale> locales = new LinkedList<>();
202+
private final LinkedList<Locale> locales = new LinkedList<>();
203203

204204
private boolean secure = false;
205205

@@ -779,7 +779,7 @@ public void clearAttributes() {
779779
*/
780780
public void addPreferredLocale(Locale locale) {
781781
Assert.notNull(locale, "Locale must not be null");
782-
this.locales.add(0, locale);
782+
this.locales.addFirst(locale);
783783
updateAcceptLanguageHeader();
784784
}
785785

@@ -817,7 +817,7 @@ private void updateAcceptLanguageHeader() {
817817
*/
818818
@Override
819819
public Locale getLocale() {
820-
return this.locales.get(0);
820+
return this.locales.getFirst();
821821
}
822822

823823
/**
@@ -1015,6 +1015,9 @@ else if (HttpHeaders.ACCEPT_LANGUAGE.equalsIgnoreCase(name) &&
10151015
List<Locale> locales = headers.getAcceptLanguageAsLocales();
10161016
this.locales.clear();
10171017
this.locales.addAll(locales);
1018+
if (this.locales.isEmpty()) {
1019+
this.locales.add(Locale.ENGLISH);
1020+
}
10181021
}
10191022
catch (IllegalArgumentException ex) {
10201023
// Invalid Accept-Language format -> just store plain header

spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -351,6 +351,13 @@ public void invalidAcceptLanguageHeader() {
351351
assertEquals("en_US", request.getHeader("Accept-Language"));
352352
}
353353

354+
@Test
355+
public void emptyAcceptLanguageHeader() {
356+
request.addHeader("Accept-Language", "");
357+
assertEquals(Locale.ENGLISH, request.getLocale());
358+
assertEquals("", request.getHeader("Accept-Language"));
359+
}
360+
354361
@Test
355362
public void getServerNameWithDefaultName() {
356363
assertEquals("localhost", request.getServerName());

spring-tx/src/main/java/org/springframework/transaction/PlatformTransactionManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
* @since 16.05.2003
4242
* @see org.springframework.transaction.support.TransactionTemplate
4343
* @see org.springframework.transaction.interceptor.TransactionInterceptor
44-
* @see org.springframework.transaction.interceptor.TransactionProxyFactoryBean
4544
*/
4645
public interface PlatformTransactionManager extends TransactionManager {
4746

@@ -68,7 +67,8 @@ public interface PlatformTransactionManager extends TransactionManager {
6867
* @see TransactionDefinition#getTimeout
6968
* @see TransactionDefinition#isReadOnly
7069
*/
71-
TransactionStatus getTransaction(@Nullable TransactionDefinition definition) throws TransactionException;
70+
TransactionStatus getTransaction(@Nullable TransactionDefinition definition)
71+
throws TransactionException;
7272

7373
/**
7474
* Commit the given transaction, with regard to its status. If the transaction

spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletRequest.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -199,7 +199,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
199199
private String remoteHost = DEFAULT_REMOTE_HOST;
200200

201201
/** List of locales in descending order. */
202-
private final List<Locale> locales = new LinkedList<>();
202+
private final LinkedList<Locale> locales = new LinkedList<>();
203203

204204
private boolean secure = false;
205205

@@ -403,12 +403,11 @@ public void setCharacterEncoding(@Nullable String characterEncoding) {
403403

404404
private void updateContentTypeHeader() {
405405
if (StringUtils.hasLength(this.contentType)) {
406-
StringBuilder sb = new StringBuilder(this.contentType);
407-
if (!this.contentType.toLowerCase().contains(CHARSET_PREFIX) &&
408-
StringUtils.hasLength(this.characterEncoding)) {
409-
sb.append(";").append(CHARSET_PREFIX).append(this.characterEncoding);
406+
String value = this.contentType;
407+
if (StringUtils.hasLength(this.characterEncoding) && !this.contentType.toLowerCase().contains(CHARSET_PREFIX)) {
408+
value += ';' + CHARSET_PREFIX + this.characterEncoding;
410409
}
411-
doAddHeaderValue(HttpHeaders.CONTENT_TYPE, sb.toString(), true);
410+
doAddHeaderValue(HttpHeaders.CONTENT_TYPE, value, true);
412411
}
413412
}
414413

@@ -780,7 +779,7 @@ public void clearAttributes() {
780779
*/
781780
public void addPreferredLocale(Locale locale) {
782781
Assert.notNull(locale, "Locale must not be null");
783-
this.locales.add(0, locale);
782+
this.locales.addFirst(locale);
784783
updateAcceptLanguageHeader();
785784
}
786785

@@ -818,7 +817,7 @@ private void updateAcceptLanguageHeader() {
818817
*/
819818
@Override
820819
public Locale getLocale() {
821-
return this.locales.get(0);
820+
return this.locales.getFirst();
822821
}
823822

824823
/**
@@ -1016,6 +1015,9 @@ else if (HttpHeaders.ACCEPT_LANGUAGE.equalsIgnoreCase(name) &&
10161015
List<Locale> locales = headers.getAcceptLanguageAsLocales();
10171016
this.locales.clear();
10181017
this.locales.addAll(locales);
1018+
if (this.locales.isEmpty()) {
1019+
this.locales.add(Locale.ENGLISH);
1020+
}
10191021
}
10201022
catch (IllegalArgumentException ex) {
10211023
// Invalid Accept-Language format -> just store plain header

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeStrategies.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,18 +37,18 @@ public interface ExchangeStrategies {
3737

3838
/**
3939
* Return {@link HttpMessageReader HttpMessageReaders} to read and decode the response body with.
40-
* @return the stream of message readers
40+
* @return the message readers
4141
*/
4242
List<HttpMessageReader<?>> messageReaders();
4343

4444
/**
4545
* Return {@link HttpMessageWriter HttpMessageWriters} to write and encode the request body with.
46-
* @return the stream of message writers
46+
* @return the message writers
4747
*/
4848
List<HttpMessageWriter<?>> messageWriters();
4949

5050

51-
// Static methods
51+
// Static builder methods
5252

5353
/**
5454
* Return a new {@code ExchangeStrategies} with default configuration

spring-webflux/src/main/java/org/springframework/web/reactive/function/server/HandlerStrategies.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,10 +28,11 @@
2828
import org.springframework.web.server.i18n.LocaleContextResolver;
2929

3030
/**
31-
* Defines the strategies to be used for processing {@link HandlerFunction HandlerFunctions}. An instance of
32-
* this class is immutable; instances are typically created through the mutable {@link Builder}:
33-
* either through {@link #builder()} to set up default strategies, or {@link #empty()} to start from
34-
* scratch.
31+
* Defines the strategies to be used for processing {@link HandlerFunction HandlerFunctions}.
32+
*
33+
* <p>An instance of this class is immutable. Instances are typically created through the
34+
* mutable {@link Builder}: either through {@link #builder()} to set up default strategies,
35+
* or {@link #empty()} to start from scratch.
3536
*
3637
* @author Arjen Poutsma
3738
* @author Juergen Hoeller
@@ -78,7 +79,7 @@ public interface HandlerStrategies {
7879
LocaleContextResolver localeContextResolver();
7980

8081

81-
// Static methods
82+
// Static builder methods
8283

8384
/**
8485
* Return a new {@code HandlerStrategies} with default initialization.

0 commit comments

Comments
 (0)