Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Fix #22961: CCE when updating a primitive
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed May 24, 2023
1 parent e52c8b8 commit d67b0d4
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.function.Consumer;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -175,14 +176,22 @@ protected void done() {
protected void process(List<MapillarySequence> chunks) {
super.process(chunks);
VectorDataSet ds = MapillaryLayer.getInstance().getData();
for (MapillarySequence seq : chunks) {
for (MapillaryNode oldNode : seq.getNodes()) {
VectorNode oldPrimitive = (VectorNode) ds.getPrimitiveById(oldNode);
if (oldPrimitive != null) {
oldPrimitive.putAll(oldNode.getKeys());
oldPrimitive.setCoor(oldNode.getCoor());
// Technically a writeLock would be better, but we cannot get that with the current VectorDataSet
// implementation.
final Lock dsLock = ds.getReadLock();
try {
dsLock.lock();
for (MapillarySequence seq : chunks) {
for (MapillaryNode oldNode : seq.getNodes()) {
VectorNode oldPrimitive = (VectorNode) ds.getPrimitiveById(oldNode);
if (oldPrimitive != null) {
oldPrimitive.putAll(oldNode.getKeys());
oldPrimitive.setCoor(oldNode.getCoor());
}
}
}
} finally {
dsLock.unlock();
}
// The counter just avoids many resets of the imagery window in short order
if (!chunks.isEmpty() && counter.getAndAdd(chunks.size()) < 3) {
Expand Down

0 comments on commit d67b0d4

Please sign in to comment.