Skip to content

Commit d72ee80

Browse files
committed
Polishing
(cherry picked from commit b559f15)
1 parent 31a251e commit d72ee80

File tree

2 files changed

+44
-39
lines changed

2 files changed

+44
-39
lines changed

spring-expression/src/main/java/org/springframework/expression/TypedValue.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
import org.springframework.util.ObjectUtils;
2121

2222
/**
23-
* Encapsulates an object and a type descriptor that describes it.
24-
* The type descriptor can hold generic information that would not be
25-
* accessible through a simple {@code getClass()} call on the object.
23+
* Encapsulates an object and a {@link TypeDescriptor} that describes it.
24+
* The type descriptor can contain generic declarations that would not
25+
* be accessible through a simple {@code getClass()} call on the object.
2626
*
2727
* @author Andy Clement
2828
* @author Juergen Hoeller
@@ -39,8 +39,8 @@ public class TypedValue {
3939

4040

4141
/**
42-
* Create a TypedValue for a simple object. The type descriptor is inferred
43-
* from the object, so no generic information is preserved.
42+
* Create a {@link TypedValue} for a simple object. The {@link TypeDescriptor}
43+
* is inferred from the object, so no generic declarations are preserved.
4444
* @param value the object value
4545
*/
4646
public TypedValue(Object value) {
@@ -49,7 +49,8 @@ public TypedValue(Object value) {
4949
}
5050

5151
/**
52-
* Create a TypedValue for a particular value with a particular type descriptor.
52+
* Create a {@link TypedValue} for a particular value with a particular
53+
* {@link TypeDescriptor} which may contain additional generic declarations.
5354
* @param value the object value
5455
* @param typeDescriptor a type descriptor describing the type of the value
5556
*/
@@ -80,9 +81,10 @@ public boolean equals(Object other) {
8081
return false;
8182
}
8283
TypedValue otherTv = (TypedValue) other;
84+
// Avoid TypeDescriptor initialization if not necessary
8385
return (ObjectUtils.nullSafeEquals(this.value, otherTv.value) &&
8486
((this.typeDescriptor == null && otherTv.typeDescriptor == null) ||
85-
getTypeDescriptor().equals(otherTv.getTypeDescriptor())));
87+
ObjectUtils.nullSafeEquals(getTypeDescriptor(), otherTv.getTypeDescriptor())));
8688
}
8789

