Skip to content

Commit d4af8c8

Browse files
committed
Polishing
1 parent 39ddd0f commit d4af8c8

File tree

6 files changed

+40
-39
lines changed

6 files changed

+40
-39
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/CannotLoadBeanClassException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class CannotLoadBeanClassException extends FatalBeanException {
4646
public CannotLoadBeanClassException(
4747
String resourceDescription, String beanName, String beanClassName, ClassNotFoundException cause) {
4848

49-
super("Cannot find class [" + String.valueOf(beanClassName) + "] for bean with name '" + beanName + "'" +
49+
super("Cannot find class [" + beanClassName + "] for bean with name '" + beanName + "'" +
5050
(resourceDescription != null ? " defined in " + resourceDescription : ""), cause);
5151
this.resourceDescription = resourceDescription;
5252
this.beanName = beanName;
@@ -64,7 +64,7 @@ public CannotLoadBeanClassException(
6464
public CannotLoadBeanClassException(
6565
String resourceDescription, String beanName, String beanClassName, LinkageError cause) {
6666

67-
super("Error loading class [" + String.valueOf(beanClassName) + "] for bean with name '" + beanName + "'" +
67+
super("Error loading class [" + beanClassName + "] for bean with name '" + beanName + "'" +
6868
(resourceDescription != null ? " defined in " + resourceDescription : "") +
6969
": problem with class file or dependent class", cause);
7070
this.resourceDescription = resourceDescription;

spring-jdbc/src/main/java/org/springframework/jdbc/core/CallableStatementCreatorFactory.java

Lines changed: 2 additions & 1 deletion
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.
@@ -55,6 +55,7 @@ public class CallableStatementCreatorFactory {
5555
/**
5656
* Create a new factory. Will need to add parameters via the
5757
* {@link #addParameter} method or have no parameters.
58+
* @param callString the SQL call string
5859
*/
5960
public CallableStatementCreatorFactory(String callString) {
6061
this.callString = callString;

spring-jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementCreatorFactory.java

Lines changed: 5 additions & 5 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.
@@ -56,14 +56,15 @@ public class PreparedStatementCreatorFactory {
5656

5757
private boolean returnGeneratedKeys = false;
5858

59-
private String[] generatedKeysColumnNames = null;
59+
private String[] generatedKeysColumnNames;
6060

6161
private NativeJdbcExtractor nativeJdbcExtractor;
6262

6363

6464
/**
6565
* Create a new factory. Will need to add parameters via the
6666
* {@link #addParameter} method or have no parameters.
67+
* @param sql the SQL statement to execute
6768
*/
6869
public PreparedStatementCreatorFactory(String sql) {
6970
this.sql = sql;
@@ -72,7 +73,7 @@ public PreparedStatementCreatorFactory(String sql) {
7273

7374
/**
7475
* Create a new factory with the given SQL and JDBC types.
75-
* @param sql SQL to execute
76+
* @param sql the SQL statement to execute
7677
* @param types int array of JDBC types
7778
*/
7879
public PreparedStatementCreatorFactory(String sql, int... types) {
@@ -82,9 +83,8 @@ public PreparedStatementCreatorFactory(String sql, int... types) {
8283

8384
/**
8485
* Create a new factory with the given SQL and parameters.
85-
* @param sql SQL
86+
* @param sql the SQL statement to execute
8687
* @param declaredParameters list of {@link SqlParameter} objects
87-
* @see SqlParameter
8888
*/
8989
public PreparedStatementCreatorFactory(String sql, List<SqlParameter> declaredParameters) {
9090
this.sql = sql;

spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java

Lines changed: 11 additions & 10 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.
@@ -104,8 +104,8 @@ public NamedParameterJdbcTemplate(JdbcOperations classicJdbcTemplate) {
104104

105105

106106
/**
107-
* Expose the classic Spring JdbcTemplate to allow invocation of
108-
* less commonly used methods.
107+
* Expose the classic Spring JdbcTemplate operations to allow invocation
108+
* of less commonly used methods.
109109
*/
110110
@Override
111111
public JdbcOperations getJdbcOperations() {
@@ -329,12 +329,14 @@ public int[] batchUpdate(String sql, SqlParameterSource[] batchArgs) {
329329
getParsedSql(sql), batchArgs, getJdbcOperations());
330330
}
331331

332+
332333
/**
333-
* Build a PreparedStatementCreator based on the given SQL and named parameters.
334-
* <p>Note: Not used for the {@code update} variant with generated key handling.
335-
* @param sql SQL to execute
334+
* Build a {@link PreparedStatementCreator} based on the given SQL and named parameters.
335+
* <p>Note: Directly called from all {@code query} variants.
336+
* Not used for the {@code update} variant with generated key handling.
337+
* @param sql the SQL statement to execute
336338
* @param paramSource container of arguments to bind
337-
* @return the corresponding PreparedStatementCreator
339+
* @return the corresponding {@link PreparedStatementCreator}
338340
*/
339341
protected PreparedStatementCreator getPreparedStatementCreator(String sql, SqlParameterSource paramSource) {
340342
ParsedSql parsedSql = getParsedSql(sql);
@@ -347,9 +349,8 @@ protected PreparedStatementCreator getPreparedStatementCreator(String sql, SqlPa
347349

348350
/**
349351
* Obtain a parsed representation of the given SQL statement.
350-
* <p>The default implementation uses an LRU cache with an upper limit
351-
* of 256 entries.
352-
* @param sql the original SQL
352+
* <p>The default implementation uses an LRU cache with an upper limit of 256 entries.
353+
* @param sql the original SQL statement
353354
* @return a representation of the parsed SQL statement
354355
*/
355356
protected ParsedSql getParsedSql(String sql) {

spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java

Lines changed: 19 additions & 20 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.
@@ -67,7 +67,7 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver {
6767
* @param userRegistry the registry, never {@code null}
6868
*/
6969
public DefaultUserDestinationResolver(SimpUserRegistry userRegistry) {
70-
Assert.notNull(userRegistry, "'userRegistry' must not be null");
70+
Assert.notNull(userRegistry, "SimpUserRegistry must not be null");
7171
this.userRegistry = userRegistry;
7272
}
7373

@@ -86,8 +86,8 @@ public SimpUserRegistry getSimpUserRegistry() {
8686
* @param prefix the prefix to use
8787
*/
8888
public void setUserDestinationPrefix(String prefix) {
89-
Assert.hasText(prefix, "prefix must not be empty");
90-
this.prefix = prefix.endsWith("/") ? prefix : prefix + "/";
89+
Assert.hasText(prefix, "Prefix must not be empty");
90+
this.prefix = (prefix.endsWith("/") ? prefix : prefix + "/");
9191
}
9292

9393
/**
@@ -101,11 +101,11 @@ public String getDestinationPrefix() {
101101
* Use this property to indicate whether the leading slash from translated
102102
* user destinations should be removed or not. This depends on the
103103
* destination prefixes the message broker is configured with.
104-
* <p>By default this is set to {@code false}, i.e. "do not change the
105-
* target destination", although
104+
* <p>By default this is set to {@code false}, i.e.
105+
* "do not change the target destination", although
106106
* {@link org.springframework.messaging.simp.config.AbstractMessageBrokerConfiguration
107-
* AbstractMessageBrokerConfiguration} may change that to {@code true} if
108-
* the configured destinations do not have a leading slash.
107+
* AbstractMessageBrokerConfiguration} may change that to {@code true}
108+
* if the configured destinations do not have a leading slash.
109109
* @param remove whether to remove the leading slash
110110
* @since 4.3.14
111111
*/
@@ -115,6 +115,7 @@ public void setRemoveLeadingSlash(boolean remove) {
115115

116116
/**
117117
* Whether to remove the leading slash from target destinations.
118+
* @since 4.3.14
118119
*/
119120
public boolean isRemoveLeadingSlash() {
120121
return this.removeLeadingSlash;
@@ -198,18 +199,18 @@ private ParseResult parseSubscriptionMessage(Message<?> message, String sourceDe
198199
Principal principal = SimpMessageHeaderAccessor.getUser(headers);
199200
String user = (principal != null ? principal.getName() : null);
200201
Set<String> sessionIds = Collections.singleton(sessionId);
201-
return new ParseResult(sourceDestination, actualDestination, sourceDestination,
202-
sessionIds, user);
202+
return new ParseResult(sourceDestination, actualDestination, sourceDestination, sessionIds, user);
203203
}
204204

205-
private ParseResult parseMessage(MessageHeaders headers, String sourceDestination) {
205+
private ParseResult parseMessage(MessageHeaders headers, String sourceDest) {
206206
int prefixEnd = this.prefix.length();
207-
int userEnd = sourceDestination.indexOf('/', prefixEnd);
207+
int userEnd = sourceDest.indexOf('/', prefixEnd);
208208
Assert.isTrue(userEnd > 0, "Expected destination pattern \"/user/{userId}/**\"");
209-
String actualDestination = sourceDestination.substring(userEnd);
210-
String subscribeDestination = this.prefix.substring(0, prefixEnd - 1) + actualDestination;
211-
String userName = sourceDestination.substring(prefixEnd, userEnd);
209+
String actualDest = sourceDest.substring(userEnd);
210+
String subscribeDest = this.prefix.substring(0, prefixEnd - 1) + actualDest;
211+
String userName = sourceDest.substring(prefixEnd, userEnd);
212212
userName = StringUtils.replace(userName, "%2F", "/");
213+
213214
String sessionId = SimpMessageHeaderAccessor.getSessionId(headers);
214215
Set<String> sessionIds;
215216
if (userName.equals(sessionId)) {
@@ -219,11 +220,11 @@ private ParseResult parseMessage(MessageHeaders headers, String sourceDestinatio
219220
else {
220221
sessionIds = getSessionIdsByUser(userName, sessionId);
221222
}
223+
222224
if (isRemoveLeadingSlash()) {
223-
actualDestination = actualDestination.substring(1);
225+
actualDest = actualDest.substring(1);
224226
}
225-
return new ParseResult(sourceDestination, actualDestination, subscribeDestination,
226-
sessionIds, userName);
227+
return new ParseResult(sourceDest, actualDest, subscribeDest, sessionIds, userName);
227228
}
228229

229230
private Set<String> getSessionIdsByUser(String userName, String sessionId) {
@@ -288,7 +289,6 @@ private static class ParseResult {
288289

289290
private final String user;
290291

291-
292292
public ParseResult(String sourceDest, String actualDest, String subscribeDest,
293293
Set<String> sessionIds, String user) {
294294

@@ -299,7 +299,6 @@ public ParseResult(String sourceDest, String actualDest, String subscribeDest,
299299
this.user = user;
300300
}
301301

302-
303302
public String getSourceDestination() {
304303
return this.sourceDestination;
305304
}

spring-web/src/main/java/org/springframework/web/client/UnknownHttpStatusCodeException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class UnknownHttpStatusCodeException extends RestClientResponseException
4444
public UnknownHttpStatusCodeException(int rawStatusCode, String statusText,
4545
HttpHeaders responseHeaders, byte[] responseBody, Charset responseCharset) {
4646

47-
super("Unknown status code [" + String.valueOf(rawStatusCode) + "]" + " " + statusText,
47+
super("Unknown status code [" + rawStatusCode + "]" + " " + statusText,
4848
rawStatusCode, statusText, responseHeaders, responseBody, responseCharset);
4949
}
5050

0 commit comments

Comments
 (0)