Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 339166

Summary: "resourceContains" causes out of memory errors during fast fail check
Product: [WebTools] WTP Releng Reporter: David Williams <david_williams>
Component: relengAssignee: David Williams <david_williams>
Status: RESOLVED FIXED QA Contact: David Williams <david_williams>
Severity: normal    
Priority: P3    
Version: 3.10   
Target Milestone: 3.10.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description David Williams CLA 2011-03-08 02:00:21 EST
At least, I think it is Ant's "resourceContains" task .. searching though our huge log file. Guess maybe it is not very efficient? And tries to read in whole file? (which would be odd, since just searching for a string ... but, maybe?) 

This is used in our "fast fail" checks, recently added. Ideally, perhaps someone will create a simple, efficient "resourceContainsString" task to do the same thing, since is handy to get more exact failure reasons.
Comment 1 David Williams CLA 2011-03-08 02:18:07 EST
I've disabled the test for "fast failure" cases by using a if="checkForFastFailReasons" on the task (which is not set). 

We were running at the relatively lean 256M for max memory, so I raised that to 380M also ... just to play it safe, but will leave the fast fail check disabled for now.
Comment 2 David Williams CLA 2011-03-08 12:14:01 EST
I have confirmed, from looking at Ant source, that ResourceContains does indeed read in a whole file. So, improved task will be needed, given that we have huge log files. I'm tempted just to use OS's grep via 'exec' task. 



= = = = 
            reader = new BufferedReader(new InputStreamReader(resource.getInputStream()));
            String contents = FileUtils.safeReadFully(reader);
            String sub = substring;
            if (!casesensitive) {
                contents = contents.toLowerCase();
                sub = sub.toLowerCase();
            }
            return contents.indexOf(sub) >= 0;
Comment 3 David Williams CLA 2011-03-09 02:42:13 EST
I've fixed the immediate problem by use 'grep' instead of ant task. While not portable, it'll be good to use for a while, and see a) if it helps enough to justify a new task, and b) once we do new task, what should requirements be. (For example, single pass through a file?) c) just how many "specific" things will we find to test for? In general, anytime there is a "build failed" there is probably a more specific reason we could check for, which makes it much much easier to diagnose build problems (by any one just looking at failure ... won't necessarily have to sign on in shell and browse around 100 M log file.
Comment 4 David Williams CLA 2011-03-09 20:32:21 EST
One bad, or at least odd, thing about using grep, is that is returns a "return code" of 1 when there is no match. And then Ant and CC logging displays it in "error red" in some logs ... and since currently checking for 4 strings, 4 greps, comes back with following, for each main build step. Kind of ugly, but doesn't hurt much, I guess. 

checkForString 	[ exec ] 	Result: 1
checkForString 	[ exec ] 	Result: 1
checkForString 	[ exec ] 	Result: 1
checkForString 	[ exec ] 	Result: 1