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

Fix LDAPFilter::Match bug #228

Merged
merged 5 commits into from
Aug 24, 2017
Merged

Fix LDAPFilter::Match bug #228

merged 5 commits into from
Aug 24, 2017

Conversation

ksubramz
Copy link
Contributor

Addresses #227

Fix the bug by taking into account the length of the keys.
Fix exception documentation of LDAPFilter::Match function.
Add tests to verify the fix.

Signed-off-by: The Mathworks Inc <Roy.Lurie@mathworks.com>
Add test to test exception for case variants of same key.
@codecov-io
Copy link

codecov-io commented Aug 17, 2017

Codecov Report

Merging #228 into development will increase coverage by 0.76%.
The diff coverage is 100%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development     #228      +/-   ##
===============================================
+ Coverage        82.69%   83.46%   +0.76%     
===============================================
  Files              186      186              
  Lines            13138    13186      +48     
===============================================
+ Hits             10865    11006     +141     
+ Misses            2273     2180      -93
Impacted Files Coverage Δ
framework/src/util/Properties.cpp 89.55% <100%> (+4.7%) ⬆️
framework/test/driver/LDAPQueryTest.cpp 98.18% <100%> (+0.88%) ⬆️
framework/src/util/SharedLibrary.cpp 65.27% <0%> (-25.7%) ⬇️
framework/include/cppmicroservices/SharedData.h 78.68% <0%> (-16.4%) ⬇️
framework/test/driver/ConcurrencyTest.cpp 81.48% <0%> (-7.41%) ⬇️
framework/test/bundles/libSL3/ActivatorSL3.cpp 90% <0%> (-4.12%) ⬇️
framework/test/bundles/libSL1/ActivatorSL1.cpp 92.59% <0%> (-3.71%) ⬇️
framework/src/service/ServiceReferenceBase.cpp 74.82% <0%> (-2.05%) ⬇️
framework/src/bundle/BundleRegistry.cpp 85.45% <0%> (-0.61%) ⬇️
framework/src/service/ServiceObjects.cpp 67.36% <0%> (-0.34%) ⬇️
... and 23 more

Copy link
Member

@jeffdiclemente jeffdiclemente left a comment

Choose a reason for hiding this comment

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

The OSGi spec for public interface Filter (Section 10.1.16) only states that matchCase throws an exception. What's the reason for all the other match methods throwing?

@ksubramz
Copy link
Contributor Author

Addressing Jeff's comment, the reason all the Match methods are throwing because they all construct temporary Properties objects. And both the exceptions may get thrown in the constructor of Properties.

@jeffdiclemente
Copy link
Member

alright, closing the loop; I talked to Krish offline and we resolved my confusion on why some match methods throw and others don't. Its because a throw happens in the BundleContext::RegisterService method if case variants are found.

Copy link
Member

@saschazelzer saschazelzer left a comment

Choose a reason for hiding this comment

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

Looks good except that minor doc issue.

@@ -130,6 +130,10 @@ class US_Framework_EXPORT LDAPFilter {
* in the match.
* @return <code>true</code> if the bundle's properties match this
* <code>LDAPFilter</code> <code>false</code> otherwise.
* @throws std::runtime_error If the number of keys of the <code>bundle</code>
* exceeds the value returned by std::numeric_limits<int>::max().
* @throws std::runtime_error If the <code>bundle</code> contains case variants
Copy link
Member

Choose a reason for hiding this comment

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

This can never happen, since the Match() function operates on the bundles headers, which is a case insensitive map already.

@@ -130,6 +130,10 @@ class US_Framework_EXPORT LDAPFilter {
* in the match.
* @return <code>true</code> if the bundle's properties match this
* <code>LDAPFilter</code> <code>false</code> otherwise.
* @throws std::runtime_error If the number of keys of the <code>bundle</code>
Copy link
Member

Choose a reason for hiding this comment

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

the keys are part of the bundle's properties and not the bundle itself.

@@ -130,6 +130,10 @@ class US_Framework_EXPORT LDAPFilter {
* in the match.
* @return <code>true</code> if the bundle's properties match this
* <code>LDAPFilter</code> <code>false</code> otherwise.
* @throws std::runtime_error If the number of keys of the <code>bundle</code>
* exceeds the value returned by std::numeric_limits<int>::max().
* @throws std::runtime_error If the <code>bundle</code> contains case variants
Copy link
Member

Choose a reason for hiding this comment

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

the keys are part of the bundle's properties and not the bundle itself.

@@ -142,6 +146,10 @@ class US_Framework_EXPORT LDAPFilter {
* in the match.
* @return <code>true</code> if the <code>AnyMap</code>'s values match this
* filter; <code>false</code> otherwise.
* @throws std::runtime_error If the number of keys of the <code>dictionary</code>
Copy link
Member

Choose a reason for hiding this comment

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

If the number of keys of the dictionary

sounds a little awkward. I'd suggest:

If the number of keys in the dictionary

@@ -154,6 +162,10 @@ class US_Framework_EXPORT LDAPFilter {
* in the match.
* @return <code>true</code> if the <code>AnyMap</code>'s values match this
* filter; <code>false</code> otherwise.
* @throws std::runtime_error If the number of keys of the <code>dictionary</code>
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest:

If the number of keys in the dictionary

Amend API documentation
Copy link
Member

@saschazelzer saschazelzer left a comment

Choose a reason for hiding this comment

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

Just one other minor thing.

@@ -130,10 +130,8 @@ class US_Framework_EXPORT LDAPFilter {
* in the match.
* @return <code>true</code> if the bundle's properties match this
* <code>LDAPFilter</code> <code>false</code> otherwise.
* @throws std::runtime_error If the number of keys of the <code>bundle</code>
* @throws std::runtime_error If the number of keys of the bundle's properties
Copy link
Member

Choose a reason for hiding this comment

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

We need to be careful about the terminology here. It is the bundle's manifest headers that are checked and matched. The return doc above also users the wrong properties term.

Improve API doc based on feedback
* @throws std::runtime_error If the number of keys of the bundle's properties
* exceeds the value returned by std::numeric_limits<int>::max().
* @throws std::runtime_error If the number of keys of the bundle's manifest
* properties exceeds the value returned by std::numeric_limits<int>::max().
Copy link
Member

Choose a reason for hiding this comment

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

I am sorry, but elsewhere we really use the term headers (the Match() implementation really calls bundle.GetHeaders()) for the manifest data, not properties. properties are accessed via the bundle context and are framework properties. manifest properties now is even more confusing in my opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No issues :). The reason I chose the wordings was because the short blurb of this API method says Filter using a bundle's manifest properties. I'll change as per your feedback.

Copy link
Member

Choose a reason for hiding this comment

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

Oh okay. Indeed, we used properties before the introduction of framework properties and the need to differentiate these. So the short blurb should be updated as well. Thanks!

Change API doc per feedback
@ksubramz ksubramz merged commit 90fa8ce into development Aug 24, 2017
@saschazelzer saschazelzer deleted the 227-ldapfilter-match branch June 14, 2018 13:39
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

Successfully merging this pull request may close these issues.

5 participants