Validation fixes

This commit is contained in:
crschnick 2024-09-22 14:30:01 +00:00
parent 39f32af927
commit acb2583100
4 changed files with 12 additions and 10 deletions

View file

@ -15,7 +15,7 @@ public class ConnectionRefreshExchangeImpl extends ConnectionRefreshExchange {
.getStoreEntryIfPresent(msg.getConnection())
.orElseThrow(() -> new BeaconClientException("Unknown connection: " + msg.getConnection()));
if (e.getStore() instanceof FixedHierarchyStore) {
DataStorage.get().refreshChildren(e, true);
DataStorage.get().refreshChildren(e, null, true);
} else {
e.validateOrThrowAndClose(null);
}

View file

@ -216,7 +216,7 @@ public class StoreEntryWrapper {
}
public void refreshChildren() {
var hasChildren = DataStorage.get().refreshChildren(entry);
var hasChildren = DataStorage.get().refreshChildren(entry, null);
PlatformThread.runLaterIfNeeded(() -> {
expanded.set(hasChildren);
});

View file

@ -353,24 +353,26 @@ public abstract class DataStorage {
}
@SneakyThrows
public boolean refreshChildren(DataStoreEntry e) {
return refreshChildren(e, false);
public boolean refreshChildren(DataStoreEntry e, ValidationContext<?> context) {
return refreshChildren(e, context, false);
}
@SuppressWarnings("unchecked")
public <T extends ValidationContext<?>> boolean refreshChildren(DataStoreEntry e, boolean throwOnFail) throws Exception {
public <T extends ValidationContext<?>> boolean refreshChildren(DataStoreEntry e, T context, boolean throwOnFail) throws Exception {
if (!(e.getStore() instanceof FixedHierarchyStore<?> h)) {
return false;
}
e.incrementBusyCounter();
List<? extends DataStoreEntryRef<? extends FixedChildStore>> newChildren;
T context = null;
var hadContext = context != null;
try {
if (context == null) {
context = (T) h.createContext();
if (context == null) {
return false;
}
}
newChildren = ((FixedHierarchyStore<T>)h).listChildren(context).stream()
.filter(dataStoreEntryRef -> dataStoreEntryRef != null && dataStoreEntryRef.get() != null)
@ -383,7 +385,7 @@ public abstract class DataStorage {
return false;
}
} finally {
if (context != null) {
if (context != null && !hadContext) {
context.close();
}
e.decrementBusyCounter();

View file

@ -72,7 +72,7 @@ public class RefreshChildrenStoreAction implements ActionProvider {
@Override
public void execute() {
DataStorage.get().refreshChildren(store);
DataStorage.get().refreshChildren(store, null);
}
}
}