IzPack

DynamicVariables does not work as expected/documented.

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 3.11.0
  • Fix Version/s: 4.0.0
  • Component/s: Compiler, Installer
  • Labels:
    None
  • Patch Submitted:
    Yes
  • Number of attachments :
    2

Description

DynamicVariables does not work as expected/documented. The dynamic variables are overwritten. As documented, you could have more dynamic variables with one name and different conditions. According the conditions, the right value should be set when you proceed in installer. However, only the last definition of the value with the last condition is take into the account.

Example:
<conditions>
<condition type="variable" id="isoracle">
<name>database.type</name>
<value>oracle</value>
</condition>
<condition type="variable" id="ismaxdb">
<name>database.type</name>
<value>maxdb</value>
</condition>
<condition type="variable" id="ismysql">
<name>database.type</name>
<value>mysql</value>
</condition>
</conditions>

<dynamicvariables>
<variable name="database.jdbcdriver" value="com.oracle.OracleDiver" condition="isoracle" />
<variable name="database.jdbcdriver" value="com.mysql.MysqlDiver" condition="ismysql" />
<variable name="database.jdbcdiver" value="com.maxdb.MaxdbDiver" condition="ismaxdb" />
</dynamicvariables>

In this example I would await, that after user input on one page and a choose of database.type by the user, the variable database.jdbcdiver would be set accordingly. However, as there can be only one definition of DynamicVariable per name in current implementation, only the last one (in this case maxdb) condition is taken.

I would await, that the concept of dynamic variable is able to handle this.
There are two patches available, for version 3.11 and current trunk.

The patches were not tested but the implementation should be clear. (no tests included)

Activity

Hide
Dennis Reil added a comment -

I did not apply the patch, but changed the behaviour to the support of multiple values with different conditions.

Show
Dennis Reil added a comment - I did not apply the patch, but changed the behaviour to the support of multiple values with different conditions.
Hide
Pavol Zibrita added a comment -

Hi. Only one thing. I think the DynamicVariable's equals/hascode should be depended only on name and condition fields.

Show
Pavol Zibrita added a comment - Hi. Only one thing. I think the DynamicVariable's equals/hascode should be depended only on name and condition fields.
Hide
Pavol Zibrita added a comment -

Will there be some 3.12 with this fix?

Show
Pavol Zibrita added a comment - Will there be some 3.12 with this fix?
Hide
Dennis Reil added a comment -

using value and conditionid for the hashcode is more general as these are the variables which can be different.

There will be no fix for 3.11.

Show
Dennis Reil added a comment - using value and conditionid for the hashcode is more general as these are the variables which can be different. There will be no fix for 3.11.
Hide
Pavol Zibrita added a comment -

Just my last 2 cents than:
What is then a "Dynamic variable overwritte?".
a) when you create a variable with same name and same condition but different value?
b) when you create a variable with same name, same condition and same value?

As this code in CompilerConfig is depended on DynamicVariable equals implementation:

if (dynamicValues.remove(dynamicVariable)){
parseWarn(var, "Dynamic Variable '" + name + "' will be overwritten");
}

for current implementation b) is the overwritte. Should not it be the a)?

This seems to be a mistake, but you will be not warned:
<variable name="database.jdbcdriver" value="com.oracle.OracleDiver" condition="isoracle" />
<variable name="database.jdbcdriver" value="com.mysql.MysqlDiver" condition="isoracle" />

Anyway, thanks for implementing it! good and fast work .
pavol

Show
Pavol Zibrita added a comment - Just my last 2 cents than: What is then a "Dynamic variable overwritte?". a) when you create a variable with same name and same condition but different value? b) when you create a variable with same name, same condition and same value? As this code in CompilerConfig is depended on DynamicVariable equals implementation: if (dynamicValues.remove(dynamicVariable)){ parseWarn(var, "Dynamic Variable '" + name + "' will be overwritten"); } for current implementation b) is the overwritte. Should not it be the a)? This seems to be a mistake, but you will be not warned: <variable name="database.jdbcdriver" value="com.oracle.OracleDiver" condition="isoracle" /> <variable name="database.jdbcdriver" value="com.mysql.MysqlDiver" condition="isoracle" /> Anyway, thanks for implementing it! good and fast work . pavol
Hide
Dennis Reil added a comment -

ok, your example convinced me
I changed the hashCode() implementation.

Thanks for your comments on that!

Show
Dennis Reil added a comment - ok, your example convinced me I changed the hashCode() implementation. Thanks for your comments on that!
Hide
Pavol Zibrita added a comment -

I'm glad for that, but, you needed to changed equals not hashCode (well this can be changed too) if you wanted to work it...

Thanks for all!

Show
Pavol Zibrita added a comment - I'm glad for that, but, you needed to changed equals not hashCode (well this can be changed too) if you wanted to work it... Thanks for all!

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: