Solr
  1. Solr
  2. SOLR-4221 Custom sharding
  3. SOLR-4925

Collection create throws NPE when 'numShards' param is missing

    Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.4
    • Component/s: None
    • Labels:
      None

      Description

      OverseerCollectionProcessor.msgStrToInt(ZkNodeProps message, String key, Integer def) throws NPE when the key value is null. I is expected to return the value of 'def'

        Activity

        Hide
        Noble Paul added a comment -

        Very interesting. This can go into a java tricks n tips book

          static Integer msgToStr(String val,Integer def ){
                return  val == null ? def : Integer.parseInt(val);
            }
        

        compiles to

          static Integer msgToStr(String val,Integer def ){
                return Integer.valueOf(val == null ? def : Integer.parseInt(val));
            }
        

        So NPE , if both 'val' and 'def' are null

        I'm committing it right away

        Show
        Noble Paul added a comment - Very interesting. This can go into a java tricks n tips book static Integer msgToStr( String val, Integer def ){ return val == null ? def : Integer .parseInt(val); } compiles to static Integer msgToStr( String val, Integer def ){ return Integer .valueOf(val == null ? def : Integer .parseInt(val)); } So NPE , if both 'val' and 'def' are null I'm committing it right away
        Hide
        Uwe Schindler added a comment -

        The code must be:

        static Integer msgToStr(String val,Integer def ){
          return  val == null ? def : Integer.valueOf(val);
        }
        

        Then it passes. It also saves boxing/unboxing multiple times.

        Show
        Uwe Schindler added a comment - The code must be: static Integer msgToStr( String val, Integer def ){ return val == null ? def : Integer .valueOf(val); } Then it passes. It also saves boxing/unboxing multiple times.
        Hide
        Uwe Schindler added a comment -

        BTW: This is one reason why I hate this autoboxing shit since Java 5. I would love to have a way to prevent it in code (forbidden checks should detect this somehow).

        Autoboxing should be possible to disable with a compiler flag, that's my opinion. Or should have never been added!

        Show
        Uwe Schindler added a comment - BTW: This is one reason why I hate this autoboxing shit since Java 5. I would love to have a way to prevent it in code (forbidden checks should detect this somehow). Autoboxing should be possible to disable with a compiler flag, that's my opinion. Or should have never been added!
        Hide
        Noble Paul added a comment -

        Actually Integer.valueOf() internally calls the parseInt . However Integer.valueOf(val) is better

        Show
        Noble Paul added a comment - Actually Integer.valueOf() internally calls the parseInt . However Integer.valueOf(val) is better
        Hide
        Commit Tag Bot added a comment -

        [trunk commit] noble
        http://svn.apache.org/viewvc?view=revision&revision=1492808

        SOLR-4925 Collection create throws NPE when 'numShards' param is missing

        Show
        Commit Tag Bot added a comment - [trunk commit] noble http://svn.apache.org/viewvc?view=revision&revision=1492808 SOLR-4925 Collection create throws NPE when 'numShards' param is missing
        Hide
        Noble Paul added a comment -

        Committed revision 1492808.

        Show
        Noble Paul added a comment - Committed revision 1492808.
        Hide
        Commit Tag Bot added a comment -

        [branch_4x commit] noble
        http://svn.apache.org/viewvc?view=revision&revision=1492811

        SOLR-4925 Collection create throws NPE when 'numShards' param is missing

        Show
        Commit Tag Bot added a comment - [branch_4x commit] noble http://svn.apache.org/viewvc?view=revision&revision=1492811 SOLR-4925 Collection create throws NPE when 'numShards' param is missing
        Hide
        Noble Paul added a comment -

        committed to branch_4x
        revision 1492811.

        Show
        Noble Paul added a comment - committed to branch_4x revision 1492811.
        Hide
        Steve Rowe added a comment -

        Bulk close resolved 4.4 issues

        Show
        Steve Rowe added a comment - Bulk close resolved 4.4 issues

          People

          • Assignee:
            Noble Paul
            Reporter:
            Noble Paul
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development