You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/10/12 16:02:03 UTC
[commons-lang] branch master updated (26becc120 -> 8b34dab44)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
from 26becc120 Javadoc
new 152c7204a Fix XML
new bc4eeca21 Fix description
new 8b34dab44 Add LazyInitializer.isInitialized()
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/changes/changes.xml | 5 +++--
.../apache/commons/lang3/concurrent/LazyInitializer.java | 12 ++++++++++++
.../lang3/concurrent/LazyInitializerAnonClassTest.java | 15 ++++++++++++++-
.../lang3/concurrent/LazyInitializerSimpleTest.java | 15 ++++++++++++++-
.../concurrent/LazyInitializerSingleInstanceTest.java | 14 +++++++++++++-
5 files changed, 56 insertions(+), 5 deletions(-)
[commons-lang] 03/03: Add LazyInitializer.isInitialized()
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit 8b34dab449dbe5eb99475262adea3de28b8c8d1e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 12 12:01:56 2023 -0400
Add LazyInitializer.isInitialized()
---
src/changes/changes.xml | 1 +
.../apache/commons/lang3/concurrent/LazyInitializer.java | 12 ++++++++++++
.../lang3/concurrent/LazyInitializerAnonClassTest.java | 15 ++++++++++++++-
.../lang3/concurrent/LazyInitializerSimpleTest.java | 15 ++++++++++++++-
.../concurrent/LazyInitializerSingleInstanceTest.java | 14 +++++++++++++-
5 files changed, 54 insertions(+), 3 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ec8bad762..0e7820796 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -69,6 +69,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="add" dev="ggregory" due-to="Gary Gregory">Add FastDateParser.TimeZoneStrategy.TzInfo.toString().</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add LocaleUtils.isLanguageUndetermined(Locale).</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add ObjectUtils.toString(Supplier<Object>, Supplier<String>).</action>
+ <action type="add" dev="ggregory" due-to="Gary Gregory">Add LazyInitializer.isInitialized().</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-parent from 58 to 64.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump org.easymock:easymock from 5.1.0 to 5.2.0 #1104.</action>
diff --git a/src/main/java/org/apache/commons/lang3/concurrent/LazyInitializer.java b/src/main/java/org/apache/commons/lang3/concurrent/LazyInitializer.java
index 5435910d7..0f25656df 100644
--- a/src/main/java/org/apache/commons/lang3/concurrent/LazyInitializer.java
+++ b/src/main/java/org/apache/commons/lang3/concurrent/LazyInitializer.java
@@ -121,4 +121,16 @@ public abstract class LazyInitializer<T> implements ConcurrentInitializer<T> {
* @throws ConcurrentException if an error occurs during object creation
*/
protected abstract T initialize() throws ConcurrentException;
+
+ /**
+ * Tests whether this instance is initialized. Once initialized, always returns true.
+ *
+ * @return whether this instance is initialized. Once initialized, always returns true.
+ * @since 3.14.0
+ */
+ public boolean isInitialized() {
+ return object != NO_INIT;
+ }
+
+
}
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/LazyInitializerAnonClassTest.java b/src/test/java/org/apache/commons/lang3/concurrent/LazyInitializerAnonClassTest.java
index 65d4373af..5bca50af4 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/LazyInitializerAnonClassTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/LazyInitializerAnonClassTest.java
@@ -16,6 +16,11 @@
*/
package org.apache.commons.lang3.concurrent;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
/**
* Tests {@code LazyInitializer}.
*/
@@ -27,7 +32,7 @@ public class LazyInitializerAnonClassTest extends AbstractConcurrentInitializerT
* @return the initializer to be tested
*/
@Override
- protected ConcurrentInitializer<Object> createInitializer() {
+ protected LazyInitializer<Object> createInitializer() {
return new LazyInitializer<Object>() {
@Override
protected Object initialize() {
@@ -36,4 +41,12 @@ public class LazyInitializerAnonClassTest extends AbstractConcurrentInitializerT
};
}
+ @Test
+ public void testIsInitialized() throws ConcurrentException {
+ final LazyInitializer<Object> initializer = createInitializer();
+ assertFalse(initializer.isInitialized());
+ initializer.get();
+ assertTrue(initializer.isInitialized());
+ }
+
}
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/LazyInitializerSimpleTest.java b/src/test/java/org/apache/commons/lang3/concurrent/LazyInitializerSimpleTest.java
index 904b72ffe..8eba8dfe3 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/LazyInitializerSimpleTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/LazyInitializerSimpleTest.java
@@ -16,6 +16,11 @@
*/
package org.apache.commons.lang3.concurrent;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
/**
* Tests {@code LazyInitializer}.
*/
@@ -38,8 +43,16 @@ public class LazyInitializerSimpleTest extends AbstractConcurrentInitializerTest
* @return the initializer to be tested
*/
@Override
- protected ConcurrentInitializer<Object> createInitializer() {
+ protected LazyInitializer<Object> createInitializer() {
return new LazyInitializerTestImpl();
}
+ @Test
+ public void testIsInitialized() throws ConcurrentException {
+ final LazyInitializer<Object> initializer = createInitializer();
+ assertFalse(initializer.isInitialized());
+ initializer.get();
+ assertTrue(initializer.isInitialized());
+ }
+
}
diff --git a/src/test/java/org/apache/commons/lang3/concurrent/LazyInitializerSingleInstanceTest.java b/src/test/java/org/apache/commons/lang3/concurrent/LazyInitializerSingleInstanceTest.java
index cde1e91f3..9ba08c248 100644
--- a/src/test/java/org/apache/commons/lang3/concurrent/LazyInitializerSingleInstanceTest.java
+++ b/src/test/java/org/apache/commons/lang3/concurrent/LazyInitializerSingleInstanceTest.java
@@ -16,7 +16,11 @@
*/
package org.apache.commons.lang3.concurrent;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Tests {@code LazyInitializer}.
@@ -43,10 +47,18 @@ public class LazyInitializerSingleInstanceTest extends AbstractConcurrentInitial
* @return the initializer to be tested
*/
@Override
- protected ConcurrentInitializer<Object> createInitializer() {
+ protected LazyInitializer<Object> createInitializer() {
return initializer;
}
+ @Test
+ public void testIsInitialized() throws ConcurrentException {
+ final LazyInitializer<Object> initializer = createInitializer();
+ assertFalse(initializer.isInitialized());
+ initializer.get();
+ assertTrue(initializer.isInitialized());
+ }
+
@BeforeEach
public void setUp() {
initializer = new LazyInitializerTestImpl();
[commons-lang] 01/03: Fix XML
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit 152c7204a0a9f88db0255815a7d3e300604abf74
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 12 11:09:07 2023 -0400
Fix XML
---
src/changes/changes.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 83bbc1799..c1f840548 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -58,7 +58,7 @@ The <action> type attribute can be add,update,fix,remove.
<action issue="LANG-1710" type="fix" dev="ggregory" due-to="Shashank Sharma, Gary Gregory, Oksana">ReflectionToStringBuilder changes in version 3.13.0 has broken the logic for overriding classes.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Return "null" instead of NPE in ClassLoaderUtils.toString(ClassLoader).</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Return "null" instead of NPE in ClassLoaderUtils.toString(URLClassLoader).</action>
- <action type="fix" dev="ggregory" due-to="Gary Gregory">Return ToStringStyle.nullText instead of NPE for ReflectionToStringBuilder.toStrin>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">Return ToStringStyle.nullText instead of NPE for ReflectionToStringBuilder.toString().</action>
<action type="fix" dev="ggregory" due-to="yichinzhu, Gary Gregory">Fix ThresholdCircuitBreaker#checkState() #1100.</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Rob Spoor, Gary Gregory">Add Functions#function(Function).</action>
[commons-lang] 02/03: Fix description
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit bc4eeca21b2f917a623da5fe5283dfc852b6e818
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Oct 12 11:09:40 2023 -0400
Fix description
---
src/changes/changes.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c1f840548..ec8bad762 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -68,7 +68,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="add" dev="ggregory" due-to="Gary Gregory">Add ArrayFill.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add FastDateParser.TimeZoneStrategy.TzInfo.toString().</action>
<action type="add" dev="ggregory" due-to="Gary Gregory">Add LocaleUtils.isLanguageUndetermined(Locale).</action>
- <action type="add" dev="ggregory" due-to="Gary Gregory">Add Add ObjectUtils.toString(Supplier<Object>, Supplier<String>).</action>
+ <action type="add" dev="ggregory" due-to="Gary Gregory">Add ObjectUtils.toString(Supplier<Object>, Supplier<String>).</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-parent from 58 to 64.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump org.easymock:easymock from 5.1.0 to 5.2.0 #1104.</action>