Skip to content

Commit 7622d1e

Browse files
committed
Polishing
1 parent d032bed commit 7622d1e

File tree

7 files changed

+53
-23
lines changed

7 files changed

+53
-23
lines changed

spring-core/src/main/java/org/springframework/core/CollectionFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import org.springframework.util.ReflectionUtils;
4444

4545
/**
46-
* Factory for collections that is aware of Java 5, Java 6, and Spring collection types.
46+
* Factory for collections that is aware of common Java and Spring collection types.
4747
*
4848
* <p>Mainly for internal use within the framework.
4949
*

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-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.
@@ -79,7 +79,7 @@ public final T extractData(ResultSet rs) throws SQLException, DataAccessExceptio
7979
}
8080
}
8181
catch (IOException ex) {
82-
throw new LobRetrievalFailureException("Couldn't stream LOB content", ex);
82+
throw new LobRetrievalFailureException("Could not stream LOB content", ex);
8383
}
8484
}
8585
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-2016 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.
@@ -160,7 +160,7 @@ public int run(int parameter) {
160160
public int run(Object... parameters) {
161161
Object obj = super.findObject(parameters);
162162
if (!(obj instanceof Number)) {
163-
throw new TypeMismatchDataAccessException("Couldn't convert result object [" + obj + "] to int");
163+
throw new TypeMismatchDataAccessException("Could not convert result object [" + obj + "] to int");
164164
}
165165
return ((Number) obj).intValue();
166166
}

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
@@ -1019,7 +1019,7 @@ public byte[] getAttachmentAsByteArray(String cid) {
10191019
return FileCopyUtils.copyToByteArray(dataHandler.getInputStream());
10201020
}
10211021
catch (IOException ex) {
1022-
throw new UnmarshallingFailureException("Couldn't read attachment", ex);
1022+
throw new UnmarshallingFailureException("Could not read attachment", ex);
10231023
}
10241024
}
10251025

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

Lines changed: 14 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-2018 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.
@@ -311,7 +311,9 @@ public Set<String> getResourcePaths(String path) {
311311
return resourcePaths;
312312
}
313313
catch (IOException ex) {
314-
logger.warn("Couldn't get resource paths for " + resource, ex);
314+
if (logger.isWarnEnabled()) {
315+
logger.warn("Could not get resource paths for " + resource, ex);
316+
}
315317
return null;
316318
}
317319
}
@@ -330,7 +332,9 @@ public URL getResource(String path) throws MalformedURLException {
330332
throw ex;
331333
}
332334
catch (IOException ex) {
333-
logger.warn("Couldn't get URL for " + resource, ex);
335+
if (logger.isWarnEnabled()) {
336+
logger.warn("Could not get URL for " + resource, ex);
337+
}
334338
return null;
335339
}
336340
}
@@ -346,7 +350,9 @@ public InputStream getResourceAsStream(String path) {
346350
return resource.getInputStream();
347351
}
348352
catch (IOException ex) {
349-
logger.warn("Couldn't open InputStream for " + resource, ex);
353+
if (logger.isWarnEnabled()) {
354+
logger.warn("Could not open InputStream for " + resource, ex);
355+
}
350356
return null;
351357
}
352358
}
@@ -414,8 +420,8 @@ public void setDefaultServletName(String defaultServletName) {
414420
registerNamedDispatcher(this.defaultServletName, new MockRequestDispatcher(this.defaultServletName));
415421
}
416422

417-
@Override
418423
@Deprecated
424+
@Override
419425
@Nullable
420426
public Servlet getServlet(String name) {
421427
return null;
@@ -457,7 +463,9 @@ public String getRealPath(String path) {
457463
return resource.getFile().getAbsolutePath();
458464
}
459465
catch (IOException ex) {
460-
logger.warn("Couldn't determine real path of resource " + resource, ex);
466+
if (logger.isWarnEnabled()) {
467+
logger.warn("Could not determine real path of resource " + resource, ex);
468+
}
461469
return null;
462470
}
463471
}

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/test/java/org/springframework/mock/web/test/MockServletContext.java

Lines changed: 31 additions & 9 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-2018 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.
@@ -48,6 +48,7 @@
4848
import org.springframework.core.io.ResourceLoader;
4949
import org.springframework.http.MediaType;
5050
import org.springframework.http.MediaTypeFactory;
51+
import org.springframework.lang.Nullable;
5152
import org.springframework.util.Assert;
5253
import org.springframework.util.ClassUtils;
5354
import org.springframework.util.MimeType;
@@ -129,14 +130,17 @@ public class MockServletContext implements ServletContext {
129130

130131
private final Set<String> declaredRoles = new LinkedHashSet<>();
131132

133+
@Nullable
132134
private Set<SessionTrackingMode> sessionTrackingModes;
133135

134136
private final SessionCookieConfig sessionCookieConfig = new MockSessionCookieConfig();
135137

136138
private int sessionTimeout;
137139

140+
@Nullable
138141
private String requestCharacterEncoding;
139142

143+
@Nullable
140144
private String responseCharacterEncoding;
141145

142146
private final Map<String, MediaType> mimeTypes = new LinkedHashMap<>();
@@ -165,7 +169,7 @@ public MockServletContext(String resourceBasePath) {
165169
* and no base path.
166170
* @param resourceLoader the ResourceLoader to use (or null for the default)
167171
*/
168-
public MockServletContext(ResourceLoader resourceLoader) {
172+
public MockServletContext(@Nullable ResourceLoader resourceLoader) {
169173
this("", resourceLoader);
170174
}
171175

@@ -178,7 +182,7 @@ public MockServletContext(ResourceLoader resourceLoader) {
178182
* @param resourceLoader the ResourceLoader to use (or null for the default)
179183
* @see #registerNamedDispatcher
180184
*/
181-
public MockServletContext(String resourceBasePath, ResourceLoader resourceLoader) {
185+
public MockServletContext(String resourceBasePath, @Nullable ResourceLoader resourceLoader) {
182186
this.resourceLoader = (resourceLoader != null ? resourceLoader : new DefaultResourceLoader());
183187
this.resourceBasePath = resourceBasePath;
184188

@@ -262,6 +266,7 @@ public int getEffectiveMinorVersion() {
262266
}
263267

264268
@Override
269+
@Nullable
265270
public String getMimeType(String filePath) {
266271
String extension = StringUtils.getFilenameExtension(filePath);
267272
if (this.mimeTypes.containsKey(extension)) {
@@ -285,6 +290,7 @@ public void addMimeType(String fileExtension, MediaType mimeType) {
285290
}
286291

287292
@Override
293+
@Nullable
288294
public Set<String> getResourcePaths(String path) {
289295
String actualPath = (path.endsWith("/") ? path : path + "/");
290296
Resource resource = this.resourceLoader.getResource(getResourceLocation(actualPath));
@@ -305,12 +311,15 @@ public Set<String> getResourcePaths(String path) {
305311
return resourcePaths;
306312
}
307313
catch (IOException ex) {
308-
logger.warn("Couldn't get resource paths for " + resource, ex);
314+
if (logger.isWarnEnabled()) {
315+
logger.warn("Could not get resource paths for " + resource, ex);
316+
}
309317
return null;
310318
}
311319
}
312320

313321
@Override
322+
@Nullable
314323
public URL getResource(String path) throws MalformedURLException {
315324
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
316325
if (!resource.exists()) {
@@ -323,12 +332,15 @@ public URL getResource(String path) throws MalformedURLException {
323332
throw ex;
324333
}
325334
catch (IOException ex) {
326-
logger.warn("Couldn't get URL for " + resource, ex);
335+
if (logger.isWarnEnabled()) {
336+
logger.warn("Could not get URL for " + resource, ex);
337+
}
327338
return null;
328339
}
329340
}
330341

331342
@Override
343+
@Nullable
332344
public InputStream getResourceAsStream(String path) {
333345
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
334346
if (!resource.exists()) {
@@ -338,7 +350,9 @@ public InputStream getResourceAsStream(String path) {
338350
return resource.getInputStream();
339351
}
340352
catch (IOException ex) {
341-
logger.warn("Couldn't open InputStream for " + resource, ex);
353+
if (logger.isWarnEnabled()) {
354+
logger.warn("Could not open InputStream for " + resource, ex);
355+
}
342356
return null;
343357
}
344358
}
@@ -406,8 +420,9 @@ public void setDefaultServletName(String defaultServletName) {
406420
registerNamedDispatcher(this.defaultServletName, new MockRequestDispatcher(this.defaultServletName));
407421
}
408422

409-
@Override
410423
@Deprecated
424+
@Override
425+
@Nullable
411426
public Servlet getServlet(String name) {
412427
return null;
413428
}
@@ -441,13 +456,16 @@ public void log(String message, Throwable ex) {
441456
}
442457

443458
@Override
459+
@Nullable
444460
public String getRealPath(String path) {
445461
Resource resource = this.resourceLoader.getResource(getResourceLocation(path));
446462
try {
447463
return resource.getFile().getAbsolutePath();
448464
}
449465
catch (IOException ex) {
450-
logger.warn("Couldn't determine real path of resource " + resource, ex);
466+
if (logger.isWarnEnabled()) {
467+
logger.warn("Could not determine real path of resource " + resource, ex);
468+
}
451469
return null;
452470
}
453471
}
@@ -484,6 +502,7 @@ public void addInitParameter(String name, String value) {
484502
}
485503

486504
@Override
505+
@Nullable
487506
public Object getAttribute(String name) {
488507
Assert.notNull(name, "Attribute name must not be null");
489508
return this.attributes.get(name);
@@ -495,7 +514,7 @@ public Enumeration<String> getAttributeNames() {
495514
}
496515

497516
@Override
498-
public void setAttribute(String name, Object value) {
517+
public void setAttribute(String name, @Nullable Object value) {
499518
Assert.notNull(name, "Attribute name must not be null");
500519
if (value != null) {
501520
this.attributes.put(name, value);
@@ -521,6 +540,7 @@ public String getServletContextName() {
521540
}
522541

523542
@Override
543+
@Nullable
524544
public ClassLoader getClassLoader() {
525545
return ClassUtils.getDefaultClassLoader();
526546
}
@@ -630,6 +650,7 @@ public <T extends Servlet> T createServlet(Class<T> c) throws ServletException {
630650
* @see javax.servlet.ServletContext#getServletRegistration(java.lang.String)
631651
*/
632652
@Override
653+
@Nullable
633654
public ServletRegistration getServletRegistration(String servletName) {
634655
return null;
635656
}
@@ -668,6 +689,7 @@ public <T extends Filter> T createFilter(Class<T> c) throws ServletException {
668689
* @see javax.servlet.ServletContext#getFilterRegistration(java.lang.String)
669690
*/
670691
@Override
692+
@Nullable
671693
public FilterRegistration getFilterRegistration(String filterName) {
672694
return null;
673695
}

0 commit comments

Comments
 (0)