Opened 10 months ago

Closed 9 months ago

Last modified 8 months ago

#23196 closed defect (fixed)

[PATCH] DataIntegrityProblemException: Primitive must be part of the dataset

Reported by: gaben Owned by: team
Priority: normal Milestone: 23.11
Component: Core Version:
Keywords: template_report preset validate async Cc:

Description (last modified by gaben)

What steps will reproduce the problem?

  1. Set taggingpreset.validator=true
  2. Create two connected ways
  3. Select way1, the common node and way2
  4. Create a turn restriction between them
  5. In the newly opened relation editor click on the header

What is the expected result?

Changing the restriction type possible.

What happens instead?

Exception appears.

Please provide any additional information below. Attach a screenshot if possible.

Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2023-09-21 20:54:28 +0200 (Thu, 21 Sep 2023)
Build-Date:2023-09-22 01:30:58
Relative:URL: ^/trunk

Identification: JOSM/1.5 (18841 hu) Windows 10 64-Bit
OS Build number: Windows 10 Pro for Workstations 2009 (19045)
Memory Usage: 2396 MB / 7266 MB (1433 MB allocated, but free)
Java version: 1.8.0_382-b05, Azul Systems, Inc., OpenJDK 64-Bit Server VM
Look and Feel:
Screen: \Display0 1920×1200 (scaling 1.00×1.00)
Maximum Screen Size: 1920×1200
Best cursor sizes: 16×16→32×32, 32×32→32×32
System property file.encoding: Cp1250
System property sun.jnu.encoding: Cp1250
Locale info: hu_HU
Numbers with default locale: 1234567890 -> 1234567890
VM arguments: [, -Dicedtea-web.bin.location=C:\Program Files\IcedTeaWeb\WebStart\bin\javaws.exe]
Dataset consistency test: No problems found

No data collected.

Warning issued by: BugReportExceptionHandler#handleException

