[ 
https://issues.apache.org/jira/browse/FLINK-4309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15420659#comment-15420659
 ] 

ASF GitHub Bot commented on FLINK-4309:
---------------------------------------

Github user aljoscha commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2371#discussion_r74724570
  
    --- Diff: 
flink-core/src/test/java/org/apache/flink/configuration/DelegatingConfigurationTest.java
 ---
    @@ -88,4 +90,49 @@ private String typeParamToString(Class<?>[] classes) {
                        assertTrue("Foo method '" + 
configurationMethod.getName() + "' has not been wrapped correctly in 
DelegatingConfiguration wrapper", hasMethod);
                }
        }
    +   
    +   @Test
    +   public void testDelegationConfigurationWithNullPrefix() {
    +
    +           Configuration backingConf = new Configuration();
    +           backingConf.setValueInternal("test-key", "value");
    +
    +           DelegatingConfiguration configuration = new 
DelegatingConfiguration(
    +                           backingConf, null);
    +           Set<String> keySet = configuration.keySet();
    +
    +           assertEquals(keySet, backingConf.keySet());
    +
    +   }
    +
    +   @Test
    +   public void testDelegationConfigurationWithPrefix() {
    +
    +           String prefix = "pref-";
    +
    +           /*
    +            * Key matches the prefix
    +            */
    +           Configuration backingConf = new Configuration();
    +           backingConf.setValueInternal("pref-key", "value");
    --- End diff --
    
    I think `"pref-"` can be replaced by the `prefix` variable, just to make it 
consistent.


> 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
>            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)

Reply via email to