You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by GitBox <gi...@apache.org> on 2022/07/12 13:52:11 UTC

[GitHub] [celix] PengZheng opened a new issue, #432: Filter version comparison

PengZheng opened a new issue, #432:
URL: https://github.com/apache/celix/issues/432

   ```C
       celix_filter_t *filter = celix_filter_create("(&(service.version>=1.2.2)(service.version<=1.2.2))");
       celix_properties_t *prop = celix_properties_create();
       celix_properties_set(prop, "service.version", "1.2.2.0");
       CHECK_TRUE(celix_filter_match(filter, prop)); // It fails.
       celix_properties_destroy(prop);
       celix_filter_destroy(filter);
   ```
   
   It happens because celix_filter makes simple strcmp when dealing with <= and >=.
   The above makes our dm_exmaple broken, i.e., phase2b's requirement is never satisfied and thus not active:
   
   ```C
   #define PHASE1_RANGE_EXACT  "[1.2.2.0,1.2.2.0]"
   
           celix_dmServiceDependency_setService(dep, PHASE1_NAME, PHASE1_RANGE_EXACT, NULL);
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [celix] tira-misu commented on issue #432: Filter version comparison

Posted by GitBox <gi...@apache.org>.
tira-misu commented on issue #432:
URL: https://github.com/apache/celix/issues/432#issuecomment-1370491798

   A more local change would be to only change filter implementation. If both compare items are convertable to a version make a version compare, else make a string compare.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [celix] tira-misu commented on issue #432: Filter version comparison

Posted by GitBox <gi...@apache.org>.
tira-misu commented on issue #432:
URL: https://github.com/apache/celix/issues/432#issuecomment-1369815516

   In addition [1.5.0,2.0.0) did not match if you version is 1.10.0 . The version comparison uses a simple string compare instead of a version compare. so 1.10.0 is less than 1.5.0, but it should be greater. So at the moment 2 digit version numbers are not supported.
   
   Is this expected behavior or a bug? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [celix] pnoltes closed issue #432: Filter version comparison

Posted by "pnoltes (via GitHub)" <gi...@apache.org>.
pnoltes closed issue #432: Filter version comparison
URL: https://github.com/apache/celix/issues/432


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [celix] tira-misu commented on issue #432: Filter version comparison

Posted by GitBox <gi...@apache.org>.
tira-misu commented on issue #432:
URL: https://github.com/apache/celix/issues/432#issuecomment-1370562070

   i made a quick fix in celix 1.12 for me. Perhaps its a solution for current branch too?
   ```
   static celix_status_t compareVersion(char* version1, char* version2, int* compareResult) {
     version_pt v1 = NULL;
     version_pt v2 = NULL;
   
     if (version_createVersionFromString(version1, &v1) != CELIX_SUCCESS ||
         version_createVersionFromString(version2, &v2) != CELIX_SUCCESS)
     {
   		return CELIX_ILLEGAL_ARGUMENT;
     }
   	version_compareTo(v1, v2, compareResult);
   	version_destroy(v1);
   	version_destroy(v2);
   	return CELIX_SUCCESS;
   }
   ```
   
   ```
     case EQUAL: {
       if (compareVersion(string, (char*)value2, &versionCompareResult) == CELIX_SUCCESS)
       {
         *result = versionCompareResult == 0;
         return CELIX_SUCCESS;
       }
       *result = (strcmp(string, (char*)value2) == 0);
       return CELIX_SUCCESS;
     }
     case GREATER: {
       if (compareVersion(string, (char*)value2, &versionCompareResult) == CELIX_SUCCESS)
       {
         *result = versionCompareResult > 0;
         return CELIX_SUCCESS;
       }
       *result = (strcmp(string, (char*)value2) > 0);
       return CELIX_SUCCESS;
     }
     case GREATEREQUAL: {
       if (compareVersion(string, (char*)value2, &versionCompareResult) == CELIX_SUCCESS)
       {
         *result = versionCompareResult >= 0;
         return CELIX_SUCCESS;
       }
       *result = (strcmp(string, (char*)value2) >= 0);
       return CELIX_SUCCESS;
     }
     case LESS: {
       if (compareVersion(string, (char*)value2, &versionCompareResult) == CELIX_SUCCESS)
       {
         *result = versionCompareResult < 0;
         return CELIX_SUCCESS;
       }
       *result = (strcmp(string, (char*)value2) < 0);
       return CELIX_SUCCESS;
     }
     case LESSEQUAL: {
       if (compareVersion(string, (char*)value2, &versionCompareResult) == CELIX_SUCCESS)
       {
         *result = versionCompareResult <= 0;
         return CELIX_SUCCESS;
       }
       *result = (strcmp(string, (char*)value2) <= 0);
       return CELIX_SUCCESS;
     }
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [celix] pnoltes commented on issue #432: Filter version comparison

Posted by GitBox <gi...@apache.org>.
pnoltes commented on issue #432:
URL: https://github.com/apache/celix/issues/432#issuecomment-1374930374

   Thanks @tira-misu I will take a look at this. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [celix] pnoltes commented on issue #432: Filter version comparison

Posted by GitBox <gi...@apache.org>.
pnoltes commented on issue #432:
URL: https://github.com/apache/celix/issues/432#issuecomment-1369913869

   This is a bug and bug that is broader then only version, because filter comparison is always done on strings.
   So the order is always lexicographically, even for something like (service.id<20).
   
   I am currently working on this, but this will take a while because it has impact on the properties implementation, properties usage and filter implementation. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org