[GitHub] brooklyn-server pull request: Add a label to predicates check in f...

2016-03-24 Thread ahgittin
Github user ahgittin commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/78#discussion_r57306501
  
--- Diff: core/src/main/java/org/apache/brooklyn/util/core/osgi/Osgis.java 
---
@@ -181,11 +181,11 @@ public BundleFinder requiringFromUrl(String url) {
 public List findAll() {
 boolean urlMatched = false;
 List result = MutableList.of();
-for (Bundle b: framework.getBundleContext().getBundles()) {
+allBundles: for (Bundle b: 
framework.getBundleContext().getBundles()) {
 if (symbolicName!=null && 
!symbolicName.equals(b.getSymbolicName())) continue;
 if (version!=null && 
!Version.parseVersion(version).equals(b.getVersion())) continue;
 for (Predicate predicate: predicates) {
-if (!predicate.apply(b)) continue;
+if (!predicate.apply(b)) continue allBundles;
--- End diff --

+1 i don't like labels here, and in any case i think the inner loop as svet 
suggests can be replaced by one line

if (!Predicates.and(predicates).apply(b)) continue;


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request: Add a label to predicates check in f...

2016-03-23 Thread neykov
Github user neykov commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/78#discussion_r57199823
  
--- Diff: core/src/main/java/org/apache/brooklyn/util/core/osgi/Osgis.java 
---
@@ -181,11 +181,11 @@ public BundleFinder requiringFromUrl(String url) {
 public List findAll() {
 boolean urlMatched = false;
 List result = MutableList.of();
-for (Bundle b: framework.getBundleContext().getBundles()) {
+allBundles: for (Bundle b: 
framework.getBundleContext().getBundles()) {
 if (symbolicName!=null && 
!symbolicName.equals(b.getSymbolicName())) continue;
 if (version!=null && 
!Version.parseVersion(version).equals(b.getVersion())) continue;
 for (Predicate predicate: predicates) {
-if (!predicate.apply(b)) continue;
+if (!predicate.apply(b)) continue allBundles;
--- End diff --

Could `Predicates.and` be used instead of the nested loop? Alternatively 
can you extract it in a separate method to avoid dealing with labels.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] brooklyn-server pull request: Add a label to predicates check in f...

2016-03-23 Thread geomacy
GitHub user geomacy opened a pull request:

https://github.com/apache/brooklyn-server/pull/78

Add a label to predicates check in findAll.

Without this change, if the predicate fails, the code flow just picks the 
next predicate to check,
when really we want to skip to checking the next bundle.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/geomacy/brooklyn-server osgis-loop-fix

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/brooklyn-server/pull/78.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #78


commit 7f21d5930b3618b41bd91986ad1eda8b71b7fe6d
Author: Geoff Macartney 
Date:   2016-03-23T16:54:21Z

Add a label to predicates check in findAll.

Without this change, if the predicate fails, the code flow just picks the 
next predicate to check,
when really we want to skip to checking the next bundle.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---