Modify

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#21203 closed defect (fixed)

[PATCH] ClassCastException in HistoryComboBox#addCurrentItemToHistory

Reported by: taylor.smock Owned by: Don-vip
Priority: normal Milestone: 21.08
Component: Core Version: latest
Keywords: template_report regression Cc: skorbut, marcello@…

Description

Revision:18119
Is-Local-Build:true
Build-Date:2021-08-03 08:34:05

Identification: JOSM/1.5 (18119 SVN en) Mac OS X 11.5.1
OS Build number: macOS 11.5.1 (20G80)
Memory Usage: 332 MB / 4096 MB (164 MB allocated, but free)
Java version: 16.0.1+0, Homebrew, OpenJDK 64-Bit Server VM
Look and Feel: com.apple.laf.AquaLookAndFeel
Screen: Display 188945233 1920×1080 (scaling 1.00×1.00) Display 188945231 1920×1080 (scaling 1.00×1.00) Display 69733382 1680×1050 (scaling 2.00×2.00)
Maximum Screen Size: 1920×1080
Best cursor sizes: 16×16→16×16, 32×32→32×32
System property file.encoding: UTF-8
System property sun.jnu.encoding: UTF-8
Locale info: en_US
Numbers with default locale: 1234567890 -> 1234567890
VM arguments: [-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:59705,suspend=y,server=n, -javaagent:/Users/tsmock/Library/Caches/JetBrains/IntelliJIdea2021.2/groovyHotSwap/gragent.jar, -javaagent:/Users/tsmock/Library/Caches/JetBrains/IntelliJIdea2021.2/captureAgent/debugger-agent.jar, -agentpath:/private/var/folders/ck/cnph0dss4t3_jym5vngbqhzr0000gn/T/libmemory_agent.dylib=, -Dfile.encoding=UTF-8]
Dataset consistency test: No problems found

Map paint styles:
+ resource://mapcss/Mapillary.mapcss
+ https://josm.openstreetmap.de/josmfile?page=Styles/Lane_and_Road_Attributes&zip=1

Last errors/warnings:
- 00003.565 W: PluginException: : org.openstreetmap.josm.plugins.PluginException: Invalid jar file '<josm.userdata>/plugins/corrupted_plugin.jar.new'
- 00003.576 W: Failed to scan file 'corrupted_plugin.jar.new' for plugin information. Skipping.
- 00003.736 W: Failed to install plugin '<josm.userdata>/plugins/corrupted_plugin.jar' from temporary download file '<josm.userdata>/plugins/corrupted_plugin.jar.new'. zip END header not found: java.util.zip.ZipException: zip END header not found
- 00004.180 W: Failed to register with macOS: java.lang.IllegalAccessException: class org.openstreetmap.josm.tools.PlatformHookOsx cannot access class com.apple.eawt.Application (in module java.desktop) because module java.desktop does not export com.apple.eawt to unnamed module @6ce139a4
- 00025.478 E: Failed to locate image 'https://koordinates.a.ssl.fastly.net/media/settings/branding/favicon-lds.ico'
- 00025.481 E: Failed to locate image 'https://koordinates.a.ssl.fastly.net/media/settings/branding/favicon-lds.ico'
- 00028.038 E: Failed to locate image 'https://koordinates.a.ssl.fastly.net/media/settings/branding/favicon-lds.ico'
- 00028.059 E: Unsupported savable layer type: TMSLayer
- 00036.049 E: Handled by bug report queue: java.lang.ClassCastException: class org.openstreetmap.josm.data.tagging.ac.AutoCompletionItem cannot be cast to class java.lang.String (org.openstreetmap.josm.data.tagging.ac.AutoCompletionItem is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
- 01606.587 E: Handled by bug report queue: java.lang.ClassCastException: class org.openstreetmap.josm.data.tagging.ac.AutoCompletionItem cannot be cast to class java.lang.String (org.openstreetmap.josm.data.tagging.ac.AutoCompletionItem is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')



=== REPORTED CRASH DATA ===
BugReportExceptionHandler#handleException:
No data collected.

Warning issued by: BugReportExceptionHandler#handleException

=== STACK TRACE ===
Thread: AWT-EventQueue-0 (26) of main
java.lang.ClassCastException: class org.openstreetmap.josm.data.tagging.ac.AutoCompletionItem cannot be cast to class java.lang.String (org.openstreetmap.josm.data.tagging.ac.AutoCompletionItem is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
	at org.openstreetmap.josm.gui.widgets.HistoryComboBox.addCurrentItemToHistory(HistoryComboBox.java:57)
	at org.openstreetmap.josm.gui.io.BasicUploadSettingsPanel.rememberUserInput(BasicUploadSettingsPanel.java:264)
	at org.openstreetmap.josm.gui.io.UploadDialog.rememberUserInput(UploadDialog.java:352)
	at org.openstreetmap.josm.actions.UploadAction.uploadData(UploadAction.java:245)
	at org.openstreetmap.josm.actions.UploadAction.actionPerformed(UploadAction.java:292)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
	at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6617)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
	at java.desktop/java.awt.Component.processEvent(Component.java:6382)
	at java.desktop/java.awt.Container.processEvent(Container.java:2264)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4993)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2322)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4825)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4934)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4563)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4504)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2308)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2773)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4825)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Attachments (4)

