You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "yzeng1618 (via GitHub)" <gi...@apache.org> on 2026/01/29 01:50:23 UTC
[PR] [Fix][Connector-V2][SelectDBCloud] Fix NotSerializableException in engine sink action [seatunnel]
yzeng1618 opened a new pull request, #10412:
URL: https://github.com/apache/seatunnel/pull/10412
<!--
Thank you for contributing to SeaTunnel! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
## Contribution Checklist
- Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/seatunnel/issues).
- Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
- Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
-->
### Purpose of this pull request
<!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
fix https://github.com/apache/seatunnel/issues/10408, SelectDBConfig does not implement the Serializable interface, resulting in a direct NotSerializableException: SelectDBConfig being thrown when Hazelcast performs Java serialization at this step.
### Does this PR introduce _any_ user-facing change?
yes
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released SeaTunnel versions or within the unreleased branches such as dev.
If no, write 'No'.
If you are adding/modifying connector documents, please follow our new specifications: https://github.com/apache/seatunnel/issues/4544.
-->
### How was this patch tested?
add
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If you are adding E2E test cases, maybe refer to https://github.com/apache/seatunnel/blob/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/resources/mysqlcdc_to_mysql.conf, here is a good example.
-->
### Check list
* [ ] If any new Jar binary package adding in your PR, please add License Notice according
[New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
* [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
* [ ] If necessary, please update `incompatible-changes.md` to describe the incompatibility caused by this PR.
* [ ] If you are contributing the connector code, please check that the following files are updated:
1. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
2. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
3. Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
4. Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
5. Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2][SelectDBCloud] Fix NotSerializableException in engine sink action [seatunnel]
Posted by "yzeng1618 (via GitHub)" <gi...@apache.org>.
yzeng1618 commented on PR #10412:
URL: https://github.com/apache/seatunnel/pull/10412#issuecomment-3815896555
@DanielCarter-stack Regarding the mentioned Issues 1-3, which are not additional scenarios introduced by this PR, could you please confirm if they need to be fixed together?
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2][SelectDBCloud] Fix NotSerializableException in engine sink action [seatunnel]
Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo merged PR #10412:
URL: https://github.com/apache/seatunnel/pull/10412
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2][SelectDBCloud] Fix NotSerializableException in engine sink action [seatunnel]
Posted by "DanielCarter-stack (via GitHub)" <gi...@apache.org>.
DanielCarter-stack commented on PR #10412:
URL: https://github.com/apache/seatunnel/pull/10412#issuecomment-3815836049
<!-- code-pr-reviewer -->
<!-- cpr:pr_reply_v2_parts {"group": "apache/seatunnel#10412", "part": 1, "total": 1} -->
---
### Issue 1: Field naming does not comply with Java specifications
**Location**: `SelectDBConfig.java:49`
**Related Context**:
- This file: defined at line 49
- Comparison class: `DorisSinkConfig.java:73` uses `streamLoadProps`
- Caller: `SelectDBStageLoad.java:87` uses `getStageLoadProps()`
**Issue Description**:
Field `StageLoadProps` uses PascalCase naming, which violates Java field naming conventions (should use camelCase).
```java
// Current code
@Setter
@Getter
public class SelectDBConfig implements Serializable {
private Properties StageLoadProps; // ❌ First letter capitalized
// Lombok will generate getStageLoadProps() method
}
// Compare with other Connectors
public class DorisSinkConfig implements Serializable {
private Properties streamLoadProps; // ✅ Correct camelCase naming
}
```
**Potential Risks**:
- Risk 1: Does not comply with JavaBean specification, which may cause issues with some reflection frameworks or serialization tools
- Risk 2: Inconsistent with other code styles in the project
- Risk 3: Will be considered unprofessional during code review
**Impact Scope**:
- Direct impact: `SelectDBConfig` class itself
- Indirect impact: Getter/setter generated using Lombok
- Affected area: Single Connector (SelectDB Cloud)
**Severity**: MINOR
**Improvement Suggestion**:
```java
// SelectDBConfig.java
@Setter
@Getter
public class SelectDBConfig implements Serializable {
private static final long serialVersionUID = 1L;
// ... other fields
// Before: private Properties StageLoadProps;
// After:
private Properties stageLoadProps; // ✅ Use camelCase naming
}
```
**Rationale**:
1. Complies with Java naming conventions (instance fields use camelCase)
2. Consistent with other Connectors (Doris, JDBC) in the project
3. Although Lombok can handle this case, non-standard names will cause maintenance trouble
4. After modification, Lombok will generate `getStageLoadProps()` and `setStageLoadProps(Properties)` methods, API remains unchanged and does not affect callers
**Locations requiring synchronous modification**:
- `SelectDBConfig.java:49` - Field declaration
- No need to modify callers (because getter/setter method names remain unchanged)
---
### Issue 2: Incomplete test coverage - Missing null value scenario tests
**Location**: `SelectDBConfigSerializableTest.java:33-84`
**Related Context**:
- Test file: `SelectDBConfigSerializableTest.java`
- Class under test: `SelectDBConfig.java`
- Usage scenario: `SelectDBStageLoad.java:87-88`
**Issue Description**:
The test only covers the scenario where `stageLoadProps` is not null, and does not test the serialization behavior when the field is `null`.
```java
// Current test (lines 49-51)
Properties stageLoadProps = new Properties();
stageLoadProps.setProperty("file.type", "json");
config.setStageLoadProps(stageLoadProps); // Always set non-null value
// Missing test scenarios
SelectDBConfig config2 = new SelectDBConfig();
config2.setLoadUrl("localhost:8080");
// Don't set stageLoadProps, keep it null
// Verify if null value is preserved after serialization/deserialization
```
**Potential Risks**:
- Risk 1: Cannot ensure correct serialization behavior when the user does not configure `selectdb.sink.config.prefix`
- Risk 2: If the serialization framework has special handling for null, it may introduce bugs
- Risk 3: The null pointer risk at `SelectDBStageLoad.java:88` is not covered by tests
**Impact Scope**:
- Direct impact: Test coverage rate
- Indirect impact: Production environment stability (if the user does not configure this parameter)
- Affected area: Single Connector
**Severity**: MAJOR
**Improvement Suggestion**:
```java
// SelectDBConfigSerializableTest.java
@Test
void testSelectDBConfigSerializableWithNullProps() throws Exception {
// Arrange
SelectDBConfig config = new SelectDBConfig();
config.setLoadUrl("localhost:8080");
config.setJdbcUrl("localhost:9030");
config.setUsername("user");
config.setPassword("pwd");
// Don't set stageLoadProps, keep it null (simulating user not configured)
// Act: Serialize
byte[] serialized;
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream =
new ObjectOutputStream(byteArrayOutputStream)) {
objectOutputStream.writeObject(config);
objectOutputStream.flush();
serialized = byteArrayOutputStream.toByteArray();
}
// Act: Deserialize
SelectDBConfig deserialized;
try (ObjectInputStream objectInputStream =
new ObjectInputStream(new ByteArrayInputStream(serialized))) {
deserialized = (SelectDBConfig) objectInputStream.readObject();
}
// Assert: Verify null value is correctly preserved
Assertions.assertEquals(config.getLoadUrl(), deserialized.getLoadUrl());
Assertions.assertEquals(config.getJdbcUrl(), deserialized.getJdbcUrl());
Assertions.assertNull(deserialized.getStageLoadProps()); // ✅ Verify null value
}
@Test
void testSelectDBConfigSerializableWithEmptyProps() throws Exception {
// Arrange: Test empty Properties
SelectDBConfig config = new SelectDBConfig();
config.setLoadUrl("localhost:8080");
config.setStageLoadProps(new Properties()); // Empty Properties
// Act & Assert: Similar to serialization/deserialization above
// ...
Assertions.assertNotNull(deserialized.getStageLoadProps());
Assertions.assertTrue(deserialized.getStageLoadProps().isEmpty());
}
```
**Rationale**:
1. In production environments, users may not configure `selectdb.sink.config.prefix`, in which case `stageLoadProps` is null
2. Serializing null values is a common scenario and should be covered by tests
3. This will help expose the potential NPE issue in `SelectDBStageLoad.java:88`
4. The cost of adding test cases is very low, but can significantly improve code quality
**Locations requiring synchronous modification**:
- Only test files need to be modified
- Production code does not need to be modified
---
### Issue 3: Potential null pointer exception risk (Existing issue)
**Location**: `SelectDBStageLoad.java:87-88`
**Related Context**:
- Caller: `SelectDBStageLoad` constructor
- Dependency class: `SelectDBConfig` configuration loading (`SelectDBConfig.java:59-63`)
**Issue Description**:
When the user does not configure `selectdb.sink.config.prefix`, `SelectDBConfig.getStageLoadProps()` returns `null`, but the `SelectDBStageLoad` constructor calls the method directly without null checking.
```java
// SelectDBConfig.java:59-63
if (pluginConfig.getOptional(SelectDBSinkOptions.SELECTDB_SINK_CONFIG_PREFIX).isPresent()) {
Properties properties = new Properties();
properties.putAll(pluginConfig.get(SelectDBSinkOptions.SELECTDB_SINK_CONFIG_PREFIX));
selectdbConfig.setStageLoadProps(properties);
}
// If condition is not met, stageLoadProps remains null
// SelectDBStageLoad.java:87-88
this.stageLoadProps = selectdbConfig.getStageLoadProps(); // Possibly null
this.lineDelimiter = stageLoadProps.getProperty(LINE_DELIMITER_KEY, LINE_DELIMITER_DEFAULT);
// ^^^^^^^^^^^^^^ If null, throws NullPointerException
```
**Potential Risks**:
- Risk 1: Task crashes when the user does not configure optional parameters
- Risk 2: Error message is unclear (NPE rather than friendly configuration error prompt)
- Risk 3: After fixing the serialization issue, this problem is easier to trigger (because serialization will not initialize null fields)
**Impact Scope**:
- Direct impact: Constructor of `SelectDBStageLoad` class
- Indirect impact: All tasks using SelectDB Cloud Sink that do not configure `selectdb.sink.config.prefix`
- Affected area: Single Connector
**Severity**: MAJOR
**Improvement Suggestion**:
```java
// SelectDBStageLoad.java
public SelectDBStageLoad(SelectDBConfig selectdbConfig, LabelGenerator labelGenerator) {
this.selectdbConfig = selectdbConfig;
this.hostPort = selectdbConfig.getLoadUrl();
this.username = selectdbConfig.getUsername();
this.password = selectdbConfig.getPassword();
this.labelGenerator = labelGenerator;
this.uploadUrl = String.format(UPLOAD_URL_PATTERN, hostPort);
// Solution 1: Use null-safe default value
Properties props = selectdbConfig.getStageLoadProps();
this.stageLoadProps = props != null ? props : new Properties();
this.lineDelimiter = this.stageLoadProps.getProperty(LINE_DELIMITER_KEY, LINE_DELIMITER_DEFAULT);
// Or Solution 2: Explicitly handle null
// this.stageLoadProps = selectdbConfig.getStageLoadProps();
// this.lineDelimiter = this.stageLoadProps != null
// ? this.stageLoadProps.getProperty(LINE_DELIMITER_KEY, LINE_DELIMITER_DEFAULT)
// : LINE_DELIMITER_DEFAULT;
// ... remaining code
}
```
**Rationale**:
1. This is an **existing bug**, not introduced by this PR
2. However, after fixing the serialization issue, this bug is more easily exposed (the field remains null after deserialization)
3. Friendly default behavior should be provided instead of throwing NPE
4. `Properties.getProperty()` itself supports default values and should utilize this feature
**Locations requiring synchronous modification**:
- `SelectDBStageLoad.java:87-88` - Add null check or default value
- `SelectDBConfig.java` - Optional: Initialize default empty Properties in the `loadConfig()` method
**Priority Note**:
Although this issue was not introduced by this PR, since it is associated with the serialization fix (serialization will not "fix" null values), it is recommended to follow up with the fix immediately after merging.
---
---
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org