Skip to content

Commit 42e550a

Browse files
committed
Polishing
1 parent 1b78afe commit 42e550a

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/AbstractFactoryBean.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 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.
@@ -33,6 +33,7 @@
3333
import org.springframework.beans.factory.FactoryBean;
3434
import org.springframework.beans.factory.FactoryBeanNotInitializedException;
3535
import org.springframework.beans.factory.InitializingBean;
36+
import org.springframework.util.Assert;
3637
import org.springframework.util.ClassUtils;
3738
import org.springframework.util.ObjectUtils;
3839
import org.springframework.util.ReflectionUtils;
@@ -153,7 +154,7 @@ public final T getObject() throws Exception {
153154
}
154155

155156
/**
156-
* Determine an 'eager singleton' instance, exposed in case of a
157+
* Determine an 'early singleton' instance, exposed in case of a
157158
* circular reference. Not called in a non-circular scenario.
158159
*/
159160
@SuppressWarnings("unchecked")
@@ -176,9 +177,7 @@ private T getEarlySingletonInstance() throws Exception {
176177
* @throws IllegalStateException if the singleton instance is not initialized
177178
*/
178179
private T getSingletonInstance() throws IllegalStateException {
179-
if (!this.initialized) {
180-
throw new IllegalStateException("Singleton instance not initialized yet");
181-
}
180+
Assert.state(this.initialized, "Singleton instance not initialized yet");
182181
return this.singletonInstance;
183182
}
184183

@@ -218,7 +217,7 @@ public void destroy() throws Exception {
218217
* FactoryBean is supposed to implement, for use with an 'early singleton
219218
* proxy' that will be exposed in case of a circular reference.
220219
* <p>The default implementation returns this FactoryBean's object type,
221-
* provided that it is an interface, or {@code null} else. The latter
220+
* provided that it is an interface, or {@code null} otherwise. The latter
222221
* indicates that early singleton access is not supported by this FactoryBean.
223222
* This will lead to a FactoryBeanNotInitializedException getting thrown.
224223
* @return the interfaces to use for 'early singletons',

src/asciidoc/core-beans.adoc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8360,12 +8360,12 @@ simple class that extends Spring's `ApplicationEvent` base class:
83608360
public class BlackListEvent extends ApplicationEvent {
83618361
83628362
private final String address;
8363-
private final String test;
8363+
private final String content;
83648364
8365-
public BlackListEvent(Object source, String address, String test) {
8365+
public BlackListEvent(Object source, String address, String content) {
83668366
super(source);
83678367
this.address = address;
8368-
this.test = test;
8368+
this.content = content;
83698369
}
83708370
83718371
// accessor and other methods...
@@ -8393,10 +8393,9 @@ example demonstrates such a class:
83938393
this.publisher = publisher;
83948394
}
83958395
8396-
public void sendEmail(String address, String text) {
8396+
public void sendEmail(String address, String content) {
83978397
if (blackList.contains(address)) {
8398-
BlackListEvent event = new BlackListEvent(this, address, text);
8399-
publisher.publishEvent(event);
8398+
publisher.publishEvent(new BlackListEvent(this, address, content));
84008399
return;
84018400
}
84028401
// send email...

0 commit comments

Comments
 (0)