Skip to content

Commit 42c0d8e

Browse files
committed
Merge branch '5.1.x'
2 parents 259dd3d + 1ccd99e commit 42c0d8e

File tree

7 files changed

+34
-25
lines changed

7 files changed

+34
-25
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/core/support/AbstractLobStreamingResultSetExtractor.java

Lines changed: 2 additions & 2 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.
@@ -80,7 +80,7 @@ public final T extractData(ResultSet rs) throws SQLException, DataAccessExceptio
8080
}
8181
}
8282
catch (IOException ex) {
83-
throw new LobRetrievalFailureException("Couldn't stream LOB content", ex);
83+
throw new LobRetrievalFailureException("Could not stream LOB content", ex);
8484
}
8585
}
8686
return null;

spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlFunction.java

Lines changed: 2 additions & 2 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.
@@ -161,7 +161,7 @@ public int run(int parameter) {
161161
public int run(Object... parameters) {
162162
Object obj = super.findObject(parameters);
163163
if (!(obj instanceof Number)) {
164-
throw new TypeMismatchDataAccessException("Couldn't convert result object [" + obj + "] to int");
164+
throw new TypeMismatchDataAccessException("Could not convert result object [" + obj + "] to int");
165165
}
166166
return ((Number) obj).intValue();
167167
}

spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ public byte[] getAttachmentAsByteArray(String cid) {
10251025
return FileCopyUtils.copyToByteArray(dataHandler.getInputStream());
10261026
}
10271027
catch (IOException ex) {
1028-
throw new UnmarshallingFailureException("Couldn't read attachment", ex);
1028+
throw new UnmarshallingFailureException("Could not read attachment", ex);
10291029
}
10301030
}
10311031

spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java

Lines changed: 2 additions & 2 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.
@@ -153,7 +153,7 @@ public void addTransactionalMethod(Class<?> clazz, String mappedName, Transactio
153153
}
154154
if (matchingMethods.isEmpty()) {
155155
throw new IllegalArgumentException(
156-
"Couldn't find method '" + mappedName + "' on class [" + clazz.getName() + "]");
156+
"Could not find method '" + mappedName + "' on class [" + clazz.getName() + "]");
157157
}
158158

159159
// Register all matching methods

spring-web/src/main/java/org/springframework/web/context/ContextCleanupListener.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 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.
@@ -54,22 +54,26 @@ public void contextDestroyed(ServletContextEvent event) {
5454

5555

5656
/**
57-
* Find all ServletContext attributes which implement {@link DisposableBean}
58-
* and destroy them, removing all affected ServletContext attributes eventually.
59-
* @param sc the ServletContext to check
57+
* Find all Spring-internal ServletContext attributes which implement
58+
* {@link DisposableBean} and invoke the destroy method on them.
59+
* @param servletContext the ServletContext to check
60+
* @see DisposableBean#destroy()
6061
*/
61-
static void cleanupAttributes(ServletContext sc) {
62-
Enumeration<String> attrNames = sc.getAttributeNames();
62+
static void cleanupAttributes(ServletContext servletContext) {
63+
Enumeration<String> attrNames = servletContext.getAttributeNames();
6364
while (attrNames.hasMoreElements()) {
6465
String attrName = attrNames.nextElement();
6566
if (attrName.startsWith("org.springframework.")) {
66-
Object attrValue = sc.getAttribute(attrName);
67+
Object attrValue = servletContext.getAttribute(attrName);
6768
if (attrValue instanceof DisposableBean) {
6869
try {
6970
((DisposableBean) attrValue).destroy();
7071
}
7172
catch (Throwable ex) {
72-
logger.error("Couldn't invoke destroy method of attribute with name '" + attrName + "'", ex);
73+
if (logger.isWarnEnabled()) {
74+
logger.warn("Invocation of destroy method failed on ServletContext " +
75+
"attribute with name '" + attrName + "'", ex);
76+
}
7377
}
7478
}
7579
}

spring-web/src/main/java/org/springframework/web/context/request/ServletRequestAttributes.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 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.
@@ -188,18 +188,17 @@ public void setAttribute(String name, Object value, int scope) {
188188
public void removeAttribute(String name, int scope) {
189189
if (scope == SCOPE_REQUEST) {
190190
if (isRequestActive()) {
191-
this.request.removeAttribute(name);
192191
removeRequestDestructionCallback(name);
192+
this.request.removeAttribute(name);
193193
}
194194
}
195195
else {
196196
HttpSession session = getSession(false);
197197
if (session != null) {
198198
this.sessionAttributesToUpdate.remove(name);
199199
try {
200-
session.removeAttribute(name);
201-
// Remove any registered destruction callback as well.
202200
session.removeAttribute(DESTRUCTION_CALLBACK_NAME_PREFIX + name);
201+
session.removeAttribute(name);
203202
}
204203
catch (IllegalStateException ex) {
205204
// Session invalidated - shouldn't usually happen.

spring-web/src/main/java/org/springframework/web/context/support/ServletContextScope.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 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.
@@ -78,8 +78,10 @@ public Object get(String name, ObjectFactory<?> objectFactory) {
7878
public Object remove(String name) {
7979
Object scopedObject = this.servletContext.getAttribute(name);
8080
if (scopedObject != null) {
81+
synchronized (this.destructionCallbacks) {
82+
this.destructionCallbacks.remove(name);
83+
}
8184
this.servletContext.removeAttribute(name);
82-
this.destructionCallbacks.remove(name);
8385
return scopedObject;
8486
}
8587
else {
@@ -89,7 +91,9 @@ public Object remove(String name) {
8991

9092
@Override
9193
public void registerDestructionCallback(String name, Runnable callback) {
92-
this.destructionCallbacks.put(name, callback);
94+
synchronized (this.destructionCallbacks) {
95+
this.destructionCallbacks.put(name, callback);
96+
}
9397
}
9498

9599
@Override
@@ -112,10 +116,12 @@ public String getConversationId() {
112116
*/
113117
@Override
114118
public void destroy() {
115-
for (Runnable runnable : this.destructionCallbacks.values()) {
116-
runnable.run();
119+
synchronized (this.destructionCallbacks) {
120+
for (Runnable runnable : this.destructionCallbacks.values()) {
121+
runnable.run();
122+
}
123+
this.destructionCallbacks.clear();
117124
}
118-
this.destructionCallbacks.clear();
119125
}
120126

121127
}

0 commit comments

Comments
 (0)