Grant Overby created KAFKA-2297:
-----------------------------------

             Summary: VerifiableProperties fails when constructed with 
Properties with numeric values
                 Key: KAFKA-2297
                 URL: https://issues.apache.org/jira/browse/KAFKA-2297
             Project: Kafka
          Issue Type: Bug
          Components: clients
    Affects Versions: 0.8.2.1
         Environment: Ubuntu 12.04, OSX 10.9, OpenJDK 7, Scala 2.10
            Reporter: Grant Overby
            Priority: Minor


VarifiableProperties produces java.lang.NumberFormatException: null when a get 
method for a numeric type is called and VerifiableProperties was constructed 
with a Properties containing a numeric type.

    private static void works() {
        Properties props = new Properties();
        props.put("request.required.acks", "0");
        new VerifiableProperties(props).getShort("request.required.acks", 
(short) 0);
    }

    private static void doesntWork() {
        Properties props = new Properties();
        props.put("request.required.acks", (short) 0);
        new VerifiableProperties(props).getShort("request.required.acks", 
(short) 0);
    }


Exception in thread "main" java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Integer.java:454)
        at java.lang.Short.parseShort(Short.java:117)
        at java.lang.Short.parseShort(Short.java:143)
        at 
scala.collection.immutable.StringLike$class.toShort(StringLike.scala:228)
        at scala.collection.immutable.StringOps.toShort(StringOps.scala:31)
        at 
kafka.utils.VerifiableProperties.getShortInRange(VerifiableProperties.scala:85)
        at 
kafka.utils.VerifiableProperties.getShort(VerifiableProperties.scala:61)
        at Main.doesntWork(Main.java:22)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to