Uploaded image for project: 'Spring Integration'
  1. Spring Integration
  2. INT-3153

Cannot read header "sequenceDetails" (or other lists) from MongoDbMessageStore

    XMLWordPrintable

    Details

      Description

      I'm seeing a pretty specific issue where a message is able to be stored in a MongoDdMessageStore, but it is invalid when reading it back out. The message header, sequenceDetails, is store as an array of array, or in Mongodb driver terms, a BasicBSONList of BasicBSONList. For example:

      ...
      "sequenceDetails" : [
      			[
      				{
      					"_value" : "3f720450-2784-11e3-86eb-001c42000009",
      					"_class" : "java.util.UUID"
      				},
      				1,
      				1
      			]
      		],
      ...
      

      The problem appears to be that upon reading from MongoDbMessageStore, it does not expect to encounter a BasicBSONList (refer to inline comments for precisely where the problem occurs):

      MongoDbMessageStore.java
      // Starts at line 386
      		private Map<String, Object> normalizeHeaders(Map<String, Object> headers) {
      			Map<String, Object> normalizedHeaders = new HashMap<String, Object>();
      			for (String headerName : headers.keySet()) {
      				Object headerValue = headers.get(headerName);
      				if (headerValue instanceof DBObject) {
      					DBObject source = (DBObject) headerValue; // "source" is now a BasicDBList
      					Object type = source.get("_class"); // ...but BasicBSONList can ready only ints as keys, not strings.
      					try {
      						Class<?> typeClass = ClassUtils.forName(type.toString(), classLoader);
      						normalizedHeaders.put(headerName, super.read(typeClass, source));
      					}
      					catch (Exception e) {
      						logger.warn("Header '" + headerName + "' could not be deserialized.", e);
      					}
      				}
      				else {
      					normalizedHeaders.put(headerName, headerValue);
      				}
      			}
      			return normalizedHeaders;
      		}
      	}
      

      The result is an exception as follows:

      java.lang.IllegalArgumentException: BasicBSONList can only work with numeric keys, not: [_class]
      

        Attachments

          Activity

            People

            Assignee:
            abilan Artem Bilan
            Reporter:
            kungfuters Matt Senter
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: