[ 
https://issues.apache.org/jira/browse/TIKA-2439?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Karl Richter updated TIKA-2439:
-------------------------------
    Description: 
In an intuitive usage of
{code:java}
LanguageDetector languageDetector = 
LanguageDetector.getDefaultLanguageDetector();
List<LanguageResult> languageResults = 
languageDetector.detectAll(someNonEmptyString);
{code}

`org.apache.tika.langdetect.OptimaizeLangDetector` might/will (?) be chosen as 
default detector, but since there's no call to `LanguageDetector.loadModels()` 
`LanguageDetector.detector` is `null` in `detectAll` which causes an unhelpful 
error situation which one has to investigate in the code. A simple check 
whether `detector` is `null` and throwing an `IllegalStateException("models 
haven't been loaded yet (forgot to call loadModels?")` would be much more 
intuitive.

If that corresponds to the expected behaviour (it's my first week with Tika), I 
can provide a patch or pull request.

experienced with 1.16-76-gecc59adc9

  was:
In an intuitive usage of
{code:java}
LanguageDetector languageDetector = 
LanguageDetector.getDefaultLanguageDetector();
List<LanguageResult> languageResults = 
languageDetector.detectAll(someNonEmptyString);
{code}

`org.apache.tika.langdetect.OptimaizeLangDetector` might/will (?) be chosen as 
default detector, but since there's no call to `LanguageDetector.loadModels()` 
`LanguageDetector.detector` is `null` in `detectAll` which causes an unhelpful 
error message which one has to investigate in the code. A simple check whether 
`detector` is `null` and throwing an `IllegalStateException("models haven't 
been loaded yet (forgot to call loadModels?")` would be much more intuitive.

If that corresponds to the expected behaviour (it's my first week with Tika), I 
can provide a patch or pull request.

experienced with 1.16-76-gecc59adc9


> Avoid NullPointerException in 
> org.apache.tika.langdetect.OptimaizeLangDetector if models haven't been loaded
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: TIKA-2439
>                 URL: https://issues.apache.org/jira/browse/TIKA-2439
>             Project: Tika
>          Issue Type: Improvement
>          Components: languageidentifier
>    Affects Versions: 1.17
>            Reporter: Karl Richter
>
> In an intuitive usage of
> {code:java}
> LanguageDetector languageDetector = 
> LanguageDetector.getDefaultLanguageDetector();
> List<LanguageResult> languageResults = 
> languageDetector.detectAll(someNonEmptyString);
> {code}
> `org.apache.tika.langdetect.OptimaizeLangDetector` might/will (?) be chosen 
> as default detector, but since there's no call to 
> `LanguageDetector.loadModels()` `LanguageDetector.detector` is `null` in 
> `detectAll` which causes an unhelpful error situation which one has to 
> investigate in the code. A simple check whether `detector` is `null` and 
> throwing an `IllegalStateException("models haven't been loaded yet (forgot to 
> call loadModels?")` would be much more intuitive.
> If that corresponds to the expected behaviour (it's my first week with Tika), 
> I can provide a patch or pull request.
> experienced with 1.16-76-gecc59adc9



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

Reply via email to