DataObject handling breaks if an attribute contains a dot
Bug Report
🐛 Summary
📋 Steps to reproduce
- Create a data object
- Add an attribute containing a dot "." somewhere in the key (e.g.
test.abc
) - Try to retrieve the data object again
📦 Environment
- shepard Version: Tested with 1.0.0 and 3.0.0
- Webbrowser and version: n/a
- shepard client and version: Both Java 3.0.0 and the frontend
- Operating system: n/a
💣 What is the current bug behavior?
The attribute is written correctly to Neo4j.
Retrieving the DataObject using the API (either by requesting it directly by retrieving all DataObjects) fails and an exception is generated.
🥅 What is the expected correct behavior?
The DataObject should be retrieved and the attribute containing the dot should be included. If dot is a special character, encoding should be done automatically on server side.
📓 Relevant logs and/or screenshots
Error message on the frontend when trying to load a "defective" DataObject:
Error while fetching data objects: JsonMappingException
(was java.lang.ClassCastException) (through reference chain: java.util.ArrayList[0]->de.dlr.shepard.neo4Core.io.DataObjectIO["attributes"]->java.util.HashMap["test"])
Log on the backend (other collection/dataobject but same effect):
2024-12-10 13:00:59.218 [INFO ] [de.dlr.shepard.filters.LoggingFilter] (executor-thread-15) Received GET request on /collections/2721/dataObjects from vist_mi with query params {size=[25]}
2024-12-10 13:00:59.249 [ERROR] [de.dlr.shepard.exceptions.ShepardExceptionMapper] (executor-thread-15) class java.util.HashMap cannot be cast to class java.lang.String (java.util.HashMap and java.lang.String are in module java.base of l
oader 'bootstrap') (through reference chain: java.util.ArrayList[101]->de.dlr.shepard.neo4Core.io.DataObjectIO["attributes"]->java.util.HashMap["Visuelle Prüfung d"]): com.fasterxml.jackson.databind.JsonMappingException: class java.util.
HashMap cannot be cast to class java.lang.String (java.util.HashMap and java.lang.String are in module java.base of loader 'bootstrap') (through reference chain: java.util.ArrayList[101]->de.dlr.shepard.neo4Core.io.DataObjectIO["attribut
es"]->java.util.HashMap["Visuelle Prüfung d"])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:402)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:361)
at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:323)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFieldsUsing(MapSerializer.java:910)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeWithoutTypeInfo(MapSerializer.java:762)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:720)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:35)
at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:732)
at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:183)
at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119)
at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79)
at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:502)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:341)
at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1574)
at com.fasterxml.jackson.databind.ObjectWriter._writeValueAndClose(ObjectWriter.java:1275)
at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:1098)
at io.quarkus.resteasy.reactive.jackson.runtime.serialisers.BasicServerJacksonMessageBodyWriter.writeResponse(BasicServerJacksonMessageBodyWriter.java:63)
at org.jboss.resteasy.reactive.server.core.ServerSerialisers.invokeWriter(ServerSerialisers.java:218)
at org.jboss.resteasy.reactive.server.core.serialization.DynamicEntityWriter.write(DynamicEntityWriter.java:119)
at org.jboss.resteasy.reactive.server.handlers.ResponseWriterHandler.handle(ResponseWriterHandler.java:32)
at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:147)
at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.ClassCastException: class java.util.HashMap cannot be cast to class java.lang.String (java.util.HashMap and java.lang.String are in module java.base of loader 'bootstrap')
at com.fasterxml.jackson.databind.ser.std.StringSerializer.serialize(StringSerializer.java:41)
at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeFieldsUsing(MapSerializer.java:905)
... 28 more
💡 Hints
The data object mapper to Neo4j seems to guess a map incorrectly.