21203.patch (1.2 KB ) - added by taylor.smock 4 years ago.
21203.2.patch (3.6 KB ) - added by taylor.smock 4 years ago.
Add tests
21203.3.patch (3.6 KB ) - added by taylor.smock 4 years ago.
Add missing assert for size of saved entries
21203.4.patch (3.0 KB ) - added by marcello@… 4 years ago.

Download all attachments as: .zip

Change History (19)

by taylor.smock, 4 years ago

Attachment: 21203.patch added

by taylor.smock, 4 years ago

Attachment: 21203.2.patch added

Add tests

by taylor.smock, 4 years ago

Attachment: 21203.3.patch added

Add missing assert for size of saved entries

comment:1 by skyper, 4 years ago

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

comment:2 by skyper, 4 years ago

Cc: skorbut added
Keywords: regression added
Version: latest

comment:3 by Don-vip, 4 years ago

Milestone: 21.08

comment:4 by Don-vip, 4 years ago

Owner: changed from team to Don-vip
Status: newassigned

comment:5 by Don-vip, 4 years ago

Cc: marcello@… added

Another regression of r18098?

comment:6 by Don-vip, 4 years ago

Resolution: fixed
Status: assignedclosed

In 18126/josm:

fix #21203 - CCE in HistoryComboBox#addCurrentItemToHistory (patch by taylor.smock)

comment:7 by marcello@…, 4 years ago

No, this patch is wrong. You should just call toString() on the item.
You can setItem any item to a ComboBoxEditor that has a toString method (that is: any Object). There's no need to limit the object classes that can be added, it makes the widget only less general. Maybe at a later point we want to add a HistoryComboBox of LatLonItem?

comment:8 by Don-vip, 4 years ago

Resolution: fixed
Status: closedreopened

@marcello can you please submit a new one?

in reply to:  7 comment:9 by taylor.smock, 4 years ago

Replying to marcello@…:

No, this patch is wrong. You should just call toString() on the item.
You can setItem any item to a ComboBoxEditor that has a toString method (that is: any Object). There's no need to limit the object classes that can be added, it makes the widget only less general. Maybe at a later point we want to add a HistoryComboBox of LatLonItem?

The Object::toString method was my first response.

Issues:

Alternative:

  • Object.class.equals(item.getClass().getMethod("toString").getDeclaringClass()). Only problem is reflection errors.

comment:10 by marcello@…, 4 years ago

The problem is not having a toString() method but having a meaningful toString() that you can show to the user. And this you cannot test.

IMO, showing "Object@64236487" or similar stuff in the dropdown list is still better than throwing. At least the combobox would still work.

The idea is: in future we may want a list of "my last tagged items". It would be much easier to just add the OsmPrimitive objects to the list than to: convert to String, add to list, let user select, get back from list, somehow convert to OsmPrimitive again. Of course this needs changes in AutoCompletionItem first.

comment:11 by taylor.smock, 4 years ago

Fair enough. If you don't have a patch written in ~1.5 hours, I'll do the Object::toString method, and adjust the tests accordingly.

by marcello@…, 4 years ago

Attachment: 21203.4.patch added

comment:12 by marcello@…, 4 years ago

I have just added a patch onto your patch.

comment:13 by Don-vip, 4 years ago

Resolution: fixed
Status: reopenedclosed

In 18128/josm:

fix #21203 - Use Object.toString() to display history combobox items (patch by marcello)

comment:14 by Don-vip, 4 years ago

thanks!

comment:15 by skyper, 4 years ago

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

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Don-vip.
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.