eclipse-ee4j / mojarra

Mojarra, a Jakarta Faces implementation
Other
160 stars 109 forks source link

The service file parsing is incomplete #5203

Closed Master-Code-Programmer closed 1 year ago

Master-Code-Programmer commented 1 year ago

Issue https://github.com/eclipse-ee4j/mojarra/issues/5204.

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.

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

melloware commented 1 year ago

Nice work. Can you open a Ticket please so they can link the issue with this PR?

Master-Code-Programmer commented 1 year ago

Nice work.

Thanks.

Can you open a Ticket please so they can link the issue with this PR?

Done. Link: https://github.com/eclipse-ee4j/mojarra/issues/5204

melloware commented 1 year ago

Thank you!

Master-Code-Programmer commented 1 year ago

Tried to fix the Eclipse verification, so I recreated the branch.