wildfly-extras / creaper

Small library for JBoss AS 7 and WildFly management with a slight bias towards testing
Apache License 2.0
20 stars 31 forks source link

OfflineServerVersion reports wrong version for WildFly 28+ #242

Open simkam opened 2 months ago

simkam commented 2 months ago

The last time WildFly updated the domain namespace in the configuration file was with WildFly 27 (Version 20.0). There has been no change since then, so OfflineServerVersion reports version 20.0 for WildFly 27 (currently -33). Version updates are no longer needed after WFCORE-5640.

<server xmlns="urn:jboss:domain:20.0">

One option to get a version might be

URLClassLoader cl = new URLClassLoader(new URL[] {"server_root/modules/.../.../wildfly-version".toURI().toURL()},
        this.getClass().getClassLoader()
);

Class<?> versionClass = Class.forName("org.jboss.as.version.Version", true, cl);
Field majorVersionField = versionClass.getDeclaredField("MANAGEMENT_MAJOR_VERSION");
return  majorVersionField.getInt(null);

but Creaper doesn't always have path to the server, only path to configuration file be used.

Another approach might be adding support for versioned subsystems instead of relying on the root version.

Or only documenting current behavior and leaving it to OfflineCommand implementations to handle different subsystems versions. One example is https://github.com/wildfly-extras/creaper/pull/235

stringSubsystemValues = datasources.'@xmlns'.text().tokenize(":")[-1].tokenize(".")
major = stringSubsystemValues[0].toInteger()
minor = stringSubsystemValues[1].toInteger()
securityParamsAsElements = major <= 7 && minor < 2
marekkopecky commented 2 months ago

If we would be ok with introducing subsystem support in creaper core, one solution could be this. But I also think that we should evaluate whether subsystem detection is really needed, because creaper use in in one command only where is a check for >WF10 (extra old WF).