Skip to content

Commit 54db496

Browse files
committed
Polishing
(cherry picked from commit 404e7cd)
1 parent fbe7ddb commit 54db496

File tree

5 files changed

+27
-31
lines changed

5 files changed

+27
-31
lines changed

spring-beans/src/main/java/org/springframework/beans/PropertyValue.java

Lines changed: 2 additions & 2 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.
@@ -145,7 +145,7 @@ public void setOptional(boolean optional) {
145145
}
146146

147147
/**
148-
* Reeurn whether this is an optional value, that is, to be ignored
148+
* Return whether this is an optional value, that is, to be ignored
149149
* when no corresponding property exists on the target class.
150150
* @since 3.0
151151
*/

spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/Reactor2StompCodec.java

Lines changed: 15 additions & 14 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.
@@ -18,14 +18,14 @@
1818

1919
import java.nio.ByteBuffer;
2020

21-
22-
import org.springframework.messaging.Message;
23-
import org.springframework.util.Assert;
2421
import reactor.fn.Consumer;
2522
import reactor.fn.Function;
2623
import reactor.io.buffer.Buffer;
2724
import reactor.io.codec.Codec;
2825

26+
import org.springframework.messaging.Message;
27+
import org.springframework.util.Assert;
28+
2929
/**
3030
* A Reactor TCP {@link Codec} for sending and receiving STOMP messages.
3131
*
@@ -35,25 +35,23 @@
3535
*/
3636
public class Reactor2StompCodec extends Codec<Buffer, Message<byte[]>, Message<byte[]>> {
3737

38-
private final StompDecoder stompDecoder;
39-
40-
private final StompEncoder stompEncoder;
41-
4238
private final Function<Message<byte[]>, Buffer> encodingFunction;
4339

40+
private final StompDecoder stompDecoder;
41+
4442

4543
public Reactor2StompCodec() {
4644
this(new StompEncoder(), new StompDecoder());
4745
}
4846

4947
public Reactor2StompCodec(StompEncoder encoder, StompDecoder decoder) {
50-
Assert.notNull(encoder, "'encoder' is required");
51-
Assert.notNull(decoder, "'decoder' is required");
52-
this.stompEncoder = encoder;
48+
Assert.notNull(encoder, "StompEncoder is required");
49+
Assert.notNull(decoder, "StompDecoder is required");
50+
this.encodingFunction = new EncodingFunction(encoder);
5351
this.stompDecoder = decoder;
54-
this.encodingFunction = new EncodingFunction(this.stompEncoder);
5552
}
5653

54+
5755
@Override
5856
public Function<Buffer, Message<byte[]>> decoder(final Consumer<Message<byte[]>> messageConsumer) {
5957
return new DecodingFunction(this.stompDecoder, messageConsumer);
@@ -66,14 +64,15 @@ public Function<Message<byte[]>, Buffer> encoder() {
6664

6765
@Override
6866
public Buffer apply(Message<byte[]> message) {
69-
return encodingFunction.apply(message);
67+
return this.encodingFunction.apply(message);
7068
}
7169

70+
7271
private static class EncodingFunction implements Function<Message<byte[]>, Buffer> {
7372

7473
private final StompEncoder encoder;
7574

76-
private EncodingFunction(StompEncoder encoder) {
75+
public EncodingFunction(StompEncoder encoder) {
7776
this.encoder = encoder;
7877
}
7978

@@ -84,6 +83,7 @@ public Buffer apply(Message<byte[]> message) {
8483
}
8584
}
8685

86+
8787
private static class DecodingFunction implements Function<Buffer, Message<byte[]>> {
8888

8989
private final StompDecoder decoder;
@@ -103,4 +103,5 @@ public Message<byte[]> apply(Buffer buffer) {
103103
return null;
104104
}
105105
}
106+
106107
}

spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/Reactor2TcpStompClient.java

Lines changed: 3 additions & 3 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.
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.messaging.simp.stomp;
1818

19-
import java.util.Arrays;
19+
import java.util.Collections;
2020
import java.util.List;
2121
import java.util.Properties;
2222

@@ -114,7 +114,7 @@ public ReactorConfiguration read() {
114114
String dispatcherName = "StompClient";
115115
DispatcherType dispatcherType = DispatcherType.DISPATCHER_GROUP;
116116
DispatcherConfiguration config = new DispatcherConfiguration(dispatcherName, dispatcherType, 128, 0);
117-
List<DispatcherConfiguration> configList = Arrays.<DispatcherConfiguration>asList(config);
117+
List<DispatcherConfiguration> configList = Collections.<DispatcherConfiguration>singletonList(config);
118118
return new ReactorConfiguration(configList, dispatcherName, new Properties());
119119
}
120120
}

spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/Reactor2TcpClient.java

Lines changed: 4 additions & 6 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.
@@ -151,15 +151,13 @@ private static NioEventLoopGroup initEventLoopGroup() {
151151
try {
152152
ioThreadCount = Integer.parseInt(System.getProperty("reactor.tcp.ioThreadCount"));
153153
}
154-
catch (Exception ex) {
154+
catch (Throwable ex) {
155155
ioThreadCount = -1;
156156
}
157-
if (ioThreadCount <= 0l) {
157+
if (ioThreadCount <= 0) {
158158
ioThreadCount = Runtime.getRuntime().availableProcessors();
159159
}
160-
161-
return new NioEventLoopGroup(ioThreadCount,
162-
new NamedDaemonThreadFactory("reactor-tcp-io"));
160+
return new NioEventLoopGroup(ioThreadCount, new NamedDaemonThreadFactory("reactor-tcp-io"));
163161
}
164162

165163

spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/Reactor2TcpConnection.java

Lines changed: 3 additions & 6 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.
@@ -29,10 +29,9 @@
2929
* An implementation of {@link org.springframework.messaging.tcp.TcpConnection
3030
* TcpConnection} based on the TCP client support of the Reactor project.
3131
*
32-
* @param <P> the payload type of messages read or written to the TCP stream.
33-
*
3432
* @author Rossen Stoyanchev
3533
* @since 4.2
34+
* @param <P> the payload type of messages read or written to the TCP stream.
3635
*/
3736
public class Reactor2TcpConnection<P> implements TcpConnection<P> {
3837

@@ -41,9 +40,7 @@ public class Reactor2TcpConnection<P> implements TcpConnection<P> {
4140
private final Promise<Void> closePromise;
4241

4342

44-
public Reactor2TcpConnection(ChannelStream<Message<P>, Message<P>> channelStream,
45-
Promise<Void> closePromise) {
46-
43+
public Reactor2TcpConnection(ChannelStream<Message<P>, Message<P>> channelStream, Promise<Void> closePromise) {
4744
this.channelStream = channelStream;
4845
this.closePromise = closePromise;
4946
}

0 commit comments

Comments
 (0)