Closed Flaurite closed 1 month ago
The reason of the problem is the events that occur after clickEvent: singleClick or doubleClick. These event cannot find removed item, so the solution can be not throwing an exception but logs it.
The rough workaround:
1) Extend GeoMap
component and override these methods:
public class ExtGeoMap extends GeoMap {
@Override
protected void onFeatureClickEvent(AbstractFeatureClickDomEvent event) {
Layer<?> layer = getLayerBySyncId(event.getLayerSyncId());
if (!(layer instanceof BaseVectorLayer)) {
return;
}
AbstractVectorSource source = (AbstractVectorSource) layer.getSource();
if (source instanceof AbstractClusterSource.HasVectorSource vectorSource) {
source = vectorSource.getVectorSource();
}
Feature feature = getFeatureBySyncId(source, event.getFeatureSyncId());
if (feature == null) {
// Do not fire event
return;
}
if (source instanceof AbstractFeatureSource featureSource) {
EventBus eventBus = MapObservableUtils.getEventBus(featureSource);
if (eventBus != null) {
fireSourceFeatureClickEvent(eventBus, event, feature, featureSource);
}
}
EventBus eventBus = MapObservableUtils.getEventBus(feature);
if (eventBus != null) {
fireFeatureClickEvent(eventBus, event, feature);
}
}
@Nullable
@Override
protected Feature getFeatureBySyncId(AbstractVectorSource source, UUID syncId) {
return (Feature) MapObservableUtils.getChildren(source).stream()
.filter(f -> getSyncId(f).equals(syncId))
.findFirst()
.orElse(null);
}
}
@Bean
public ComponentRegistration extGeoMap() {
return ComponentRegistrationBuilder.create(ExtGeoMap.class)
.replaceComponent(GeoMap.class)
.build();
}
Reopened to test.
Tested on Jmix version: 2.4.999-SNAPSHOT Jmix Studio plugin version: 2.4.SNAPSHOT6876-242 IntelliJ version: IntelliJ IDEA 2024.2.3 (Community Edition)
Environment
Jmix version: 2.3.x
Bug Description
When the
GeoObjectClickEvent
listener removes clicked item and add it back to container, the little delay in communication between client-side and server throws an exception. For instance:This code in debug mode will throw an exception.
Steps To Reproduce
Current Behavior
Stacktrace:
Expected Behavior
No exceptions occur