Modify

Opened 8 years ago

Closed 8 years ago

#14428 closed defect (invalid)

javax.script.ScriptException not caught when invoking opening_hours.js

Reported by: ypid23 Owned by: team
Priority: normal Milestone:
Component: Core validator Version:
Keywords: opening_hours Cc:

Description

Hi

Unfortunately opening_hours.js can crash with certain values. Can you catch this exception and show a warning in the validation. opening_hours.js is not expected to crash for values following the syntax.

This was first reported upstream and is a known problem: https://github.com/opening-hours/opening_hours.js/issues/209

Steps to reproduce:

  1. Try to validate "Monday - Friday: 8:30 AM-5:30PM, Saturday: 9AM-1PM" from v1 of https://www.openstreetmap.org/way/422234085
  2. Check console log
2017-02-28 16:13:28.673 SEVERE: javax.script.ScriptException: TypeError: Cannot read property "0" from undefined in <eval> at line number 43. Cause: jdk.nashorn.internal.runtime.ECMAException: TypeError: Cannot 
read property "0" from undefined
javax.script.ScriptException: TypeError: Cannot read property "0" from undefined in <eval> at line number 43
        at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470)
        at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:392)
        at jdk.nashorn.api.scripting.NashornScriptEngine.invokeMethod(NashornScriptEngine.java:199)
        at org.openstreetmap.josm.data.validation.tests.OpeningHourTest.checkOpeningHourSyntax(OpeningHourTest.java:214)
        at org.openstreetmap.josm.data.validation.tests.OpeningHourTest.checkOpeningHourSyntax(OpeningHourTest.java:183)
        at org.openstreetmap.josm.data.validation.tests.OpeningHourTest.check(OpeningHourTest.java:258)
        at org.openstreetmap.josm.data.validation.tests.OpeningHourTest.check(OpeningHourTest.java:265)
        at org.openstreetmap.josm.data.validation.Test$TagTest.visit(Test.java:128)
        at org.openstreetmap.josm.data.osm.Way.accept(Way.java:211)
        at org.openstreetmap.josm.data.validation.Test.visit(Test.java:211)
        at org.openstreetmap.josm.actions.ValidateAction$ValidationTask.realRun(ValidateAction.java:166)
        at org.openstreetmap.josm.gui.PleaseWaitRunnable.doRealRun(PleaseWaitRunnable.java:93)
        at org.openstreetmap.josm.gui.PleaseWaitRunnable.run(PleaseWaitRunnable.java:141)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: <eval>:43 TypeError: Cannot read property "0" from undefined
        at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
        at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:213)
        at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:185)
        at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:172)
        at jdk.nashorn.internal.runtime.Undefined.get(Undefined.java:157)
        at jdk.nashorn.internal.scripts.Script$Recompilation$117$212984AAA$\^eval\_.opening_hours#L:43#L:43#formatWarnErrorMessage(<eval>:43)
        at jdk.nashorn.internal.scripts.Script$Recompilation$108$219955A$\^eval\_.opening_hours#L:43#L:43#getWarnings(<eval>:44)
        at jdk.nashorn.internal.scripts.Script$Recompilation$100$281175$\^eval\_.opening_hours#L:43#L:43#getWarnings-1(<eval>:45)
        at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)
        at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
        at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
        at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:199)
        at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:386)
        ... 16 more

Attachments (0)

Change History (3)

comment:1 by Don-vip, 8 years ago

Milestone: 17.03

comment:2 by Don-vip, 8 years ago

Milestone: 17.03

The exception is already catched. As it is a bug in the library I don't see the point to present it to the user, it doesn't mean the value is incorrect.

comment:3 by Don-vip, 8 years ago

Resolution: invalid
Status: newclosed

I'm closing this issue. When the root cause will be fixed in the library we'll update with pelasure :)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.