Skip to content

Commit 7275fd2

Browse files
committed
Polishing
1 parent 6e5b873 commit 7275fd2

File tree

4 files changed

+29
-30
lines changed

4 files changed

+29
-30
lines changed

spring-oxm/src/main/java/org/springframework/oxm/xstream/CatchAllConverter.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -23,27 +23,27 @@
2323
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
2424

2525
/**
26-
* XStream {@link Converter} that supports all classes but throws exceptions
27-
* for (un)marshalling.
26+
* XStream {@link Converter} that supports all classes, but throws exceptions for
27+
* (un)marshalling.
2828
*
29-
* <p>Main purpose of this class is to
30-
* {@linkplain com.thoughtworks.xstream.XStream#registerConverter(Converter, int) register}
31-
* this converter as a catch-all converter with a
29+
* <p>The main purpose of this class is to
30+
* {@linkplain com.thoughtworks.xstream.XStream#registerConverter(com.thoughtworks.xstream.converters.Converter, int) register}
31+
* this converter as a catch-all last converter with a
3232
* {@linkplain com.thoughtworks.xstream.XStream#PRIORITY_NORMAL normal}
33-
* or higher priority, in addition to converters that explicitly support the domain
34-
* classes that should be supported. As a result, default XStream converters with lower
35-
* priorities and possible security vulnerabilities do not get invoked.
33+
* or higher priority, in addition to converters that explicitly handle the domain
34+
* classes that should be supported. As a result, default XStream converters with
35+
* lower priorities and possible security vulnerabilities do not get invoked.
3636
*
37-
* <p>For instance:</p>
37+
* <p>For instance:
3838
* <pre class="code">
3939
* XStreamMarshaller unmarshaller = new XStreamMarshaller();
4040
* unmarshaller.getXStream().registerConverter(new MyDomainClassConverter(), XStream.PRIORITY_VERY_HIGH);
4141
* unmarshaller.getXStream().registerConverter(new CatchAllConverter(), XStream.PRIORITY_NORMAL);
42-
* MyDomainClass o = unmarshaller.unmarshal(source);
42+
* MyDomainClass myObject = unmarshaller.unmarshal(source);
4343
* </pre
4444
*
4545
* @author Arjen Poutsma
46-
* @since 4.0
46+
* @since 3.2.5
4747
*/
4848
public class CatchAllConverter implements Converter {
4949

spring-websocket/src/main/java/org/springframework/web/socket/adapter/AbstractWebSocketSession.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@ public abstract class AbstractWebSocketSession<T> implements NativeWebSocketSess
4242

4343
protected static final Log logger = LogFactory.getLog(NativeWebSocketSession.class);
4444

45+
private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
4546

4647
private T nativeSession;
4748

48-
private final Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
49-
5049

5150
/**
5251
* Create a new instance and associate the given attributes with it.
53-
*
5452
* @param attributes attributes from the HTTP handshake to associate with the WebSocket
5553
* session; the provided attributes are copied, the original map is not used.
5654
*/
@@ -83,7 +81,7 @@ public <R> R getNativeSession(Class<R> requiredType) {
8381
}
8482

8583
public void initializeNativeSession(T session) {
86-
Assert.notNull(session, "session must not be null");
84+
Assert.notNull(session, "WebSocket session must not be null");
8785
this.nativeSession = session;
8886
}
8987

@@ -125,6 +123,7 @@ else if (message instanceof PongMessage) {
125123

126124
protected abstract void sendPongMessage(PongMessage message) throws IOException;
127125

126+
128127
@Override
129128
public final void close() throws IOException {
130129
close(CloseStatus.NORMAL);

spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSession.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -62,7 +62,6 @@ public class JettyWebSocketSession extends AbstractWebSocketSession<Session> {
6262

6363
/**
6464
* Create a new {@link JettyWebSocketSession} instance.
65-
*
6665
* @param attributes attributes from the HTTP handshake to associate with the WebSocket session
6766
*/
6867
public JettyWebSocketSession(Map<String, Object> attributes) {
@@ -71,11 +70,10 @@ public JettyWebSocketSession(Map<String, Object> attributes) {
7170

7271
/**
7372
* Create a new {@link JettyWebSocketSession} instance associated with the given user.
74-
*
7573
* @param attributes attributes from the HTTP handshake to associate with the WebSocket
7674
* session; the provided attributes are copied, the original map is not used.
77-
* @param user the user associated with the session; if {@code null} we'll fallback on the user
78-
* available via {@link org.eclipse.jetty.websocket.api.Session#getUpgradeRequest()}
75+
* @param user the user associated with the session; if {@code null} we'll fallback on the
76+
* user available via {@link org.eclipse.jetty.websocket.api.Session#getUpgradeRequest()}
7977
*/
8078
public JettyWebSocketSession(Map<String, Object> attributes, Principal user) {
8179
super(attributes);
@@ -156,9 +154,10 @@ public int getBinaryMessageSizeLimit() {
156154

157155
@Override
158156
public boolean isOpen() {
159-
return ((getNativeSession() != null) && getNativeSession().isOpen());
157+
return (getNativeSession() != null && getNativeSession().isOpen());
160158
}
161159

160+
162161
@Override
163162
public void initializeNativeSession(Session session) {
164163
super.initializeNativeSession(session);

spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -22,7 +22,6 @@
2222
import java.util.ArrayList;
2323
import java.util.List;
2424
import java.util.Map;
25-
2625
import javax.servlet.ServletContext;
2726
import javax.servlet.http.HttpServletRequest;
2827
import javax.servlet.http.HttpServletResponse;
@@ -75,12 +74,12 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life
7574

7675
private final WebSocketServerFactory factory;
7776

78-
private volatile List<WebSocketExtension> supportedExtensions;
79-
8077
private ServletContext servletContext;
8178

8279
private volatile boolean running = false;
8380

81+
private volatile List<WebSocketExtension> supportedExtensions;
82+
8483

8584
/**
8685
* Default constructor that creates {@link WebSocketServerFactory} through
@@ -215,16 +214,18 @@ private static class WebSocketHandlerContainer {
215214

216215
private final List<ExtensionConfig> extensionConfigs;
217216

218-
public WebSocketHandlerContainer(JettyWebSocketHandlerAdapter handler, String protocol, List<WebSocketExtension> extensions) {
217+
public WebSocketHandlerContainer(
218+
JettyWebSocketHandlerAdapter handler, String protocol, List<WebSocketExtension> extensions) {
219+
219220
this.handler = handler;
220221
this.selectedProtocol = protocol;
221222
if (CollectionUtils.isEmpty(extensions)) {
222223
this.extensionConfigs = null;
223224
}
224225
else {
225-
this.extensionConfigs = new ArrayList<ExtensionConfig>();
226-
for (WebSocketExtension e : extensions) {
227-
this.extensionConfigs.add(new WebSocketToJettyExtensionConfigAdapter(e));
226+
this.extensionConfigs = new ArrayList<ExtensionConfig>(extensions.size());
227+
for (WebSocketExtension extension : extensions) {
228+
this.extensionConfigs.add(new WebSocketToJettyExtensionConfigAdapter(extension));
228229
}
229230
}
230231
}

0 commit comments

Comments
 (0)