Skip to content

Commit 6a03d44

Browse files
huanmeng-qwqCarmJos
authored andcommitted
1 parent 4a0e6b0 commit 6a03d44

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

core/src/main/java/cc/carm/lib/configuration/adapter/ValueAdapterRegistry.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ public void unregister(@NotNull ValueType<?> type) {
8888

8989
@SuppressWarnings("unchecked")
9090
public <T> @Nullable ValueAdapter<T> adapterOf(@NotNull ValueType<T> type) {
91-
ValueAdapter<?> cached = adapterCache.get(type);
92-
if (cached != null) return (ValueAdapter<T>) cached;
91+
if (adapterCache.containsKey(type)) {
92+
return (ValueAdapter<T>) adapterCache.get(type);
93+
}
9394

9495
for (ValueAdapter<?> adapter : adapters) {
9596
if (adapter.type().equals(type)) {
@@ -154,11 +155,14 @@ private <T> T deserializeWithoutAdapter(@NotNull ConfigurationHolder<?> holder,
154155

155156
private <T> T deserializeArray(@NotNull ConfigurationHolder<?> holder, @NotNull ValueType<T> type,
156157
@NotNull Object source, @NotNull Class<?> rawType) throws Exception {
157-
if (!(source instanceof List<?>)) {
158-
source = deserializeList(holder, type, source);
158+
List<?> list;
159+
if (source instanceof List<?>) {
160+
list = (List<?>) source;
161+
} else {
162+
// For non-list sources, treat as single element array
163+
list = Collections.singletonList(source);
159164
}
160165

161-
List<?> list = (List<?>) source;
162166
int size = list.size();
163167
if (size == 0) {
164168
return type.cast(Array.newInstance(rawType.getComponentType(), 0));

0 commit comments

Comments
 (0)