#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)
Change History (19)
by , 4 years ago
| Attachment: | 21203.patch added |
|---|
by , 4 years ago
| Attachment: | 21203.2.patch added |
|---|
comment:2 by , 4 years ago
| Cc: | added |
|---|---|
| Keywords: | regression added |
| Version: | → latest |
comment:3 by , 4 years ago
| Milestone: | → 21.08 |
|---|
comment:4 by , 4 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
follow-up: 9 comment:7 by , 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 , 4 years ago
| Resolution: | fixed |
|---|---|
| Status: | closed → reopened |
@marcello can you please submit a new one?
comment:9 by , 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:
- Not every class overrides the toString method (see https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#toString() for the default implementation, which is probably not what we want to show, so I figured it would be a better idea to
throwon unknown items, and deal with that).
Alternative:
Object.class.equals(item.getClass().getMethod("toString").getDeclaringClass()). Only problem is reflection errors.
comment:10 by , 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 , 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 , 4 years ago
| Attachment: | 21203.4.patch added |
|---|



Add tests