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

Karl Wright commented on SOLR-3015:
-----------------------------------

Finally had a moment to look at this.  The code (in 
org.apache.solr.core.SolrResourceLoader) explicitly excludes 
QParserPlugin-derived classes from being SolrCoreAware:

{code}
  /**
   * Keep a list of classes that are allowed to implement each 'Aware' interface
   */
  private static final Map<Class, Class[]> awareCompatibility;
  static {
    awareCompatibility = new HashMap<Class, Class[]>();
    awareCompatibility.put( 
      SolrCoreAware.class, new Class[] {
        SolrRequestHandler.class,
        QueryResponseWriter.class,
        SearchComponent.class,
        UpdateRequestProcessorFactory.class
      }
    );

    awareCompatibility.put(
      ResourceLoaderAware.class, new Class[] {
        CharFilterFactory.class,
        TokenFilterFactory.class,
        TokenizerFactory.class,
        QParserPlugin.class,
        FieldType.class
      }
    );
  }

  /**
   * Utility function to throw an exception if the class is invalid
   */
  void assertAwareCompatibility( Class aware, Object obj )
  {
    Class[] valid = awareCompatibility.get( aware );
    if( valid == null ) {
      throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
          "Unknown Aware interface: "+aware );
    }
    for( Class v : valid ) {
      if( v.isInstance( obj ) ) {
        return;
      }
    }
    StringBuilder builder = new StringBuilder();
    builder.append( "Invalid 'Aware' object: " ).append( obj );
    builder.append( " -- ").append( aware.getName() );
    builder.append(  " must be an instance of: " );
    for( Class v : valid ) {
      builder.append( "[" ).append( v.getName() ).append( "] ") ;
    }
    throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, 
builder.toString() );
  }
{code}

There's no indication of why this should be.  I'm therefore going to experiment 
and see if the simple patch of including QParserPlugins in the SolrCoreAware 
list seems to work, and if so include a patch.

                
> CloseHook cannot be used with QParserPlugins
> --------------------------------------------
>
>                 Key: SOLR-3015
>                 URL: https://issues.apache.org/jira/browse/SOLR-3015
>             Project: Solr
>          Issue Type: Bug
>            Reporter: Karl Wright
>              Labels: closehook, qparserplugin, solrcoreaware
>
> For some kinds of plugins, the CloseHook API works well to allow the plugin 
> to clean up any resources it was using prior to Solr shutdown.  But for 
> QParserPlugins, CloseHook does not work; you get an error if you try to use 
> it.  This occurs because the QParserPlugin cannot be made SolrCoreAware:
> {code}
>     [junit] org.apache.solr.common.SolrException: Invalid 'Aware' object: 
> org.apache.solr.mcf.ManifoldCFQParserPlugin@18941f7 -- 
> org.apache.solr.util.plugin.SolrCoreAware must be an instance of: 
> [org.apache.solr.request.SolrRequestHandler]
> [org.apache.solr.response.QueryResponseWriter] 
> [org.apache.solr.handler.component.SearchComponent] 
> [org.apache.solr.update.processor.UpdateRequestProcessorFactory] 
> [org.apache.solr.handler.component.ShardHandlerFactory]
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

Reply via email to