Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 4.5
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      I want write tests for some of our own components which internally use a SolrCore. As SolrCore is defined final, I cannot mock it and instead have to create an instance of it. Therefore I came across the following constructor:

      public SolrCore(String name, CoreDescriptor cd) {
          this.setName(name);
          coreDescriptor = cd;
          this.schema = null;
          this.dataDir = null;
          this.solrConfig = null;
          this.startTime = System.currentTimeMillis();
          this.maxWarmingSearchers = 2;  // we don't have a config yet, just pick a number.
          this.resourceLoader = null;
          this.updateHandler = null;
          this.isReloaded = true;
          this.reqHandlers = null;
          this.searchComponents = null;
          this.updateProcessorChains = null;
          this.infoRegistry = null;
          this.codec = null;
      
          solrCoreState = null;
      }
      

      When calling this constructor there will always be a NullPointerException, because of the call of setName(...) before coreDescriptor is set. In setName this.coreDescriptor (which was not yet set) is being used:

      public void setName(String v) {
          this.name = v;
          this.logid = (v==null)?"":("["+v+"] ");
          this.coreDescriptor = new CoreDescriptor(v, this.coreDescriptor);
      }
      

      The fix probably is to set the coreDesciptor first and then call setName.

        Activity

        Noble Paul made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Noble Paul [ noble.paul ]
        Resolution Fixed [ 1 ]
        Hide
        Noble Paul added a comment -

        committed

        Show
        Noble Paul added a comment - committed
        Hide
        ASF subversion and git services added a comment -

        Commit 1536847 from Noble Paul in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1536847 ]

        SOLR-5400

        Show
        ASF subversion and git services added a comment - Commit 1536847 from Noble Paul in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1536847 ] SOLR-5400
        Hide
        ASF subversion and git services added a comment -

        Commit 1536846 from Noble Paul in branch 'dev/trunk'
        [ https://svn.apache.org/r1536846 ]

        SOLR-5400

        Show
        ASF subversion and git services added a comment - Commit 1536846 from Noble Paul in branch 'dev/trunk' [ https://svn.apache.org/r1536846 ] SOLR-5400
        Pascal Chollet created issue -

          People

          • Assignee:
            Noble Paul
            Reporter:
            Pascal Chollet
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development