Skip to content

Commit 26378cd

Browse files
committed
Polishing
1 parent d554229 commit 26378cd

File tree

6 files changed

+46
-41
lines changed

6 files changed

+46
-41
lines changed

spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java

Lines changed: 5 additions & 5 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.
@@ -398,7 +398,7 @@ protected static int calculateShift(int minimumValue, int maximumValue) {
398398
/**
399399
* Various reference types supported by this map.
400400
*/
401-
public static enum ReferenceType {
401+
public enum ReferenceType {
402402

403403
/** Use {@link SoftReference}s */
404404
SOFT,
@@ -636,7 +636,7 @@ public final int getCount() {
636636
* A reference to an {@link Entry} contained in the map. Implementations are usually
637637
* wrappers around specific Java reference implementations (e.g., {@link SoftReference}).
638638
*/
639-
protected static interface Reference<K, V> {
639+
protected interface Reference<K, V> {
640640

641641
/**
642642
* Returns the referenced entry or {@code null} if the entry is no longer
@@ -765,7 +765,7 @@ protected T execute(Reference<K, V> reference, Entry<K, V> entry) {
765765
/**
766766
* Various options supported by a {@code Task}.
767767
*/
768-
private static enum TaskOption {
768+
private enum TaskOption {
769769

770770
RESTRUCTURE_BEFORE, RESTRUCTURE_AFTER, SKIP_IF_EMPTY, RESIZE
771771
}
@@ -912,7 +912,7 @@ public void remove() {
912912
/**
913913
* The types of restructuring that can be performed.
914914
*/
915-
protected static enum Restructure {
915+
protected enum Restructure {
916916

917917
WHEN_NECESSARY, NEVER
918918
}

spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistry.java

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.apache.commons.logging.Log;
2727
import org.apache.commons.logging.LogFactory;
2828

29-
import org.springframework.beans.BeansException;
3029
import org.springframework.beans.factory.BeanInitializationException;
3130
import org.springframework.beans.factory.DisposableBean;
3231
import org.springframework.beans.factory.InitializingBean;
@@ -72,11 +71,19 @@ public class JmsListenerEndpointRegistry implements DisposableBean, SmartLifecyc
7271

7372
private boolean contextRefreshed;
7473

74+
7575
@Override
76-
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
76+
public void setApplicationContext(ApplicationContext applicationContext) {
7777
this.applicationContext = applicationContext;
7878
}
7979

80+
@Override
81+
public void onApplicationEvent(ContextRefreshedEvent event) {
82+
if (event.getApplicationContext() == this.applicationContext) {
83+
this.contextRefreshed = true;
84+
}
85+
}
86+
8087

8188
/**
8289
* Return the {@link MessageListenerContainer} with the specified id or
@@ -107,7 +114,6 @@ public Collection<MessageListenerContainer> getListenerContainers() {
107114
return Collections.unmodifiableCollection(this.listenerContainers.values());
108115
}
109116

110-
111117
/**
112118
* Create a message listener container for the given {@link JmsListenerEndpoint}.
113119
* <p>This create the necessary infrastructure to honor that endpoint
@@ -129,8 +135,9 @@ public void registerListenerContainer(JmsListenerEndpoint endpoint, JmsListenerC
129135
String id = endpoint.getId();
130136
Assert.notNull(id, "Endpoint id must not be null");
131137
synchronized (this.listenerContainers) {
132-
Assert.state(!this.listenerContainers.containsKey(id),
133-
"Another endpoint is already registered with id '" + id + "'");
138+
if (this.listenerContainers.containsKey(id)) {
139+
throw new IllegalStateException("Another endpoint is already registered with id '" + id + "'");
140+
}
134141
MessageListenerContainer container = createListenerContainer(endpoint, factory);
135142
this.listenerContainers.put(id, container);
136143
if (startImmediately) {
@@ -181,28 +188,6 @@ protected MessageListenerContainer createListenerContainer(JmsListenerEndpoint e
181188
}
182189

183190

184-
@Override
185-
public void destroy() {
186-
for (MessageListenerContainer listenerContainer : getListenerContainers()) {
187-
if (listenerContainer instanceof DisposableBean) {
188-
try {
189-
((DisposableBean) listenerContainer).destroy();
190-
}
191-
catch (Throwable ex) {
192-
logger.warn("Failed to destroy message listener container", ex);
193-
}
194-
}
195-
}
196-
}
197-
198-
199-
@Override
200-
public void onApplicationEvent(ContextRefreshedEvent event) {
201-
if (event.getApplicationContext().equals(this.applicationContext)) {
202-
this.contextRefreshed = true;
203-
}
204-
}
205-
206191
// Delegating implementation of SmartLifecycle
207192

208193
@Override
@@ -259,6 +244,20 @@ private void startIfNecessary(MessageListenerContainer listenerContainer) {
259244
}
260245
}
261246

247+
@Override
248+
public void destroy() {
249+
for (MessageListenerContainer listenerContainer : getListenerContainers()) {
250+
if (listenerContainer instanceof DisposableBean) {
251+
try {
252+
((DisposableBean) listenerContainer).destroy();
253+
}
254+
catch (Throwable ex) {
255+
logger.warn("Failed to destroy message listener container", ex);
256+
}
257+
}
258+
}
259+
}
260+
262261

263262
private static class AggregatingCallback implements Runnable {
264263

spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public void composedJmsListeners() {
187187
@SuppressWarnings("resource")
188188
public void unknownFactory() {
189189
thrown.expect(BeanCreationException.class);
190-
thrown.expectMessage("customFactory"); // Not found
190+
thrown.expectMessage("customFactory"); // not found
191191
new AnnotationConfigApplicationContext(EnableJmsSampleConfig.class, CustomBean.class);
192192
}
193193

@@ -199,11 +199,11 @@ public void lazyComponent() {
199199
context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
200200
assertEquals(0, defaultFactory.getListenerContainers().size());
201201

202-
context.getBean(LazyBean.class); // trigger lazy resolution
202+
context.getBean(LazyBean.class); // trigger lazy resolution
203203
assertEquals(1, defaultFactory.getListenerContainers().size());
204204
MessageListenerTestContainer container = defaultFactory.getListenerContainers().get(0);
205205
assertTrue("Should have been started " + container, container.isStarted());
206-
context.close(); // Close and stop the listeners
206+
context.close(); // close and stop the listeners
207207
assertTrue("Should have been stopped " + container, container.isStopped());
208208
}
209209

@@ -339,6 +339,7 @@ public JmsListenerContainerTestFactory defaultFactory() {
339339
}
340340
}
341341

342+
342343
@Configuration
343344
@EnableJms
344345
static class EnableJmsAutoStartupFalseConfig implements JmsListenerConfigurer {
@@ -378,6 +379,7 @@ public void handle(String msg) {
378379
String concurrency() default "";
379380
}
380381

382+
381383
@JmsListener(destination = "billingQueue")
382384
@Retention(RetentionPolicy.RUNTIME)
383385
private @interface BillingQueueListener {
@@ -389,6 +391,7 @@ public void handle(String msg) {
389391
String concurrency() default "";
390392
}
391393

394+
392395
@Component
393396
static class ComposedJmsListenersBean {
394397

spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerTestFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ public class JmsListenerContainerTestFactory implements JmsListenerContainerFact
3131
private final Map<String, MessageListenerTestContainer> listenerContainers =
3232
new LinkedHashMap<>();
3333

34+
3435
public void setAutoStartup(boolean autoStartup) {
3536
this.autoStartup = autoStartup;
3637
}
3738

39+
3840
public List<MessageListenerTestContainer> getListenerContainers() {
3941
return new ArrayList<>(this.listenerContainers.values());
4042
}

spring-jms/src/test/java/org/springframework/jms/config/MessageListenerTestContainer.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
/**
2727
* @author Stephane Nicoll
2828
*/
29-
public class MessageListenerTestContainer
30-
implements MessageListenerContainer, InitializingBean, DisposableBean {
29+
public class MessageListenerTestContainer implements MessageListenerContainer, InitializingBean, DisposableBean {
3130

3231
private final JmsListenerEndpoint endpoint;
3332

@@ -41,10 +40,12 @@ public class MessageListenerTestContainer
4140

4241
private boolean destroyInvoked;
4342

43+
4444
MessageListenerTestContainer(JmsListenerEndpoint endpoint) {
4545
this.endpoint = endpoint;
4646
}
4747

48+
4849
public void setAutoStartup(boolean autoStartup) {
4950
this.autoStartup = autoStartup;
5051
}
@@ -133,8 +134,7 @@ public void afterPropertiesSet() {
133134
@Override
134135
public void destroy() {
135136
if (!stopInvoked) {
136-
throw new IllegalStateException("Stop should have been invoked before " +
137-
"destroy on " + this);
137+
throw new IllegalStateException("Stop should have been invoked before " + "destroy on " + this);
138138
}
139139
destroyInvoked = true;
140140
}
@@ -150,4 +150,5 @@ public String toString() {
150150
sb.append('}');
151151
return sb.toString();
152152
}
153+
153154
}

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.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.
@@ -132,7 +132,7 @@ public void setMessageCodec(SockJsMessageCodec messageCodec) {
132132

133133
public SockJsMessageCodec getMessageCodec() {
134134
Assert.state(this.messageCodec != null, "A SockJsMessageCodec is required but not available: " +
135-
"Add Jackson 2 to the classpath, or configure a custom SockJsMessageCodec.");
135+
"Add Jackson to the classpath, or configure a custom SockJsMessageCodec.");
136136
return this.messageCodec;
137137
}
138138

0 commit comments

Comments
 (0)