lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shai Erera (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENE-2436) FilterIndexReader doesn't delegate everything necessary
Date Mon, 03 May 2010 06:11:55 GMT

    [ https://issues.apache.org/jira/browse/LUCENE-2436?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12863246#action_12863246
] 

Shai Erera commented on LUCENE-2436:
------------------------------------

FWIW, there's a test I wrote for ParallelWriter to ensure it overrides all of IndexWriter
methods:

{code}
private String normalizeMethodName(Method method) {
  String mstr = method.toGenericString();
  int orgIdx = mstr.indexOf("org");
  int nameIdx = mstr.indexOf(method.getName());
  String normalizedName = mstr.substring(0, orgIdx) + mstr.substring(nameIdx);
  return normalizedName;
}
	
@Test
public void testIndexWriterOverrides() throws Exception {
  // The following methods are not overridden by ParallelWriter, usually
  // because they are trivial, or PW has nothing special to do with them.
  Set<String> methodsNotOverridden = new HashSet<String>();
  methodsNotOverridden.add(normalizeMethodName(IndexWriter.class.getMethod("getConfig")));
  methodsNotOverridden.add(normalizeMethodName(IndexWriter.class.getMethod("getInfoStream")));
  methodsNotOverridden.add(normalizeMethodName(IndexWriter.class.getMethod("message", String.class)));
  	  
  Set<String> pwMethods = new HashSet<String>();
  for (Method m : ParallelWriter.class.getDeclaredMethods()) {
    String normName = normalizeMethodName(m);
    int mod = m.getModifiers();
    if (!Modifier.isPrivate(mod) && !Modifier.isFinal(mod) && !Modifier.isStatic(mod))
{
      pwMethods.add(normName);
    }
  }
  		
  for (Method m : IndexWriter.class.getDeclaredMethods()) {
    int mod = m.getModifiers();
    if (!Modifier.isPrivate(mod) && !Modifier.isFinal(mod) && !Modifier.isStatic(mod))
{
      String normName = normalizeMethodName(m);
      if (!methodsNotOverridden.contains(normName)) {
        assertTrue("ParallelWriter does not override " + normName, pwMethods.contains(normName));
      } else if (pwMethods.contains(normName)) {
        fail("mothod " + normName + " is set as not overridden by ParallelWriter, but it is.
Remove it from methodsNotOverridden set.");
      }
    }
  }
}
{code}

I don't know what VirtualMethod is, but this test allows for specifying some methods that
are ok not to be overridden. normalizeMethodName ignores the FQDN of the method, which obviously
changes when you override it. Take a look - might give you something to start with.

> FilterIndexReader doesn't delegate everything necessary
> -------------------------------------------------------
>
>                 Key: LUCENE-2436
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2436
>             Project: Lucene - Java
>          Issue Type: Bug
>            Reporter: Yonik Seeley
>             Fix For: 4.0.0
>
>
> Some new methods like fields() aren't delegated by FilterIndexReader, incorrectly resulting
in the IndexReader base class method being used.  We should audit all current IndexReader
methods to determine which should be overridden and delegated.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message