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

Mojarras Service Loader can't parse comments (#) #5204

Closed
Master-Code-Programmer opened this issue Jan 19, 2023 · 0 comments
Closed

Mojarras Service Loader can't parse comments (#) #5204

Master-Code-Programmer opened this issue Jan 19, 2023 · 0 comments

Comments

@Master-Code-Programmer
Copy link
Contributor

Master-Code-Programmer commented Jan 19, 2023

Describe the bug

According to the official documentation of Javas Service Loader it may contain comments. Everything which comes after the '#' is considered a comment. Reference: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/ServiceLoader.html.
But Mojarras own Service Loader implementation doesn't support comments. It even doesn't skip blank lines. This leads to unexpected behaviour when using Mojarras Service Loader. When files under META-INF/services are loaded from Mojarras Service Loader it may lead to exceptions, while these service files under any other META-INF/services directory may perform perfect when they're loaded by the JDK Service Loader.

Therefore I implemented a Pull-Request which fixes that, so comments and blank lines don't lead to crashes when loading service files.

I also added unit tests to test the new functionality. To an area which had previously no test coverage at all.

I also replaced the magic string "UTF-8" with StandardCharsets.UTF_8 in the method I updated. It was introduced with Java 7 and can therefore also be used in a project where downwards compability is important.

Pull-Request: #5205

To Reproduce

Steps to reproduce the behavior:
Add a service file under META-INF/services, with a comment line, to a JAR which gets loaded and see how Mojarra fails to load a class named, for example # Copyright 2017, 2021 Eclipse Foundation. Eclipse License 2..

Expected behavior

Comments and blank lines are ignored.

P.S.: I read, understood and accepted the ECA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants