Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-3612

Spin test suite fails with latest jdk 8u40

    • Icon: Task Task
    • Resolution: Fixed
    • Icon: L3 - Default L3 - Default
    • 7.3.0, 7.3.0-alpha3
    • None
    • engine, spin
    • None

      Using latest jdk 8u40 the spin test suite fails, with 8u25 everything works fine:

      15:49:50 Failed tests: 
      15:49:50   JsonTreeEditListPropertyJavascriptTest.shouldFailInsertAtWithWrongObject Expected exception: org.camunda.spin.json.SpinJsonException
      15:49:50   JsonTreeEditListPropertyJavascriptTest.shouldFailInsertWrongObjectAfterSearchObject Expected exception: org.camunda.spin.json.SpinJsonException
      15:49:50   JsonTreeEditListPropertyJavascriptTest.shouldFailAppendWrongNode Expected exception: org.camunda.spin.json.SpinJsonException
      15:49:50   JsonTreeEditListPropertyJavascriptTest.shouldFailInsertWrongObjectBeforeSearchObject Expected exception: org.camunda.spin.json.SpinJsonPropertyException
      

      Reason:

      Before java 8 u40, a script like

      var node = S(input, "application/json");
      var customers = node.prop("customers");
      customers.insertAt(1, new Date());
      

      resulted in calling the spin method #insertAt with an instance of NativeDate. This fails (as expected by the test), because insertAt only accepts primitives or lists or maps.

      But now:

      With jdk8u40 onwards, script objects are converted to ScriptObjectMirror whenever script objects are passed to Java layer - even with Object type params or assigned to a Object[] element.

      Source: https://wiki.openjdk.java.net/display/Nashorn/Nashorn+jsr223+engine+notes

      and the class ScriptObjectMirror implements Map (cf http://cr.openjdk.java.net/~sundar/jdk.nashorn.api/8u40/javadoc/jdk/nashorn/api/scripting/ScriptObjectMirror.html), which is why Spin happily inserts an (empty) map when calling #insertAt in the above script.

      Solution possibilities:

      1. disable these tests for Javascript. Downside: this makes the API inconsistent. Users would not expect that a call such as in the above example suceeds and results in an empty map being inserted
      2. add specific handling/unwrapping of ScriptObjectMirror objects to the JacksonJsonDataFormat#createJsonNode. Downside: This couples the Jackson dataformat to a scripting engine which is in general not a good idea (although java script should always be available)

      Some explanations on the change in Nashorn:

        This is the controller panel for Smart Panels app

            [CAM-3612] Spin test suite fails with latest jdk 8u40

            There are no comments yet on this issue.

              sebastian.menski Sebastian Menski
              sebastian.menski Sebastian Menski
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: