weird behavior in ModuleUtil.matchRequiredVersions()


I stumbled on a to me weird behavior of

ModuleUtil.matchRequiredVersions(openmrsVersion, requiredOpenmrsVersion)

Which says that it

@return true if the <code>version</code> is within the <code>value</code>

This expression is true (as I would expect):

assertFalse(ModuleUtil.matchRequiredVersions("2.1.0", "1.9.*"));

But this is not:

assertFalse(ModuleUtil.matchRequiredVersions("2.1.0", "1.9.8"));

Im puzzled :dizzy_face: How can β€œ2.1.0” match β€œ1.9.8” ?

mhmm. So if you pass in a single required version like β€œ1.9.8”, no range then it ends up in

and since the current version in my example β€œ2.1.0” is above the range value β€œ1.9.8” this evaluates to true.

So I know where it comes from. Now the question is do you want this behavior ? I dont think I do :wink:

Modules put a requires version of the platform. This method was created for such. it usually means the lowest required version. So if a module requires version 1.9.8, it should then be able to run on version 2.1.0

should it? 2.1.0 can have backwards incompatible changes making a 1.9.8 module unable to run on 2.1.0.

But apart from that why is assertFalse(ModuleUtil.matchRequiredVersions("2.1.0", "1.9.*")); expression true then and β€œ1.9.8” its not? Seems inconsistent to me

@teleivo that is simply the minimum required version. It does not necessarily mean that it will run on all higher versions. If the module developer wants to specify an upper boundary, it is all up to them.

ok, thanks for clarifying this.

But still the behavior of ModuleUtil.matchRequiredVersions doesnt make sense to me.

assertFalse(ModuleUtil.matchRequiredVersions(β€œ2.1.0”, β€œ1.9.*”)); evaluates to true and β€œ1.9.8” does not, why?

When using a wild card, the meaning changes. So 1.9.* means the version is required to be in the 1.9.x series.

1.9 does mean 1.9 and above. 1.9.* means any version of the 1.9.x branch. That is 1.9.1, 1.9.2, but not 1.10.0, 1.11.0, etc

1 Like

ahhh :wink:

this should go into the javadoc which isnt very clear.

I fully agree! Do you wanna add it? :slight_smile:

am on it :slight_smile:

@dkayiwa see PR here

I trust your speed man!!! :smile:

Hi, @teleivo @dkayiwa I feel this ticket would hamper backward compatibility right? Forgive me if this is out of the scope of this discussion :sweat_smile:

@reubenv can you give an explanation regarding how it would affect backward compatibility?

From what I understood, @Dengfeng Li proposes that the single version of each module within the openmrs installation should match that of the main software ,else an error would be thrown .If so then this would mean that the single required version of each module would have to updated with each new build. This in my opinion would not be very feasible each time. Even if a single version is below the openmrs version then the build fails. Now, if I were to install an old version of the module then currently the build won’t fail but after the proposed change it will. This is how it would prevent older versions of modules from running even if they were to run perfectly .Please do correct me if I am wrong