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

Uwe Schindler edited comment on SOLR-4123 at 12/3/12 7:46 AM:
--------------------------------------------------------------

The rule is simple: Never prepend /. 

For tests we added a special case and that may confuse here: 
ClasspathResourceLoader with a class in ctor param, there you can pass in the 
base class from which the packages are load. This is added to make writing 
tests easy: You can pass in a plain file name and it is loaded from the package 
of the corresponding class. This is to mimic what we always had in our tests: 
Loading local class resources:

{code}
// this will load the
new ClassPathResourceLoader(getClass()).openResource("file.txt");
{code}

Code like Solr uses FileSystemResourceLoader that wants relative path to the 
local working directory or uses the classloader, but thats for Solr and other 
applications like ElasticSearch. Tests should use 
ClasspathResourceLoader(getClass()) and only pass a file name fro their own 
package.

bq. Yes, we should remove this /-stuff!!!

We can do nothing here, the confusion is created by Java's API by itsself: If 
you call Class.getResource() without a path (only file name), it loads from 
same package as the class, if you prepend with "/" it uses the given path as 
full package name. In contrast, if you directly use the ClassLoader (not 
Class), you must give a full path, but without a /.
                
      was (Author: thetaphi):
    The rule is simple: Never prepend /. 

For tests we added a special case and that may confuse here: 
ClasspathResourceLoader with a class in ctor param, there you can pass in the 
base class from which the packages are load.

{code}
// this will load the
new ClassPathResourceLoader(getClass()).openResource("file.txt");
{code}

bq. Yes, we should remove this /-stuff!!!

We can do nothing here, the confusion is created by Java's API by itsself: If 
you call Class.getResource() without a path (only file name), it loads from 
same package as the class, if you prepend with "/" it uses the given path as 
full package name. In contrast, if you directly use the ClassLoader (not 
Class), you must give a full path, but without a /.
                  
> ICUTokenizerFactory - per-script RBBI customization
> ---------------------------------------------------
>
>                 Key: SOLR-4123
>                 URL: https://issues.apache.org/jira/browse/SOLR-4123
>             Project: Solr
>          Issue Type: Improvement
>          Components: Schema and Analysis
>    Affects Versions: 4.0
>            Reporter: Shawn Heisey
>             Fix For: 4.1, 5.0
>
>         Attachments: SOLR-4123.patch, SOLR-4123.patch, SOLR-4123.patch
>
>
> Initially this started out as an idea for a configuration knob on 
> ICUTokenizer that would allow me to tell it not to tokenize on punctuation.  
> Through IRC discussion on #lucene, it sorta ballooned.  The committers had a 
> long discussion about it that I don't really understand, so I'll be including 
> it in the comments.
> I am a Solr user, so I would also need the ability to access the 
> configuration from there, likely either in schema.xml or solrconfig.xml.

--
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-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to