darkyellowcat opened a new issue, #901: URL: https://github.com/apache/hugegraph-toolchain/issues/901
### Bug Type (问题类型) exception / error (异常报错) ### Before submit - [x] I had searched in the [issues](https://github.com/apache/hugegraph-toolchain/issues) and found no similar issues. ### Environment (环境信息) - Server Version: N/A (This issue is independent of the HugeGraph Server) - Toolchain Version: 1.8.0 (source build from master, before the fix) - Data Size: N/A (Unit-level issue, no graph data required) ### Expected & Actual behavior (期望与实际表现) ### Expected Behavior `DataTypeUtil.splitField()` should handle Java `Collection` inputs without assuming that they implement `List`. - If the input is a `List`, it should return the original list. - If the input is another type of `Collection` (such as `Set`), it should return a list containing all elements. - The iteration order should be preserved for collections that guarantee ordering, such as `LinkedHashSet`. ### Actual Behavior The current implementation checks whether `rawColumnValue` is an instance of `Collection` and directly casts it to `List<Object>`: ```java if (rawColumnValue instanceof Collection) { return (List<Object>) rawColumnValue; } ``` However, `Set` implements `Collection` but does not implement `List`. Consequently, passing a `Set` (e.g., `HashSet`, `LinkedHashSet`, or Guava's `ImmutableSet`) causes a `ClassCastException` instead of returning the collection elements. The existing `DataTypeUtilTest.testSplitField()` covers `String` and `List` inputs, but does not cover other `Collection` implementations such as `Set`. This case is therefore not covered by the existing unit tests. ### Minimal Reproduction ```java Set<Object> values = new LinkedHashSet<>( Arrays.asList("b", "a") ); List<Object> result = DataTypeUtil.splitField( "key", values, new FileSource() ); ``` **Expected result:** ```text [b, a] ``` **Actual result:** ```text java.lang.ClassCastException ``` The exception occurs because a `LinkedHashSet` cannot be cast to a `List`. ### Impact This prevents `splitField()` from handling non-List collection values correctly and may cause failures when processing collection-valued fields in HugeGraph Loader. ### Vertex/Edge example (问题点 / 边数据举例) ```javascript N/A. This issue is related to the internal collection handling in HugeGraph Loader's DataTypeUtil.splitField() method. It can be reproduced with a simple Java Set without requiring a specific vertex or edge record. ``` ### Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构) ```javascript N/A. No specific VertexLabel, EdgeLabel, or IndexLabelschema is required to reproduce this issue. ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
