Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#7245: better recovery from script engine failures #7250

Merged
merged 2 commits into from
Apr 16, 2024

Conversation

sdedic
Copy link
Member

@sdedic sdedic commented Apr 9, 2024

Improves error handling in script engine initialization. In #7245 the graaljs script engine fails to load, but aborts the entire template operation (creation of a file using freemaker).

This PR does not fix the issue with graaljs, but improves handling of errors if a script engine fails to load or initialize. Now the error is just logged and does not abort ScriptManager init.

@sdedic sdedic added JavaScript [ci] enable web job and extra JavaScript tests (webcommon/javascript2.editor) HTML [ci] enable web job Platform [ci] enable platform tests (platform/*) labels Apr 9, 2024
@sdedic sdedic added this to the NB22 milestone Apr 9, 2024
@sdedic sdedic self-assigned this Apr 9, 2024
} catch (IllegalStateException | LinkageError err) {
} catch (IllegalStateException | LinkageError | ServiceConfigurationError err) {
// See NETBEANS #7245: First-time initialization with broken implementation may produce ServiceConfigurationError, As this
// happens in class-initializer, subsequent attempts will throw LinkageErrors.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you - indeed a more focused fix, bringing a partitial solution with minimal/no negative side effects. At this point however I think it would be helpful to also have logging as in Scripting.java. Adding the catch clause for ServiceConfigurationError fixes the problem reported in #7245 (not being able to generate a HTML/JS application), but there is also no info shown, as the exception is swallowed. This also does not need an additional guard as the code that could cause the exceptions is entered at most once (disable is used as guard).

Copy link
Member Author

@sdedic sdedic Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK to more logging here. I do not quite understand the part with disable: as far as I read the code, factories() can be called as part of Scripting.newBuilder().build(), each call would produce an additional exception (since Graal SDK is unable to enumerate its languages). The disable aimed to prevent that and log Graal provider's failure just once (Graal's EngineProvider is a singleton in Lookup, so the same instance is called all the time).

Is it desirable to log each time Scripting.newBuilder().build() is called ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant, that we should log the exception here, as it is not reported anywhere else and relevant it a user for example complains about missing PAC support.

The disable part was only meant to say, that from my POV a plain log without an additional guard would be ok, because the exception code path will only be hit once. In Scripting.java you added faultyLookupIds to prevent duplicate reports and that is not necessary here.

Copy link
Member Author

@sdedic sdedic Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the exception code path will only be hit once.

That's not true IMHO; ServerConfigError will be fired just once, but LinkageError would be fired for every Scripting.newBuilder().build() call without the guard - this provider is bound to fail all the time after ServerConfigurationError condition (and most possibly after a LinkageError originating elsewhere as well). At least if I interpret/debugged the code correctly.

The question is still whether it is desirable to have an exception logged for each Scripting.newBuilder().build() or not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is, that GraalEnginesProvider.java is loaded as a singleton and thus the second call to factories will not call into enumerateLanguages because disable is already set.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this looks like the catch block can be only reached once since it writes to disable and nothing is ever resetting it -> logging here would be no problem

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbien & @matthiasblaesing : finally understood. thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging addressed in 0389c34 (rebased & replaced commits).

Copy link
Contributor

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sane to me. Thank you!

@sdedic sdedic merged commit 88d95db into apache:master Apr 16, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HTML [ci] enable web job JavaScript [ci] enable web job and extra JavaScript tests (webcommon/javascript2.editor) Platform [ci] enable platform tests (platform/*)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants