Http server error

Hello,

I am facing an issue when using http server of languagetool,

when testing for text on http server for some text i get an error:

“ValueError: Error: Internal Error: java.lang.RuntimeException: java.lang.StringIndexOutOfBoundsException: String index out of range: 60, detected: de-DE”

but when I copy-paste the same text and run it on languagetool.zip artifact that is created it runs without any errors.

Can someone help me with identifying where this error is coming from ???

Hi, can you send the text that causes this error? Is it reproducible, i.e. does it happen again when you send the text more than once?

Hi Daniel, I cannot share the text at the moment as it is company data. I will encrypt it and share it with you if allowed by the company. but yes I have several examples.

example sentence: “Sie fragt , ob Sie international liefern.Sei spricht englisch.”

I have an idea why it is ocurring, when I put a space between the fullstop and the following word “. Sei” rather than keeping it “liefern.Sei” the error goes away. but it only happens while using http server and not the desktop version.

I am unable to locate where in http server it is generating.

the languagetool version i am working on is 5.4

The longer version of error is like this;

  1. Access from 127.0.0.1, HTTP user agent: python-requests/2.26.0, User agent param: null, Referrer: null, language: auto, h: 1, r: 20477, time: 29text length: 264, m: ALL, l: DEFAULT, Stacktrace follows:java.lang.RuntimeException: java.lang.RuntimeException: java.lang.StringIndexOutOfBoundsException: String index out of range: 116, detected: de-DE
    at org.languagetool.server.TextChecker.checkText(TextChecker.java:412)
    at org.languagetool.server.ApiV2.handleCheckRequest(ApiV2.java:155)
    at org.languagetool.server.ApiV2.handleRequest(ApiV2.java:75)
    at org.languagetool.server.LanguageToolHttpHandler.handle(LanguageToolHttpHandler.java:180)
    at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
    at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
    at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
    at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)
    at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
    at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
    Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.StringIndexOutOfBoundsException: String index out of range: 116
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.languagetool.server.TextChecker.checkText(TextChecker.java:393)
    … 12 more
    Caused by: java.lang.RuntimeException: java.lang.StringIndexOutOfBoundsException: String index out of range: 116
    at org.languagetool.JLanguageTool.performCheck(JLanguageTool.java:1233)
    at org.languagetool.JLanguageTool.checkInternal(JLanguageTool.java:973)
    at org.languagetool.JLanguageTool.check2(JLanguageTool.java:911)
    at org.languagetool.server.TextChecker.getPipelineResults(TextChecker.java:669)
    at org.languagetool.server.TextChecker.getRuleMatches(TextChecker.java:618)
    at org.languagetool.server.TextChecker.access$000(TextChecker.java:56)
    at org.languagetool.server.TextChecker$1.call(TextChecker.java:382)
    at org.languagetool.server.TextChecker$1.call(TextChecker.java:375)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    … 3 more
    Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 116
    at java.lang.String.substring(String.java:1963)
    at org.languagetool.JLanguageTool$TextCheckCallable.findLineColumn(JLanguageTool.java:1896)
    at org.languagetool.JLanguageTool$TextCheckCallable.getTextLevelRuleMatches(JLanguageTool.java:1800)
    at org.languagetool.JLanguageTool$TextCheckCallable.call(JLanguageTool.java:1767)
    at org.languagetool.JLanguageTool$TextCheckCallable.call(JLanguageTool.java:1739)
    at org.languagetool.JLanguageTool.performCheck(JLanguageTool.java:1229)

I cannot reproduce this yet, could you send a curl call that triggers this?

curl --data “language=auto&text=Sie fragt , ob Sie international liefern.Sei spricht englisch” http://localhost:8081/v2/check

I get no error with this using the latest version in git. You might want to try with a recent snapshot (Index of /snapshots/).