Opened 3 years ago
Closed 8 months ago
#20849 closed defect (fixed)
[PATCH] WARNING: row index is bigger than sorter's row count. Most likely this is a wrong sorter usage.
Reported by: | skyper | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 22.12 |
Component: | Core | Version: | latest |
Keywords: | template_report | Cc: |
Description
What steps will reproduce the problem?
- Start JOSM with fresh/empty preferences
What is the expected result?
No warnings on startup
What happens instead?
In the console: WARNING: row index is bigger than sorter's row count. Most likely this is a wrong sorter usage.
Please provide any additional information below. Attach a screenshot if possible.
I noticed this for some time, now, and thought it is a problem of my external files but I was wrong.
Relative:URL: ^/trunk Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b Last:Changed Date: 2021-05-04 21:01:14 +0200 (Tue, 04 May 2021) Revision:17860 Build-Date:2021-05-05 01:30:58 URL:https://josm.openstreetmap.de/svn/trunk Identification: JOSM/1.5 (17860 en) Linux Debian GNU/Linux 10 (buster) Java version: 11.0.11+9-post-Debian-1deb10u1, Debian, OpenJDK 64-Bit Server VM
Attachments (0)
Change History (8)
comment:1 by , 2 years ago
comment:2 by , 18 months ago
Summary: | WARNING: row index is bigger than sorter's row count. Most likely this is a wrong sorter usage. → [PATCH] WARNING: row index is bigger than sorter's row count. Most likely this is a wrong sorter usage. |
---|
It looks like this is due to order in which the table listeners get notified. It looks like SonarLint doesn't like the patch (java:S3047), so I don't think we will apply this patch unless we really need to, or SonarLint is fixed.
Also, the fix is a bit of a hack -- the order in which TableModelListeners are notified is not specified in documentation, so it could change at any time. :(
I'll do a bit more debugging tomorrow to see if there is a "better" way to do it.
-
src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
diff --git a/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java b/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
a b 190 190 }); 191 191 // Force Swing to show horizontal scrollbars for the JTable 192 192 // Yes, this is a little ugly, but should work 193 availableSourcesModel.addTableModelListener(e -> TableHelper.adjustColumnWidth(tblAvailableSources, 0, 800));193 fix20849(this.availableSourcesModel, e -> TableHelper.adjustColumnWidth(tblAvailableSources, 0, 800)); 194 194 activeSourcesModel.addTableModelListener(e -> TableHelper.adjustColumnWidth(tblActiveSources, canEnable ? 1 : 0, 800)); 195 195 activeSourcesModel.setActiveSources(getInitialSourcesList()); 196 196 … … 339 339 } 340 340 } 341 341 342 /** 343 * This fixes #20849: WARNING: row index is bigger than sorter's row count. Most likely this is a wrong sorter usage. 344 * This is caused by Java firing the event for updating {@code modelRowCount} in {@link javax.swing.DefaultRowSorter} 345 * <i>after</i> we attempt to update the table widths, which depends upon the {@code modelRowCount} being updated to 346 * avoid the warning. 347 * @param model The model to modify the listeners for 348 * @param listener The listener to add <i>first</i> 349 */ 350 private static void fix20849(AbstractTableModel model, TableModelListener listener) { 351 final TableModelListener[] listeners = model.getTableModelListeners(); 352 for (TableModelListener tListener : listeners) { 353 model.removeTableModelListener(tListener); 354 } 355 model.addTableModelListener(listener); 356 for (TableModelListener tListener : listeners) { 357 model.addTableModelListener(tListener); 358 } 359 } 360 342 361 private void buildIcons(GridBagConstraints gbc) { 343 362 DefaultListSelectionModel selectionModel = new DefaultListSelectionModel(); 344 363 iconPathsModel = new IconPathTableModel(selectionModel);
comment:4 by , 18 months ago
Milestone: | → 22.11 |
---|
comment:6 by , 8 months ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
In Ubuntu 23.04 I am using
DefaultTableModel mod1; mod1 = (DefaultTableModel) jTable1.getModel(); mod1.setNumRows(0); ...... mod1.addRow(row1);
The row1 is a plain vanilla object which I have been using for years.
All its values are legal and reasonable.
Only now did I notice this warning message.
comment:8 by , 8 months ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
@ilan.tal: I don't know why you reopened this ticket. If you have a bug to report about JOSM or JOSM plugins, please use the report bug functionality. This gives us information on:
- The java version you are using
- The JOSM version you are using
- The plugin versions you are using
If you additionally use the Report bug
functionality when the report bug window appears spontaneously, we will also get a stack trace.
Thanks for your report, however your ticket is incomplete and therefore not helpful in its current form.
Please add all needed information according to this list:
- The required parts of the Status Report from your JOSM.
- Please, use Report Bug from Help menu and copy & paste.
- Describe what behaviour you expected.
- Describe what did happen instead.
- Describe if and how the issue is reproducible.
- Add any relevant information like error messages or screenshots.
To ensure that all technical relevant information is contained, create new tickets by clicking in JOSMs Main Menu on Help → Report Bug.
With all that said, it sounds like you are working on a different Java project. This is not a generic Java help or troubleshooting forum. If that is the case, I would recommend filing a ticket against the JDK, see https://bugreport.java.com/bugreport/ .
If you want to see the changes I made to "fix" the problem in JOSM, see r18603.
I can track it down to be one of several problems with tagging presets preference:
In the console I notice warnings and errors: