You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Adrien Grand (JIRA)" <ji...@apache.org> on 2012/09/15 11:24:07 UTC

[jira] [Created] (LUCENE-4391) Lucene40Codec methods should be final

Adrien Grand created LUCENE-4391:
------------------------------------

             Summary: Lucene40Codec methods should be final
                 Key: LUCENE-4391
                 URL: https://issues.apache.org/jira/browse/LUCENE-4391
             Project: Lucene - Core
          Issue Type: Bug
            Reporter: Adrien Grand
             Fix For: 4.0


I think all methods but {{getPostingsFormatForField}} should be made final so that users can't create a Codec that redefines any of the formats of Lucene40 by subclassing (since the codec name can't be overriden by subclassing, Lucene will fail at loading segments that use such codecs).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Resolved] (LUCENE-4391) Lucene40Codec methods should be final

Posted by "Adrien Grand (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-4391?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adrien Grand resolved LUCENE-4391.
----------------------------------

    Resolution: Fixed

Just committed (r1387222 on trunk and r1387229 on branch 4.x).
                
> Lucene40Codec methods should be final
> -------------------------------------
>
>                 Key: LUCENE-4391
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4391
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Adrien Grand
>            Assignee: Adrien Grand
>             Fix For: 4.0
>
>         Attachments: LUCENE-4391.patch, LUCENE-4391.patch
>
>
> I think all methods but {{getPostingsFormatForField}} should be made final so that users can't create a Codec that redefines any of the formats of Lucene40 by subclassing (since the codec name can't be overriden by subclassing, Lucene will fail at loading segments that use such codecs).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Updated] (LUCENE-4391) Lucene40Codec methods should be final

Posted by "Adrien Grand (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-4391?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adrien Grand updated LUCENE-4391:
---------------------------------

    Attachment: LUCENE-4391.patch

Same patch, but with ForwardingCodec renamed as FilterCodec. I however didn't change the way it gets the delegate codec because of the issue mentioned above.
                
> Lucene40Codec methods should be final
> -------------------------------------
>
>                 Key: LUCENE-4391
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4391
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Adrien Grand
>            Assignee: Adrien Grand
>             Fix For: 4.0
>
>         Attachments: LUCENE-4391.patch, LUCENE-4391.patch
>
>
> I think all methods but {{getPostingsFormatForField}} should be made final so that users can't create a Codec that redefines any of the formats of Lucene40 by subclassing (since the codec name can't be overriden by subclassing, Lucene will fail at loading segments that use such codecs).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Commented] (LUCENE-4391) Lucene40Codec methods should be final

Posted by "Robert Muir (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-4391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457019#comment-13457019 ] 

Robert Muir commented on LUCENE-4391:
-------------------------------------

Instead of ForwardingCodec having an abstract delegate(), can we maybe have it look like this:

{code}
FilterCodec(String name, Codec in) {
...
{code}

(Suggesting FilterCodec to be consistent with FilterReader, FilterTerms, ....)


                
> Lucene40Codec methods should be final
> -------------------------------------
>
>                 Key: LUCENE-4391
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4391
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Adrien Grand
>            Assignee: Adrien Grand
>             Fix For: 4.0
>
>         Attachments: LUCENE-4391.patch
>
>
> I think all methods but {{getPostingsFormatForField}} should be made final so that users can't create a Codec that redefines any of the formats of Lucene40 by subclassing (since the codec name can't be overriden by subclassing, Lucene will fail at loading segments that use such codecs).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Updated] (LUCENE-4391) Lucene40Codec methods should be final

Posted by "Adrien Grand (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-4391?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adrien Grand updated LUCENE-4391:
---------------------------------

    Fix Version/s:     (was: 4.1)
                   4.0
    
> Lucene40Codec methods should be final
> -------------------------------------
>
>                 Key: LUCENE-4391
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4391
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Adrien Grand
>            Assignee: Adrien Grand
>             Fix For: 4.0
>
>
> I think all methods but {{getPostingsFormatForField}} should be made final so that users can't create a Codec that redefines any of the formats of Lucene40 by subclassing (since the codec name can't be overriden by subclassing, Lucene will fail at loading segments that use such codecs).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Updated] (LUCENE-4391) Lucene40Codec methods should be final

Posted by "Adrien Grand (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-4391?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adrien Grand updated LUCENE-4391:
---------------------------------

    Attachment: LUCENE-4391.patch

New patch:
 - makes codecs and postings formats methods final whenever it may lead to broken subclassing,
 - adds a new {{ForwardingCodec}} class that makes it easy to build a codec by reusing some functionality of another codec.
                
> Lucene40Codec methods should be final
> -------------------------------------
>
>                 Key: LUCENE-4391
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4391
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Adrien Grand
>            Assignee: Adrien Grand
>             Fix For: 4.0
>
>         Attachments: LUCENE-4391.patch
>
>
> I think all methods but {{getPostingsFormatForField}} should be made final so that users can't create a Codec that redefines any of the formats of Lucene40 by subclassing (since the codec name can't be overriden by subclassing, Lucene will fail at loading segments that use such codecs).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Assigned] (LUCENE-4391) Lucene40Codec methods should be final

Posted by "Adrien Grand (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-4391?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adrien Grand reassigned LUCENE-4391:
------------------------------------

    Assignee: Adrien Grand
    
> Lucene40Codec methods should be final
> -------------------------------------
>
>                 Key: LUCENE-4391
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4391
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Adrien Grand
>            Assignee: Adrien Grand
>             Fix For: 4.1
>
>
> I think all methods but {{getPostingsFormatForField}} should be made final so that users can't create a Codec that redefines any of the formats of Lucene40 by subclassing (since the codec name can't be overriden by subclassing, Lucene will fail at loading segments that use such codecs).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Commented] (LUCENE-4391) Lucene40Codec methods should be final

Posted by "Uwe Schindler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-4391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13456361#comment-13456361 ] 

Uwe Schindler commented on LUCENE-4391:
---------------------------------------

+1, I was thinking aout a similar thing, too! If somebody wants to create another codec, reusing *some* Lucene40 stuff, he should subclass Codec directly and delegate the needed things to Codec.forName("Lucene40").fooBar()

The same should be done for Lucene40 PostingsFormat!
                
> Lucene40Codec methods should be final
> -------------------------------------
>
>                 Key: LUCENE-4391
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4391
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Adrien Grand
>             Fix For: 4.0
>
>
> I think all methods but {{getPostingsFormatForField}} should be made final so that users can't create a Codec that redefines any of the formats of Lucene40 by subclassing (since the codec name can't be overriden by subclassing, Lucene will fail at loading segments that use such codecs).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Commented] (LUCENE-4391) Lucene40Codec methods should be final

Posted by "Shai Erera (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-4391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13464704#comment-13464704 ] 

Shai Erera commented on LUCENE-4391:
------------------------------------

I really don't like the delegate() solution ... every method calls this, which in turn calls Codec.forName(). I have a solution and a simple patch to this. I'll open a separate issue as it's focused just on FilterCodec.
                
> Lucene40Codec methods should be final
> -------------------------------------
>
>                 Key: LUCENE-4391
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4391
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Adrien Grand
>            Assignee: Adrien Grand
>             Fix For: 4.0
>
>         Attachments: LUCENE-4391.patch, LUCENE-4391.patch
>
>
> I think all methods but {{getPostingsFormatForField}} should be made final so that users can't create a Codec that redefines any of the formats of Lucene40 by subclassing (since the codec name can't be overriden by subclassing, Lucene will fail at loading segments that use such codecs).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Commented] (LUCENE-4391) Lucene40Codec methods should be final

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-4391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13456383#comment-13456383 ] 

Michael McCandless commented on LUCENE-4391:
--------------------------------------------

+1
                
> Lucene40Codec methods should be final
> -------------------------------------
>
>                 Key: LUCENE-4391
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4391
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Adrien Grand
>             Fix For: 4.0
>
>
> I think all methods but {{getPostingsFormatForField}} should be made final so that users can't create a Codec that redefines any of the formats of Lucene40 by subclassing (since the codec name can't be overriden by subclassing, Lucene will fail at loading segments that use such codecs).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


[jira] [Commented] (LUCENE-4391) Lucene40Codec methods should be final

Posted by "Adrien Grand (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-4391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13457040#comment-13457040 ] 

Adrien Grand commented on LUCENE-4391:
--------------------------------------

The reason I used a {{delegate()}} method is that setting the delegate in the constructor seems to generate cyclic dependencies when used in combination with {{Codec.forName}}. (For example, if I use {{super("Appending", Codec.forName("Lucene40"));}} in AppendingCodec's constructor, I get a:
{noformat}
[junit4:junit4]    > Throwable #1: java.util.ServiceConfigurationError: Cannot instantiate SPI class: org.apache.lucene.codecs.appending.AppendingCodec
[junit4:junit4]    > 	at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:72)
[junit4:junit4]    > 	at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:42)
[junit4:junit4]    > 	at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:37)
[junit4:junit4]    > 	at org.apache.lucene.codecs.Codec.<clinit>(Codec.java:39)
[junit4:junit4]    > 	at org.apache.lucene.util.TestRuleSetupAndRestoreClassEnv.before(TestRuleSetupAndRestoreClassEnv.java:133)
[junit4:junit4]    > 	at org.apache.lucene.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:44)
[junit4:junit4]    > 	at org.apache.lucene.util.TestRuleStoreClassName$1.evaluate(TestRuleStoreClassName.java:42)
[junit4:junit4]    > 	at com.carrotsearch.randomizedtesting.rules.SystemPropertiesInvariantRule$1.evaluate(SystemPropertiesInvariantRule.java:55)
[junit4:junit4]    > 	at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:39)
[junit4:junit4]    > 	at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:39)
[junit4:junit4]    > 	at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
[junit4:junit4]    > 	at org.apache.lucene.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:43)
[junit4:junit4]    > 	at org.apache.lucene.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:48)
[junit4:junit4]    > 	at org.apache.lucene.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:70)
[junit4:junit4]    > 	at org.apache.lucene.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:55)
[junit4:junit4]    > 	at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
[junit4:junit4]    > 	at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:358)
[junit4:junit4]    > 	at java.lang.Thread.run(Thread.java:722)
[junit4:junit4]    > Caused by: java.lang.NullPointerException
[junit4:junit4]    > 	at org.apache.lucene.codecs.Codec.forName(Codec.java:89)
[junit4:junit4]    > 	at org.apache.lucene.codecs.appending.AppendingCodec.<init>(AppendingCodec.java:35)
[junit4:junit4]    > 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[junit4:junit4]    > 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
[junit4:junit4]    > 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[junit4:junit4]    > 	at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
[junit4:junit4]    > 	at java.lang.Class.newInstance0(Class.java:372)
[junit4:junit4]    > 	at java.lang.Class.newInstance(Class.java:325)
[junit4:junit4]    > 	at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:62)
[junit4:junit4]    > 	... 17 more
{noformat})

So I thought it would be less error-prone to let users specify the delegate through an abstract method?
                
> Lucene40Codec methods should be final
> -------------------------------------
>
>                 Key: LUCENE-4391
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4391
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Adrien Grand
>            Assignee: Adrien Grand
>             Fix For: 4.0
>
>         Attachments: LUCENE-4391.patch
>
>
> I think all methods but {{getPostingsFormatForField}} should be made final so that users can't create a Codec that redefines any of the formats of Lucene40 by subclassing (since the codec name can't be overriden by subclassing, Lucene will fail at loading segments that use such codecs).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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