You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Zakelly (via GitHub)" <gi...@apache.org> on 2023/09/20 10:04:27 UTC
[GitHub] [flink] Zakelly opened a new pull request, #23441: [FLINK-33060] Fix the javadoc of ListState interfaces about not allowing null value
Zakelly opened a new pull request, #23441:
URL: https://github.com/apache/flink/pull/23441
## What is the purpose of the change
After FLINK-8411, the ListState.update/add/addAll do not allow a null value passed in, while the javadoc says "If null is passed in, the state value will remain unchanged". This should be fixed.
## Brief change log
The javadoc of ListState#update/addAll, InternalListState#update/addAll and AppendingState#add.
## Verifying this change
This change is a trivial work without any test coverage.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (yes / **no**)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
- The serializers: (yes / **no** / don't know)
- The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / **no** / don't know)
- The S3 file system connector: (yes / **no** / don't know)
## Documentation
- Does this pull request introduce a new feature? (yes / **no**)
- If yes, how is the feature documented? (**not applicable** / docs / JavaDocs / not documented)
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33060] Fix the javadoc of ListState interfaces about not allowing null value [flink]
Posted by "masteryhx (via GitHub)" <gi...@apache.org>.
masteryhx commented on code in PR #23441:
URL: https://github.com/apache/flink/pull/23441#discussion_r1382767597
##########
flink-core/src/main/java/org/apache/flink/api/common/state/AppendingState.java:
##########
@@ -58,10 +58,11 @@ public interface AppendingState<IN, OUT> extends State {
* of values. The next time {@link #get()} is called (for the same state partition) the returned
* state will represent the updated list.
*
- * <p>If null is passed in, the state value will remain unchanged.
+ * <p>If null is passed in, the behaviour is undefined (implementation related).
Review Comment:
Sure. I could get this.
How about adding TODO description here? Then users could also get the reason.
Then let's unify them in 2.0.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #23441: [FLINK-33060] Fix the javadoc of ListState interfaces about not allowing null value
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #23441:
URL: https://github.com/apache/flink/pull/23441#issuecomment-1727408582
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "99f4dd9965ba131ba6abceada5a9969555fbb033",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "99f4dd9965ba131ba6abceada5a9969555fbb033",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 99f4dd9965ba131ba6abceada5a9969555fbb033 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] Zakelly commented on pull request #23441: [FLINK-33060] Fix the javadoc of ListState interfaces about not allowing null value
Posted by "Zakelly (via GitHub)" <gi...@apache.org>.
Zakelly commented on PR #23441:
URL: https://github.com/apache/flink/pull/23441#issuecomment-1728686306
@flinkbot run azure
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33060] Fix the javadoc of ListState interfaces about not allowing null value [flink]
Posted by "Zakelly (via GitHub)" <gi...@apache.org>.
Zakelly commented on code in PR #23441:
URL: https://github.com/apache/flink/pull/23441#discussion_r1382739665
##########
flink-core/src/main/java/org/apache/flink/api/common/state/ListState.java:
##########
@@ -48,10 +48,13 @@ public interface ListState<T> extends MergingState<T, Iterable<T>> {
* given list of values. The next time {@link #get()} is called (for the same state partition)
* the returned state will represent the updated list.
*
- * <p>If null or an empty list is passed in, the state value will be null.
+ * <p>If an empty list is passed in, the state value will be null.
Review Comment:
Agreed. A more unified behaviour makes sense. Let's do this in 2.0.
##########
flink-core/src/main/java/org/apache/flink/api/common/state/AppendingState.java:
##########
@@ -58,10 +58,11 @@ public interface AppendingState<IN, OUT> extends State {
* of values. The next time {@link #get()} is called (for the same state partition) the returned
* state will represent the updated list.
*
- * <p>If null is passed in, the state value will remain unchanged.
+ * <p>If null is passed in, the behaviour is undefined (implementation related).
Review Comment:
The current situation is that all implementations are not unified. This comment describe the current situation.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] davidradl commented on a diff in pull request #23441: [FLINK-33060] Fix the javadoc of ListState interfaces about not allowing null value
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #23441:
URL: https://github.com/apache/flink/pull/23441#discussion_r1337464779
##########
flink-core/src/main/java/org/apache/flink/api/common/state/AppendingState.java:
##########
@@ -60,8 +60,11 @@ public interface AppendingState<IN, OUT> extends State {
*
* <p>If null is passed in, the state value will remain unchanged.
*
+ * <p>Except for list state, where null value is not allowed to be passed in.
Review Comment:
I think when referring to list state you mean the ListState interface. I do not think that a parent interface should document special behaviour for a child interface. This breaks to the solid principle Liskov Substitution Principle and is not good practice.
It would be cleaner to have 2 parent interfaces; a null policing interface (extended by ListState) and a null tolerant interface for the other implementations.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33060] Fix the javadoc of ListState interfaces about not allowing null value [flink]
Posted by "Zakelly (via GitHub)" <gi...@apache.org>.
Zakelly commented on code in PR #23441:
URL: https://github.com/apache/flink/pull/23441#discussion_r1349473352
##########
flink-core/src/main/java/org/apache/flink/api/common/state/AppendingState.java:
##########
@@ -60,8 +60,11 @@ public interface AppendingState<IN, OUT> extends State {
*
* <p>If null is passed in, the state value will remain unchanged.
*
+ * <p>Except for list state, where null value is not allowed to be passed in.
Review Comment:
Agreed. I believe it would be better to eliminate the description of the null value at the moment, considering the implementations have already become varied. We can consider refactoring the interfaces in the upcoming major version. What do you think? @davidradl
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] davidradl commented on a diff in pull request #23441: [FLINK-33060] Fix the javadoc of ListState interfaces about not allowing null value
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #23441:
URL: https://github.com/apache/flink/pull/23441#discussion_r1337464779
##########
flink-core/src/main/java/org/apache/flink/api/common/state/AppendingState.java:
##########
@@ -60,8 +60,11 @@ public interface AppendingState<IN, OUT> extends State {
*
* <p>If null is passed in, the state value will remain unchanged.
*
+ * <p>Except for list state, where null value is not allowed to be passed in.
Review Comment:
I think when referring to list state you mean the ListState interface. I do not think that a parent interface should document special behaviour for a child interface. This breaks to the solid principle Liskov Substitution Principle and is not good practice.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] Zakelly commented on pull request #23441: [FLINK-33060] Fix the javadoc of ListState interfaces about not allowing null value
Posted by "Zakelly (via GitHub)" <gi...@apache.org>.
Zakelly commented on PR #23441:
URL: https://github.com/apache/flink/pull/23441#issuecomment-1729445124
@masteryhx Would you please review this PR? Thanks.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33060] Fix the javadoc of ListState interfaces about not allowing null value [flink]
Posted by "Zakelly (via GitHub)" <gi...@apache.org>.
Zakelly commented on PR #23441:
URL: https://github.com/apache/flink/pull/23441#issuecomment-1760741020
> Thanks for the pr! Changes about these comments LGTM. But I found some implementaion is not consistent. (See PartitionableListState#update, PartitionableListState#addAll,BatchExecutionKeyListState)
>
> I think we should also make them follow the comment, WDYT ?
Good point, I added sanity check in those implementations.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33060] Fix the javadoc of ListState interfaces about not allowing null value [flink]
Posted by "masteryhx (via GitHub)" <gi...@apache.org>.
masteryhx closed pull request #23441: [FLINK-33060] Fix the javadoc of ListState interfaces about not allowing null value
URL: https://github.com/apache/flink/pull/23441
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33060] Fix the javadoc of ListState interfaces about not allowing null value [flink]
Posted by "Zakelly (via GitHub)" <gi...@apache.org>.
Zakelly commented on PR #23441:
URL: https://github.com/apache/flink/pull/23441#issuecomment-1801079127
The spotless check is failed. I openend https://github.com/apache/flink/pull/23683 to fix this. Sorry for the mistake.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33060] Fix the javadoc of ListState interfaces about not allowing null value [flink]
Posted by "masteryhx (via GitHub)" <gi...@apache.org>.
masteryhx commented on code in PR #23441:
URL: https://github.com/apache/flink/pull/23441#discussion_r1382731932
##########
flink-core/src/main/java/org/apache/flink/api/common/state/AppendingState.java:
##########
@@ -58,10 +58,11 @@ public interface AppendingState<IN, OUT> extends State {
* of values. The next time {@link #get()} is called (for the same state partition) the returned
* state will represent the updated list.
*
- * <p>If null is passed in, the state value will remain unchanged.
+ * <p>If null is passed in, the behaviour is undefined (implementation related).
Review Comment:
Could we unify the behavious of all sub classes?
I think "undefined" maybe also confuse users.
##########
flink-core/src/main/java/org/apache/flink/api/common/state/ListState.java:
##########
@@ -48,10 +48,13 @@ public interface ListState<T> extends MergingState<T, Iterable<T>> {
* given list of values. The next time {@link #get()} is called (for the same state partition)
* the returned state will represent the updated list.
*
- * <p>If null or an empty list is passed in, the state value will be null.
+ * <p>If an empty list is passed in, the state value will be null.
Review Comment:
Maybe it's also better to unify the behavious of null and empty list in the future.
But this may modify the semantic of public API so it could be done in 2.0. WDYT?
##########
flink-runtime/src/main/java/org/apache/flink/runtime/state/PartitionableListState.java:
##########
@@ -122,15 +124,26 @@ public long[] write(FSDataOutputStream out) throws IOException {
@Override
public void update(List<S> values) {
+ checkNotNull(values, "List of values to add cannot be null.");
+
internalList.clear();
- addAll(values);
+ if (!values.isEmpty()) {
Review Comment:
Could we just also use `addAll` here ?
##########
flink-core/src/main/java/org/apache/flink/api/common/state/AppendingState.java:
##########
@@ -58,10 +58,11 @@ public interface AppendingState<IN, OUT> extends State {
* of values. The next time {@link #get()} is called (for the same state partition) the returned
* state will represent the updated list.
*
- * <p>If null is passed in, the state value will remain unchanged.
+ * <p>If null is passed in, the behaviour is undefined (implementation related).
*
* @param value The new value for the state.
- * @throws Exception Thrown if the system cannot access the state.
+ * @throws Exception Thrown if the system cannot access the state, or null value is passed to
Review Comment:
This seems conflict with last "undefined".
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33060] Fix the javadoc of ListState interfaces about not allowing null value [flink]
Posted by "Zakelly (via GitHub)" <gi...@apache.org>.
Zakelly commented on PR #23441:
URL: https://github.com/apache/flink/pull/23441#issuecomment-1760742148
> I suggest a cleaner approach with the interfaces.
I remove the description for ListState in the base interface.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org