testmycode / tmc-core

The common clientside implementation for tmc-clients. Used by the tmc-netbeans and the tmc-cli
3 stars 18 forks source link

Submit hangs indefinitely if there are validation errors #109

Closed juvester closed 7 years ago

juvester commented 8 years ago

SubmissionResultParser fails to parse the submissionStatus JSON if there are validation errors. This seems to cause an infinite loop in Submit.call() method where it just fetches the same JSON string over and over again. No interrupt exception is ever thrown, we let it run for 30+ mins.

Here's the parse exception and the JSON string causing it. The same exception is thrown like every two seconds. Very easy to reproduce, just have incorrect indentation in some exercise that does checkstyle validations and do TmcCore.submit(). Local validation works fine.

@Salmela got the parsing to work by defining ValidationResultImpl.validationErrors map as 'transient' but wasn't quite sure whether that's the right way to fix it or if it causes problems elsewhere.

Hope this helps!

cxcorp commented 7 years ago

Can confirm.

Snippet from response JSON:

"validations": {
  "strategy": "FAIL",
  "validationErrors": {
    "Main.java": [
    {
      "column": 0,
      "line": 13,
      "message": "'if' construct must use curly braces '{}'.",
      "sourceName": "com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck"
    }
    ]
  }
}

Here the parsing fails at the start of "Main.java".

The problem is that class ValidationResultImpl keeps validation errors in a Map<File, List<ValidationError>>, however, File does not get serialized into just a string containing the filename. It gets serialized into (and deserialized from) an object like such:

{"path":"Main.java"}
nygrenh commented 7 years ago

Fixed by #116