You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Yun Tang (Jira)" <ji...@apache.org> on 2022/04/02 08:23:00 UTC
[jira] [Resolved] (FLINK-26738) Default value of StateDescriptor is valid when enable state ttl config
[ https://issues.apache.org/jira/browse/FLINK-26738?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Yun Tang resolved FLINK-26738.
------------------------------
Fix Version/s: 1.15.0
1.16.0
1.14.5
Resolution: Fixed
merged in master: 5045f1f68687785b472536bfa041b09e9e896816
release-1.15: b3428b345a230446d7a502ef5e6827a2ab826d4e
release-1.14: d706b8169faa77dd126d923db326709dc5631a37
> Default value of StateDescriptor is valid when enable state ttl config
> ----------------------------------------------------------------------
>
> Key: FLINK-26738
> URL: https://issues.apache.org/jira/browse/FLINK-26738
> Project: Flink
> Issue Type: Bug
> Components: API / Core
> Affects Versions: 1.15.0
> Reporter: Jianhui Dong
> Assignee: Jianhui Dong
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.15.0, 1.16.0, 1.14.5
>
>
> Suppose we declare a ValueState like following:
> {code:java}
> ValueStateDescriptor<Tuple2<Long, Long>> descriptor =
> new ValueStateDescriptor<>(
> "average", // the state name
> TypeInformation.of(new TypeHint<Tuple2<Long, Long>>() {}),
> Tuple2.of(0L, 0L));
> {code}
> and then we add state ttl config to the state:
> {code:java}
> descriptor.enableTimeToLive(StateTtlConfigUtil.createTtlConfig(60000));
> {code}
> the default value Tuple2.of(0L, 0L) will be invalid and may cause NPE.
> I don't know if this is a bug cause I see @Deprecated in the comment of the ValueStateDescriptor constructor with argument defaultValue:
> {code:java}
> Use {@link #ValueStateDescriptor(String, TypeSerializer)} instead and manually
> * manage the default value by checking whether the contents of the state is {@code null}.
> {code}
> and if we decide not to use the defaultValue field in the class StateDescriptor, should we add @Deprecated annotation to the field defaultValue?
--
This message was sent by Atlassian Jira
(v8.20.1#820001)