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

Evan Fagerberg edited comment on SOLR-11647 at 11/17/17 7:01 PM:
-----------------------------------------------------------------

Hey [~hossman] thanks for the reply. Yeah that is something we are scratching 
our heads about as well I believe that file is about solr cloud functionality 
and not an embedded solr server which is what we are using.

I will check to see which noggit we are using, that is a good suggestion.

Here is an example base class we use that will fail on the 
{noformat}coreContainer.load(){noformat} because of the json parse error.

{code}
import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;

public class SolrTest {

  static CoreContainer coreContainer;
  protected SolrServer solr;

    @BeforeClass
    public static void startup() throws Exception {
      FileUtils.cleanDirectory(new File("solr/collection1/data/"));
      FileUtils.cleanDirectory(new File("solr/collection1/suggestIndex/"));
      // start an embedded solr instance
      coreContainer = new CoreContainer("solr");
      coreContainer.load();
    }

    @AfterClass
    public static void shutdown() throws Exception {
        SolrCore core = getDefaultCore();
        if (core != null) {
            core.close();
        }
        coreContainer.shutdown();
        FileUtils.cleanDirectory(new File("solr/collection1/data/"));
        FileUtils.cleanDirectory(new File("solr/collection1/suggestIndex/"));
        coreContainer = null;
    }

    @Before
    public void init() throws Exception {
        solr = new EmbeddedSolrServer(coreContainer, "collection1");
        clearIndex();
    }
    
    protected void clearIndex () throws SolrServerException, IOException {
        solr.deleteByQuery("*:*");
        solr.commit(true, true, false);
    }
    
    protected static SolrCore getDefaultCore() {
      return coreContainer.getCore("collection1");
    }

    @After
    public void cleanup() throws Exception {}
}
{code}


was (Author: efagerberg):
Hey [~hossman] thanks for the reply. Yeah that is something we are scratching 
our heads about as well I believe that file is about solr cloud functionality 
and not an embedded solr server which is what we are using.

I will check to see which noggit we are using, that is a good suggestion.

Here is an example base class we use that will fail on the 
{noformat}coreContainer.load{noformat} because of the json parse error.

{code}
import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;

public class SolrTest {

  static CoreContainer coreContainer;
  protected SolrServer solr;

    @BeforeClass
    public static void startup() throws Exception {
      FileUtils.cleanDirectory(new File("solr/collection1/data/"));
      FileUtils.cleanDirectory(new File("solr/collection1/suggestIndex/"));
      // start an embedded solr instance
      coreContainer = new CoreContainer("solr");
      coreContainer.load();
    }

    @AfterClass
    public static void shutdown() throws Exception {
        SolrCore core = getDefaultCore();
        if (core != null) {
            core.close();
        }
        coreContainer.shutdown();
        FileUtils.cleanDirectory(new File("solr/collection1/data/"));
        FileUtils.cleanDirectory(new File("solr/collection1/suggestIndex/"));
        coreContainer = null;
    }

    @Before
    public void init() throws Exception {
        solr = new EmbeddedSolrServer(coreContainer, "collection1");
        clearIndex();
    }
    
    protected void clearIndex () throws SolrServerException, IOException {
        solr.deleteByQuery("*:*");
        solr.commit(true, true, false);
    }
    
    protected static SolrCore getDefaultCore() {
      return coreContainer.getCore("collection1");
    }

    @After
    public void cleanup() throws Exception {}
}
{code}

> SolrJ's autoscaling.Commands.json has invalid json
> --------------------------------------------------
>
>                 Key: SOLR-11647
>                 URL: https://issues.apache.org/jira/browse/SOLR-11647
>             Project: Solr
>          Issue Type: Bug
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: AutoScaling
>            Reporter: Evan Fagerberg
>              Labels: test
>
> https://github.com/apache/lucene-solr/blob/master/solr/solrj/src/resources/apispec/autoscaling.Commands.json#L165-L169
> Contains a block that has a commented out json stanza. When using solrj this 
> will fail at the json parsing step 
> {noformat}
> org.apache.solr.common.SolrException: Error in JSON : 
> apispec/autoscaling.Commands.json
>       at 
> org.apache.solr.common.util.ValidatingJsonMap.parse(ValidatingJsonMap.java:323)
>       at org.apache.solr.common.util.Utils.lambda$getSpec$0(Utils.java:394)
>       at 
> org.apache.solr.common.util.Utils$$Lambda$45/2131952342.getSpec(Unknown 
> Source)
>       at org.apache.solr.api.Api.getSpec(Api.java:65)
>       at org.apache.solr.api.ApiBag.register(ApiBag.java:73)
>       at org.apache.solr.core.PluginBag.put(PluginBag.java:217)
>       at org.apache.solr.core.PluginBag.put(PluginBag.java:188)
>       at 
> org.apache.solr.core.CoreContainer.createHandler(CoreContainer.java:1526)
>       at org.apache.solr.core.CoreContainer.load(CoreContainer.java:539)
>       --our solr test case with a setup that loads a core container --
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:483)
>       at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
>       at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>       at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
>       at 
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
>       at 
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
>       at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
>       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
>       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
>       at 
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
>       at 
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
> Caused by: org.noggit.JSONParser$ParseException: Expected string: 
> char=/,position=4851 BEFORE=' to add and update policies that apply to 
> collections", /' AFTER='* "patternProperties": { "^.+$'
>       at org.noggit.JSONParser.err(JSONParser.java:223)
>       at org.noggit.JSONParser.nextEvent(JSONParser.java:693)
>       at org.noggit.ObjectBuilder.getObject(ObjectBuilder.java:123)
>       at org.noggit.ObjectBuilder.getVal(ObjectBuilder.java:57)
>       at org.noggit.ObjectBuilder.getObject(ObjectBuilder.java:127)
>       at 
> org.apache.solr.common.util.ValidatingJsonMap.fromJSON(ValidatingJsonMap.java:251)
>       at 
> org.apache.solr.common.util.ValidatingJsonMap.fromJSON(ValidatingJsonMap.java:246)
>       at 
> org.apache.solr.common.util.ValidatingJsonMap.parse(ValidatingJsonMap.java:321)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to