8890
@Override

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,22 @@ public AbstractSockJsService(TaskScheduler scheduler) {
9090

9191

9292
/**
93-
* A unique name for the service mainly for logging purposes.
93+
* A scheduler instance to use for scheduling heart-beat messages.
94+
*/
95+
public TaskScheduler getTaskScheduler() {
96+
return this.taskScheduler;
97+
}
98+
99+
/**
100+
* Set a unique name for this service (mainly for logging purposes).
94101
*/
95102
public void setName(String name) {
96103
this.name = name;
97104
}
98105

106+
/**
107+
* Return the unique name associated with this service.
108+
*/
99109
public String getName() {
100110
return this.name;
101111
}
@@ -121,8 +131,7 @@ public void setSockJsClientLibraryUrl(String clientLibraryUrl) {
121131
}
122132

123133
/**
124-
* The URL to the SockJS JavaScript client library.
125-
* @see #setSockJsClientLibraryUrl(String)
134+
* Return he URL to the SockJS JavaScript client library.
126135
*/
127136
public String getSockJsClientLibraryUrl() {
128137
return this.clientLibraryUrl;
@@ -132,7 +141,7 @@ public String getSockJsClientLibraryUrl() {
132141
* Streaming transports save responses on the client side and don't free
133142
* memory used by delivered messages. Such transports need to recycle the
134143
* connection once in a while. This property sets a minimum number of bytes
135-
* that can be send over a single HTTP streaming request before it will be
144+
* that can be sent over a single HTTP streaming request before it will be
136145
* closed. After that client will open a new request. Setting this value to
137146
* one effectively disables streaming and will make streaming transports to
138147
* behave like polling transports.
@@ -142,6 +151,10 @@ public void setStreamBytesLimit(int streamBytesLimit) {
142151
this.streamBytesLimit = streamBytesLimit;
143152
}
144153

154+
/**
155+
* Return the minimum number of bytes that can be sent over a single HTTP
156+
* streaming request before it will be closed.
157+
*/
145158
public int getStreamBytesLimit() {
146159
return this.streamBytesLimit;
147160
}
@@ -168,32 +181,28 @@ public void setSessionCookieNeeded(boolean sessionCookieNeeded) {
168181
}
169182

170183
/**
171-
* Whether JSESSIONID cookie is required for the application to function. For
172-
* more detail see {@link #setSessionCookieNeeded(boolean)}.
184+
* Return whether the JSESSIONID cookie is required for the application to function.
173185
*/
174186
public boolean isSessionCookieNeeded() {
175187
return this.sessionCookieNeeded;
176188
}
177189

178190
/**
179-
* The amount of time in milliseconds when the server has not sent any
180-
* messages and after which the server should send a heartbeat frame to the
181-
* client in order to keep the connection from breaking.
191+
* Specify the amount of time in milliseconds when the server has not sent
192+
* any messages and after which the server should send a heartbeat frame
193+
* to the client in order to keep the connection from breaking.
182194
* <p>The default value is 25,000 (25 seconds).
183195
*/
184196
public void setHeartbeatTime(long heartbeatTime) {
185197
this.heartbeatTime = heartbeatTime;
186198
}
187199

188-
public long getHeartbeatTime() {
189-
return this.heartbeatTime;
190-
}
191-
192200
/**
193-
* A scheduler instance to use for scheduling heart-beat messages.
201+
* Return the amount of time in milliseconds when the server has not sent
202+
* any messages.
194203
*/
195-
public TaskScheduler getTaskScheduler() {
196-
return this.taskScheduler;
204+
public long getHeartbeatTime() {
205+
return this.heartbeatTime;
197206
}
198207

199208
/**
@@ -214,12 +223,12 @@ public long getDisconnectDelay() {
214223
}
215224

216225
/**
217-
* The number of server-to-client messages that a session can cache while waiting for
218-
* the next HTTP polling request from the client. All HTTP transports use this
226+
* The number of server-to-client messages that a session can cache while waiting
227+
* for the next HTTP polling request from the client. All HTTP transports use this
219228
* property since even streaming transports recycle HTTP requests periodically.
220-
* <p>The amount of time between HTTP requests should be relatively brief and will not
221-
* exceed the allows disconnect delay (see
222-
* {@link #setDisconnectDelay(long)}), 5 seconds by default.
229+
* <p>The amount of time between HTTP requests should be relatively brief and will
230+
* not exceed the allows disconnect delay (see {@link #setDisconnectDelay(long)});
231+
* 5 seconds by default.
223232
* <p>The default size is 100.
224233
*/
225234
public void setHttpMessageCacheSize(int httpMessageCacheSize) {
@@ -234,7 +243,7 @@ public int getHttpMessageCacheSize() {
234243
}
235244

236245
/**
237-
* Some load balancers don't support WebSocket. This option can be used to
246+
* Some load balancers do not support WebSocket. This option can be used to
238247
* disable the WebSocket transport on the server side.
239248
* <p>The default value is "true".
240249
*/
@@ -243,18 +252,16 @@ public void setWebSocketEnabled(boolean webSocketEnabled) {
243252
}
244253

245254
/**
246-
* Whether WebSocket transport is enabled.
247-
* @see #setWebSocketEnabled(boolean)
255+
* Return whether WebSocket transport is enabled.
248256
*/
249257
public boolean isWebSocketEnabled() {
250258
return this.webSocketEnabled;
251259
}
252260

253261

254262
/**
255-
* {@inheritDoc}
256-
* <p>This method determines the SockJS path and handles SockJS static URLs. Session
257-
* URLs and raw WebSocket requests are delegated to abstract methods.
263+
* This method determines the SockJS path and handles SockJS static URLs.
264+
* Session URLs and raw WebSocket requests are delegated to abstract methods.
258265
*/
259266
@Override
260267
public final void handleRequest(ServerHttpRequest request, ServerHttpResponse response,
@@ -271,7 +278,6 @@ public final void handleRequest(ServerHttpRequest request, ServerHttpResponse re
271278
if (logger.isDebugEnabled()) {
272279
logger.debug(request.getMethod() + " with SockJS path [" + sockJsPath + "]");
273280
}
274-
275281
try {
276282
request.getHeaders();
277283
}
@@ -309,7 +315,6 @@ else if (sockJsPath.equals("/websocket")) {
309315
String serverId = pathSegments[0];
310316
String sessionId = pathSegments[1];
311317
String transport = pathSegments[2];
312-
313318
if (!validateRequest(serverId, sessionId, transport)) {
314319
response.setStatusCode(HttpStatus.NOT_FOUND);
315320
return;
@@ -360,7 +365,6 @@ protected abstract void handleTransportRequest(ServerHttpRequest request, Server
360365
protected void addCorsHeaders(ServerHttpRequest request, ServerHttpResponse response, HttpMethod... httpMethods) {
361366
HttpHeaders requestHeaders = request.getHeaders();
362367
HttpHeaders responseHeaders = response.getHeaders();
363-
364368
try {
365369
// Perhaps a CORS Filter has already added this?
366370
if (!CollectionUtils.isEmpty(responseHeaders.get("Access-Control-Allow-Origin"))) {
@@ -373,8 +377,7 @@ protected void addCorsHeaders(ServerHttpRequest request, ServerHttpResponse resp
373377
}
374378

375379
String origin = requestHeaders.getFirst("origin");
376-
origin = ((origin == null) || origin.equals("null")) ? "*" : origin;
377-
380+
origin = (origin == null || origin.equals("null") ? "*" : origin);
378381
responseHeaders.add("Access-Control-Allow-Origin", origin);
379382
responseHeaders.add("Access-Control-Allow-Credentials", "true");
380383

0 commit comments

Comments
 (0)