[GRADLE-422] Script Caching gets stuck on EMPTY_SCRIPT state Created: 12/Mar/09  Updated: 04/Jan/13  Resolved: 14/Apr/09

Status: Resolved
Project: Gradle
Affects Version/s: 0.5.2
Fix Version/s: 0.6

Type: Bug
Reporter: Steve Appling Assignee: Hans Dockter
Resolution: Fixed Votes: 0

Attachments: Text File cachefix.patch    
Issue Links:
Duplicate
Duplicated by GRADLE-466 NPE for empty build file Resolved

 Description   

If a script has been identified as an empty script, then this information is cached and the script is never used again unless the cache is cleaned (even after contents are added). Also, truely empty scripts (with no content - even whitespace) cause an NPE.

To reproduce this problem:

  1. create a build.gradle and add no content (not even \n)
  2. run gradle -t, you should get a NullPointerException
  3. add a single carriage return to the build.gradle
  4. run gradle -t, you should get an empty task list (which is correct)
  5. add the following to build.gradle: createTask('check')
  6. run gradle -t, you will get an empty task list (not correct) because it has been cached as empty and is now stuck that way

I added testCases to DefaultCachePropertiesHandlerTest to cover both of these problems.



 Comments   
Comment by Hans Dockter [ 13/Mar/09 ]

Many thanks for the patch. We will apply this for 0.6.

Comment by Hans Dockter [ 13/Apr/09 ]

I saw a possibility to get rid of the special case 'empty script' all together (We only need to deal with it in one place now). I think this is a nice simplification. I haven't committed it yet. I'd like to get some feedback first. I have changed the contract of the ScriptSource.getText method to never return null. This method returns an empty String now in case of an empty (or non existing script).

I have uploaded the stuff to github. For a list of changed files see:

http://github.com/hansd/gradle/commit/9082c4c48f9a317339ce37f6d400a5e552bf9ec8

Comment by Steve Appling [ 13/Apr/09 ]

Not treating the empty script as a special case is a much better solution!

Generated at Wed Jun 30 11:29:42 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.