{"record":{"id":"9df3fd7993a8e72a","repo":"heibaiying/BigData-Notes","slug":"cannot-process-such-data-type-datatype","errorCode":null,"errorMessage":"Cannot process such data type: ${dataType}","messagePattern":"Cannot process such data type: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"notes/Storm集成Redis详解.md","lineNumber":422,"sourceCode":"                    break;\n\n                case HYPER_LOG_LOG:\n                    jedisCommand.pfadd(key, value);\n                    break;\n\n                case GEO:\n                    String[] array = value.split(\":\");\n                    if (array.length != 2) {\n                        throw new IllegalArgumentException(\"value structure should be longitude:latitude\");\n                    }\n\n                    double longitude = Double.valueOf(array[0]);\n                    double latitude = Double.valueOf(array[1]);\n                    jedisCommand.geoadd(additionalKey, longitude, latitude, key);\n                    break;\n\n                default:\n                    throw new IllegalArgumentException(\"Cannot process such data type: \" + dataType);\n            }\n\n            collector.ack(input);\n        } catch (Exception e) {\n            this.collector.reportError(e);\n            this.collector.fail(input);\n        } finally {\n            returnInstance(jedisCommand);\n        }\n    }\n\n     .........\n}\n\n```\n\n### 3.3 JedisCommands\n","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/heibaiying/BigData-Notes/blob/3898939aca387c25b3eb4e51ef49dfccca8543ed/notes/Storm集成Redis详解.md#L404-L440","documentation":"This IllegalArgumentException is the default branch of the data-type switch in the Redis store bolt's process() method (pattern of Storm's RedisStoreBolt): every RedisDataTypeDescription.RedisDataType case that the bolt knows how to persist (STRING, HASH, SORTED_SET, HYPER_LOG_LOG, GEO, etc.) has an explicit handler, and any other value falls through to this throw. It means the store mapper declared a data type the persistence logic does not support, so the tuple cannot be written to Redis. The exception is caught, reported to the topology, and the tuple is failed.","triggerScenarios":"Calling setDataTypeDescription()/getDataTypeDescription() with a RedisDataType value not covered by the switch — typically because the code was compiled against a newer storm-redis where RedisDataType gained new enum constants (or a custom enum value) that this bolt's switch does not handle; or the switch itself was trimmed during copy-paste so legitimate types (e.g. LIST, SET, HASH) are missing. It fires per-tuple: the first tuple with the unsupported type triggers it.","commonSituations":"Vendoring/copying RedisStoreBolt source into your project (as this repo's notes do) and not porting every case; upgrading storm-redis to a version whose RedisDataType enum includes types your copied switch never handled; declaring a data type in the mapper that was never wired into the bolt ('STRING' vs custom constants); mixed pipelines where one mapper is reused across bolts with different switch coverage.","solutions":["Align the mapper's declared data type with one the switch actually handles — pick STRING, HASH, SORTED_SET, HYPER_LOG_LOG, or GEO per your access pattern.","If you need a type the copied switch lacks (e.g. LIST via rpush, SET via sadd), add the case to the switch: case LIST: jedisCommand.rpush(additionalKey, value); break; — this code is yours to extend.","Prefer the official org.apache.storm.redis.bolt.RedisStoreBolt from the storm-redis artifact over vendored copies so you inherit full enum coverage; if the vendored copy exists for learning, keep its switch in sync when upgrading Storm.","Add a startup assertion in prepare() that rejects unsupported data types at topology launch instead of failing on the first tuple."],"exampleFix":"// before: mapper declares a type with no case in the switch\nnew RedisDataTypeDescription(RedisDataTypeDescription.RedisDataType.LIST, \"mylist\");\n// -> default: throw new IllegalArgumentException(\"Cannot process such data type: \" + dataType);\n\n// after: add the missing case to the vendored bolt\nswitch (dataType) {\n    case LIST:\n        jedisCommand.rpush(additionalKey, value);\n        break;\n    // ...existing cases...\n}","handlingStrategy":"validation","validationCode":"Set<RedisDataTypeDescription.RedisDataType> supported =\n    EnumSet.of(STRING, HASH, SORTED_SET, HYPER_LOG_LOG, GEO /* cases present in your switch */);\nif (!supported.contains(dataType)) {\n    throw new IllegalArgumentException(\"Unsupported data type \" + dataType + \"; supported: \" + supported);\n}","typeGuard":"boolean isSupportedStoreType(org.apache.storm.redis.common.mapper.RedisDataTypeDescription.RedisDataType t) {\n    switch (t) {\n        case STRING: case HASH: case SORTED_SET: case HYPER_LOG_LOG: case GEO:\n            return true;\n        default:\n            return false;\n    }\n}","tryCatchPattern":"// Validate in prepare() rather than catching per-tuple: fail the topology at launch\nif (!isSupportedStoreType(dataType)) {\n    throw new IllegalArgumentException(\"Cannot process such data type: \" + dataType);\n}\n// The per-tuple catch (reportError + fail) in process() remains as a safety net only.","preventionTips":["Prefer the official storm-redis RedisStoreBolt over vendored copies; if you vendor it, keep the switch exhaustive against the RedisDataType enum you compile against.","Run with Java's -Xlint:switch (or a default-branch unit test enumerating all enum values) to detect unhandled enum constants at build time.","Validate the mapper's declared type against a supported-set in prepare() so errors surface at deployment, not on the first tuple.","Add a unit test that iterates RedisDataType.values() and asserts the bolt handles or explicitly rejects each one."],"tags":["storm","redis","jedis","illegalargumentexception","configuration","switch-enum"],"backgroundTag":null,"analyzedSha":"3898939aca387c25b3eb4e51ef49dfccca8543ed","analyzedAt":"2026-08-14T15:36:11.245Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}