Closed pnoltes closed 6 months ago
Attention: 33 lines
in your changes are missing coverage. Please review.
Comparison is base (
95bbcfc
) 83.11% compared to head (43b73d3
) 84.34%. Report is 29 commits behind head on master.:exclamation: Current head 43b73d3 differs from pull request most recent head 9d37c55. Consider uploading reports for the commit 9d37c55 to get more accurate results
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
According to OSGi 3.2.7 Filter Syntax
substring ::= attr '=' initial any final
initial ::= () | value
any ::= '*' star-value
star-value ::= () | value '*' star-value
final ::= () | value
value
is a string representing the value, or part of one, which will be compared against a value in the filtered properties. Ifvalue
must contain one of the characters reverse solidus ('\' \u005C), asterisk ('*' \u002A), paren- theses open ('(' \u0028) or parentheses close (')' \u0029), then these characters should be preceded with the reverse solidus ('\' \u005C) character. Spaces are significant invalue
. Space characters are defined by Character.isWhiteSpace().
If "space characters are significant in value
", the following test should pass:
TEST_F(FilterTestSuite, SubStringTest) {
celix_autoptr(celix_properties_t) props = celix_properties_create();
celix_properties_set(props, "test", "John Bob Doe");
celix_properties_set(props, "test2", "*ValueWithStar");
celix_properties_set(props, "test3", " Value");
//test filter with mathing subInitial beginning with whitespace
celix_autoptr(celix_filter_t) filter13 = celix_filter_create("(test3= Value*)");
EXPECT_TRUE(celix_filter_match(filter13, props));
//test filter with matching subInitial consisting of spaces
celix_autoptr(celix_filter_t) filter14 = celix_filter_create("(test3= *)");
EXPECT_TRUE(celix_filter_match(filter14, props));
}
But filter13
fails and filter14
triggers assertion assert(filter->children && celix_arrayList_size(filter->children) >= 2)
.
I think the beginning white spaces should not be escaped in value
, which is quite different from Java properties file format. And a related issue is raised there.
Please have a look at these two issues, @pnoltes
PS: I have not finished my review yet.
@PengZheng Thanks for the thorough review and additional commits. I will do the rework based on the left over review comment.s
This will take some time, because I will not have a lot spare time next week.
Please have a look at these two issues, @pnoltes .
Thanks, nice catch. I removed the incorrect whitespace removal
Review comments have been addressed. Please note that I used a :+1: emoji to indicate my agreement with review comments and to confirm that it has been addressed.
Intro
This PR updates the Apache Celix filter to utilize typed properties entries and also refactors the filter implementation.
My intention was to create a small PR allowing filters to work with typed properties before starting on array support. However, I observed several issues with the filter implementation that I also wanted to address.
Benchmark
With this PR, a filter match will take into account the underlying properties entry type and use it for a more efficient comparison. A Filter match benchmark is introduced (and run before using the typed properties entries in filter match) to ensure the desired effect.
Here are some before and after results (measured on my machine), where the range indicates the size of the properties set used within a filter match.
Before Refactor
After refactor
Substring Refactor
The filter substring implementation was incorrect (not according to the RFC) and has been updated. Additionally, the previous implementation required a malloc during matching; this need has now been removed, ensuring that a filter match does not require additional memory and thus cannot fail due to an allocation error.
Small Refactor of AND and OR
The matching for AND and OR operators has been updated so that
(|)
and(&)
will return true.Service Registration
Service registration, including component service registration, has been updated. Now,
service.id
andservice.version
are stored aslong
andcelix_version_t
types, respectively. Also, some minor "last boy scout rule" changes have been implemented for error handling in the service registration flow.Error Handling
Most of the string parsing part has been refactored to use
open_memstream
. Error handling, including error injection testing, is now in place.