Skip to content

Commit 45b0198

Browse files
chore: merge main into release [skip ci]
2 parents e45a223 + 24d04d7 commit 45b0198

18 files changed

Lines changed: 40 additions & 24 deletions

microsphere-java-core/src/main/java/io/microsphere/classloading/ArtifactDetector.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import static io.microsphere.util.SystemUtils.JAVA_HOME;
2626
import static java.util.Collections.emptyList;
2727
import static java.util.Collections.unmodifiableList;
28+
import static io.microsphere.collection.SetUtils.newLinkedHashSet;
2829

2930
/**
3031
* The {@code ArtifactDetector} class is responsible for detecting and resolving artifacts from the classpath.
@@ -149,7 +150,7 @@ public Artifact detect(@Nonnull URL classPathURL) {
149150

150151
protected Set<URL> getClassPathURLs(boolean includedJdkLibraries) {
151152
Set<URL> urls = findAllClassPathURLs(classLoader);
152-
LinkedHashSet<URL> classPathURLs = new LinkedHashSet<>(urls);
153+
LinkedHashSet<URL> classPathURLs = newLinkedHashSet(urls);
153154
if (!includedJdkLibraries) {
154155
removeJdkClassPathURLs(classPathURLs);
155156
}

microsphere-java-core/src/main/java/io/microsphere/classloading/BannedArtifactClassLoadingExecutor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static io.microsphere.util.StringUtils.isBlank;
1919
import static io.microsphere.util.StringUtils.split;
2020
import static io.microsphere.util.SystemUtils.FILE_ENCODING;
21+
import static io.microsphere.collection.ListUtils.newLinkedList;
2122

2223
/**
2324
* The executor for the banned artifacts that are loading by {@link ClassLoader}.
@@ -94,7 +95,7 @@ public void execute() {
9495
}
9596

9697
static List<MavenArtifact> loadBannedArtifactConfigs(ClassLoader classLoader) {
97-
LinkedList<MavenArtifact> bannedArtifactConfigs = new LinkedList<>();
98+
LinkedList<MavenArtifact> bannedArtifactConfigs = newLinkedList();
9899
try {
99100
Enumeration<URL> configResources = classLoader.getResources(CONFIG_LOCATION);
100101
while (configResources.hasMoreElements()) {
@@ -109,7 +110,7 @@ static List<MavenArtifact> loadBannedArtifactConfigs(ClassLoader classLoader) {
109110
}
110111

111112
static List<MavenArtifact> loadBannedArtifactConfigs(URL configResource) throws IOException {
112-
LinkedList<MavenArtifact> bannedArtifactConfigs = new LinkedList<>();
113+
LinkedList<MavenArtifact> bannedArtifactConfigs = newLinkedList();
113114
try (InputStream inputStream = configResource.openStream();
114115
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, ENCODING))
115116
) {

microsphere-java-core/src/main/java/io/microsphere/event/AbstractEventDispatcher.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import static io.microsphere.util.ServiceLoaderUtils.loadServicesList;
4141
import static java.util.Collections.sort;
4242
import static java.util.Collections.unmodifiableList;
43+
import static io.microsphere.collection.ListUtils.newLinkedList;
4344

4445
/**
4546
* Abstract implementation of {@link EventDispatcher} that provides common functionality for dispatching events to
@@ -127,7 +128,7 @@ public void removeEventListener(EventListener<?> listener) throws NullPointerExc
127128
@Override
128129
@Immutable
129130
public List<EventListener<?>> getAllEventListeners() {
130-
LinkedList<EventListener<?>> listeners = new LinkedList<>();
131+
LinkedList<EventListener<?>> listeners = newLinkedList();
131132

132133
sortedListeners().forEach(listener -> {
133134
addIfAbsent(listeners, listener);
@@ -192,7 +193,7 @@ protected void doInListener(EventListener<?> listener, Consumer<Collection<Event
192193
void doInListener(Class<? extends Event> eventType, Consumer<Collection<EventListener>> consumer) {
193194
if (eventType != null) {
194195
synchronized (mutex) {
195-
List<EventListener> listeners = listenersCache.computeIfAbsent(eventType, e -> new LinkedList<>());
196+
List<EventListener> listeners = listenersCache.computeIfAbsent(eventType, e -> newLinkedList());
196197
// consume
197198
consumer.accept(listeners);
198199
// sort

microsphere-java-core/src/main/java/io/microsphere/event/GenericEventListener.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import static io.microsphere.lang.function.ThrowableConsumer.execute;
3030
import static java.util.Collections.emptySet;
3131
import static java.util.stream.Stream.of;
32+
import static io.microsphere.collection.SetUtils.newLinkedHashSet;
3233

3334
/**
3435
* A generic implementation of the {@link EventListener} interface that supports multiple event handling methods.
@@ -97,7 +98,7 @@ private Map<Class<?>, Set<Method>> findHandleEventMethods() {
9798
HashMap<Class<?>, Set<Method>> eventMethods = newHashMap();
9899
of(getClass().getMethods()).filter(this::isHandleEventMethod).forEach(method -> {
99100
Class<?> paramType = method.getParameterTypes()[0];
100-
Set<Method> methods = eventMethods.computeIfAbsent(paramType, key -> new LinkedHashSet<>());
101+
Set<Method> methods = eventMethods.computeIfAbsent(paramType, key -> newLinkedHashSet());
101102
methods.add(method);
102103
});
103104
return eventMethods;

microsphere-java-core/src/main/java/io/microsphere/event/Listenable.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import static io.microsphere.util.ClassUtils.getTypeName;
2828
import static java.lang.reflect.Modifier.isFinal;
2929
import static java.util.stream.StreamSupport.stream;
30+
import static io.microsphere.collection.ListUtils.newArrayList;
3031

3132
/**
3233
* A component that allows registration and management of {@link EventListener} instances.
@@ -111,7 +112,7 @@ static void assertListener(EventListener<?> listener) throws IllegalArgumentExce
111112
*/
112113
default void addEventListeners(E listener, E... others) throws NullPointerException,
113114
IllegalArgumentException {
114-
ArrayList<E> listeners = new ArrayList<>(1 + others.length);
115+
ArrayList<E> listeners = newArrayList(1 + others.length);
115116
listeners.add(listener);
116117
addAll(listeners, others);
117118
addEventListeners(listeners);

microsphere-java-core/src/main/java/io/microsphere/filter/FilterUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.List;
1313

1414
import static java.util.Collections.unmodifiableList;
15+
import static io.microsphere.collection.ListUtils.newArrayList;
1516

1617
/**
1718
* Utility class for working with {@link Filter} instances.
@@ -74,7 +75,7 @@ public static <E> List<E> filter(Iterable<E> iterable, Filter<E> filter) {
7475
@Nonnull
7576
@Immutable
7677
public static <E> List<E> filter(Iterable<E> iterable, FilterOperator filterOperator, Filter<E>... filters) {
77-
ArrayList<E> list = new ArrayList<E>();
78+
ArrayList<E> list = newArrayList();
7879
Iterator<E> iterator = iterable.iterator();
7980
while (iterator.hasNext()) {
8081
E element = iterator.next();

microsphere-java-core/src/main/java/io/microsphere/io/StandardFileWatchService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
6464
import static java.util.concurrent.Executors.newSingleThreadExecutor;
6565
import static java.util.concurrent.TimeUnit.MILLISECONDS;
66+
import static io.microsphere.collection.SetUtils.newTreeSet;
6667

6768
/**
6869
* /**
@@ -330,7 +331,7 @@ static Kind toKind(WatchEvent.Kind<?> watchEventKind) {
330331

331332
private static class FileChangedMetadata {
332333

333-
private final Set<Path> filePaths = new TreeSet<>();
334+
private final Set<Path> filePaths = newTreeSet();
334335

335336
private EventDispatcher eventDispatcher;
336337

microsphere-java-core/src/main/java/io/microsphere/json/JSONArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class JSONArray {
8282
* Creates a {@code JSONArray} with no values.
8383
*/
8484
public JSONArray() {
85-
this.values = new ArrayList<>();
85+
this.values = newArrayList();
8686
}
8787

8888
@SuppressWarnings("rawtypes")

microsphere-java-core/src/main/java/io/microsphere/json/JSONObject.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import static io.microsphere.util.ClassUtils.isEnum;
4444
import static io.microsphere.util.ClassUtils.isNumber;
4545
import static io.microsphere.util.ClassUtils.isWrapperType;
46+
import static io.microsphere.collection.ListUtils.newArrayList;
4647

4748
/**
4849
* A modifiable set of name/value mappings. Names are unique, non-null strings. Values may
@@ -730,7 +731,7 @@ public Iterator<String> keys() {
730731
* @return the array
731732
*/
732733
public JSONArray names() {
733-
return this.nameValuePairs.isEmpty() ? null : new JSONArray(new ArrayList<>(this.nameValuePairs.keySet()));
734+
return this.nameValuePairs.isEmpty() ? null : new JSONArray(newArrayList(this.nameValuePairs.keySet()));
734735
}
735736

736737
/**

microsphere-java-core/src/main/java/io/microsphere/json/JSONStringer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import static io.microsphere.util.ClassUtils.getTypeName;
3030
import static java.lang.String.format;
3131
import static java.util.Arrays.fill;
32+
import static io.microsphere.collection.ListUtils.newArrayList;
3233

3334
/**
3435
* Implements {@link JSONObject#toString} and {@link JSONArray#toString}. Most application
@@ -121,7 +122,7 @@ enum Scope {
121122
* Unlike the original implementation, this stack isn't limited to 20 levels of
122123
* nesting.
123124
*/
124-
private final List<Scope> stack = new ArrayList<>();
125+
private final List<Scope> stack = newArrayList();
125126

126127
/**
127128
* A string containing a full set of spaces for a single level of indentation, or null

0 commit comments

Comments
 (0)