[
https://issues.apache.org/jira/browse/FLINK-4309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15422392#comment-15422392
]
ASF GitHub Bot commented on FLINK-4309:
---------------------------------------
Github user tillrohrmann commented on a diff in the pull request:
https://github.com/apache/flink/pull/2371#discussion_r74893388
--- Diff:
flink-core/src/main/java/org/apache/flink/configuration/DelegatingConfiguration.java
---
@@ -178,14 +178,19 @@ public String toString() {
@Override
public Set<String> keySet() {
+
final HashSet<String> set = new HashSet<String>();
- final int prefixLen = this.prefix == null ? 0 :
this.prefix.length();
for (String key : this.backingConfig.keySet()) {
- if (key.startsWith(this.prefix)) {
+
+ if (this.prefix == null) {
--- End diff --
Can we move the condition out of the loop? The condition does not change
over different iteration so we don't have to perform it every time.
> Potential null pointer dereference in DelegatingConfiguration#keySet()
> ----------------------------------------------------------------------
>
> Key: FLINK-4309
> URL: https://issues.apache.org/jira/browse/FLINK-4309
> Project: Flink
> Issue Type: Bug
> Reporter: Ted Yu
> Assignee: Sunny T
> Priority: Minor
>
> {code}
> final int prefixLen = this.prefix == null ? 0 : this.prefix.length();
> for (String key : this.backingConfig.keySet()) {
> if (key.startsWith(this.prefix)) {
> {code}
> If this.prefix == null, we would get NPE in startsWith():
> {code}
> public boolean startsWith(String prefix, int toffset) {
> char ta[] = value;
> int to = toffset;
> char pa[] = prefix.value;
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)