Thread: AWT-EventQueue-1 (33) of JOSM (development version) Primitive must be part of the dataset: {Relation id=-63 version=0 VT [vonal -610, pont -25375, vonal -611]}
	at java.util.ArrayList.forEach(
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPreset.createPanel(
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPreset.showDialog(
	at java.awt.AWTEventMulticaster.mouseClicked(
	at java.awt.Component.processMouseEvent(
	at javax.swing.JComponent.processMouseEvent(
	at java.awt.Component.processEvent(
	at java.awt.Container.processEvent(
	at java.awt.Component.dispatchEventImpl(
	at java.awt.Container.dispatchEventImpl(
	at java.awt.Component.dispatchEvent(
	at java.awt.LightweightDispatcher.retargetMouseEvent(
	at java.awt.LightweightDispatcher.processMouseEvent(
	at java.awt.LightweightDispatcher.dispatchEvent(
	at java.awt.Container.dispatchEventImpl(
	at java.awt.Window.dispatchEventImpl(
	at java.awt.Component.dispatchEvent(
	at java.awt.EventQueue.dispatchEventImpl(
	at java.awt.EventQueue.access$500(
	at java.awt.EventQueue$
	at java.awt.EventQueue$
	at Method)
	at java.awt.EventQueue$
	at java.awt.EventQueue$
	at Method)
	at java.awt.EventQueue.dispatchEvent(
	at java.awt.EventDispatchThread.pumpOneEventForFilters(
	at java.awt.EventDispatchThread.pumpEventsForFilter(
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(
	at java.awt.EventDispatchThread.pumpEvents(
	at java.awt.EventDispatchThread.pumpEvents(

Attachments (0)

Change History (14)

comment:1 by gaben, 10 months ago

Description: modified (diff)

The taggingpreset.validator=true setting causing the issue.

comment:2 by gaben, 10 months ago

Keywords: preset validate async added

comment:3 by gaben, 10 months ago

The root cause is that the relation does not exist in the dataset at that point. It becomes part of the dataset once the relation editor is closed with the OK button. At least that's how I understand it.

comment:4 by taylor.smock, 10 months ago

I could have sworn I fixed that. I guess not, or it is a slightly different problem with a slightly different set of steps to reproduce.

comment:5 by gaben, 10 months ago

The only solution I can think of at the moment is:

  • src/org/openstreetmap/josm/gui/tagging/presets/

    444444            GuiHelper.setEnabledRec(itemPanel, false);
    445445        }
    447         if (selected.size() == 1 && Boolean.TRUE.equals(USE_VALIDATOR.get())) {
     447        if (selected.size() == 1 && Boolean.TRUE.equals(USE_VALIDATOR.get()) &&
     448                .noneMatch(Objects::isNull)) {
    448449            // Fail early -- validateAsync requires the primitive(s) to be part of a dataset. Failing later in validateAsync ''does not'' give us
    449             // a usable stack trace. See #21829 for details.
    450             selected.forEach(OsmPrimitive::checkDataset);
     450            // a usable stack trace. See #21829 and #23196 for details.
    451451            itemGuiSupport.addListener((source, key, newValue) ->
    452452                    TaggingPresetValidation.validateAsync(selected.iterator().next(), validationLabel, getChangedTags()));
    453453        }

The drawback is that it disables the async validation for newly created objects, which is the point of the feature... Please do not commit this, I'm just thinking loudly.

comment:6 by taylor.smock, 10 months ago

The stacktrace if we get rid of the selected.forEach(OsmPrimitive::checkDataset) is Primitive must be part of the dataset: {Relation id=-142 version=0 VT [way -648, node 236132035, way -649]}
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPresetValidation.applyChangedTags(
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPresetValidation.validateAsync(
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPreset.lambda$createPanel$2(
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport.lambda$fireItemValueModified$1(
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport.fireItemValueModified(
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPreset.createPanel(
	at org.openstreetmap.josm.gui.tagging.presets.TaggingPreset.showDialog(Unknown Source)

The "best" solution is to add the relation to the dataset, so something like

  • src/org/openstreetmap/josm/gui/tagging/presets/

    diff --git a/src/org/openstreetmap/josm/gui/tagging/presets/ b/src/org/openstreetmap/josm/gui/tagging/presets/
    a b  
    545548            if (r.isMultipolygon() && r != calculated) {
    546549                r.setMembers(RelationSorter.sortMembersByConnectivity(r.getMembers()));
    547550            }
     551            // Add the new relation to the dataset
     552            final Relation toEdit;
     553            if (r != calculated) {
     554                final DataSet ds =
     555                        .orElse(OsmDataManager.getInstance().getEditDataSet());
     556                UndoRedoHandler.getInstance().add(new AddPrimitivesCommand(Collections.singletonList(, ds));
     557                toEdit = (Relation) ds.getPrimitiveById(r);
     558            } else {
     559                toEdit = r;
     560            }
    548561            SwingUtilities.invokeLater(() -> RelationEditor.getEditor(
    549                     MainApplication.getLayerManager().getEditLayer(), r, members).setVisible(true));
     562                    MainApplication.getLayerManager().getEditLayer(), toEdit, members).setVisible(true));
    550563        }
    551564        if (!primitives.isEmpty()) {
    552565            DataSet ds = primitives.iterator().next().getDataSet();

would work.

comment:7 by gaben, 10 months ago

I like it and at the same time feels weird to use. Probably just I need to get used to it.

comment:8 by taylor.smock, 10 months ago

Milestone: 23.10
Summary: DataIntegrityProblemException: Primitive must be part of the dataset[PATCH] DataIntegrityProblemException: Primitive must be part of the dataset

comment:9 by taylor.smock, 9 months ago

Resolution: fixed
Status: newclosed

In 18866/josm:

Fix #23196: DataIntegrityProblemException: Primitive must be part of the dataset

It turns out that FilterModel doesn't care whether a primitive's referrers are
in the dataset or not.

This additionally adds a non-regression test and modifies WindowMocker to cover
some more headless exceptions. This additionally lets us stop mocking

comment:10 by gaben, 9 months ago

That's even more simple, great!

comment:11 by taylor.smock, 9 months ago

In 18867/josm:

See #16567: Update to JUnit 5

This adds the @TaggingPresets annotation used by r18866 (see #23196). The
annotation tries to only initialize the presets when the current preset list does
not have the same hashCode as the default preset list. In order for this to work,
TaggingPresets#getTaggingPresets had to return a List (the method contract
has not changed), which calculates the hashCode in a deterministic manner.

comment:12 by taylor.smock, 9 months ago

Ticket #23247 has been marked as a duplicate of this ticket.

comment:13 by gaben, 9 months ago

Description: modified (diff)

fix typo

comment:14 by taylor.smock, 8 months ago

Milestone: 23.1023.11

Ticket retargeted after milestone deleted

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.