Up to date check not working when task contains object with equals method checking for class equality

(Dennis Kaselow) #1

If I execute the following task repeatedly it will always be executed because the up to data check fails and reports that the instance property changed.:

task gradlebug(type: Gradlebug) {
                outDir file('bug')
  class Gradlebug extends ConventionTask
                SomeClass instance = new SomeClass();
                File outDir
                void doSomething() {
                               println "done"
  class SomeClass implements Serializable {
                  boolean equals(Object o) {
                               println getClass().getClassLoader()
                               println o.getClass().getClassLoader()
                               return getClass() == o.getClass();

The problem did not exist with 1.10, but exists in 1.11 and 1.12. For 1.10 the 'ClassLoader’s of ‘SomeClass’ are the same instance, starting with 1.11 they are different instances which causes the ‘getClass() == o.getClass()’ check to return false.

(Peter Niederwieser) #2

Raised GRADLE-3088. Thanks for the report.

(Dennis Kaselow) #3

One more bit of information: This error only happens on repeated executions when using the daemon.

Without a daemon the up to date check is always working as expected. First execution with the daemon is also working correctly.