Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361077 - NullPointerException during validation when dep.index filesize is 0
Summary: NullPointerException during validation when dep.index filesize is 0
Status: RESOLVED FIXED
Alias: None
Product: WTP Common Tools
Classification: WebTools
Component: wst.validation (show other bugs)
Version: 3.3.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.4.2   Edit
Assignee: Rosendo Martinez CLA
QA Contact: Chuck Bridgham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-16 02:46 EDT by David Woldrich CLA
Modified: 2012-10-30 17:14 EDT (History)
2 users (show)

See Also:
ccc: review+


Attachments
Proposed HEAD patch (866 bytes, patch)
2012-03-26 13:33 EDT, Rosendo Martinez CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Woldrich CLA 2011-10-16 02:46:11 EDT
Build Identifier: 20110916-0149

I a million of these exceptions in my log and on the IDE after my .plugins/org.eclipse.wst.validation/dep.index file got accidentally truncated to 0 bytes.

!ENTRY org.eclipse.wst.validation 4 0 2011-10-15 23:26:46.779
!MESSAGE 
!STACK 0
java.lang.NullPointerException
	at org.eclipse.wst.validation.internal.DependencyIndex.getSet(DependencyIndex.java:102)
	at org.eclipse.wst.validation.internal.DependencyIndex.set(DependencyIndex.java:223)
	at org.eclipse.wst.validation.Validator$V2.validate(Validator.java:1178)
	at org.eclipse.wst.validation.internal.ValManager.validate(ValManager.java:704)
	at org.eclipse.wst.validation.internal.ValManager$1.visit(ValManager.java:665)
	at org.eclipse.wst.validation.internal.ValManager.accept(ValManager.java:810)
	at org.eclipse.wst.validation.internal.ValManager.validate(ValManager.java:669)
	at org.eclipse.wst.validation.internal.ValBuilderJob$Visitor.visit(ValBuilderJob.java:299)
	at org.eclipse.core.internal.resources.Resource$2.visit(Resource.java:106)
	at org.eclipse.core.internal.resources.Resource$1.visitElement(Resource.java:65)
	at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:82)
	at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:86)
	at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:86)
	at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:86)
	at org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:127)
	at org.eclipse.core.internal.resources.Resource.accept(Resource.java:75)
	at org.eclipse.core.internal.resources.Resource.accept(Resource.java:104)
	at org.eclipse.core.internal.resources.Resource.accept(Resource.java:88)
	at org.eclipse.wst.validation.internal.ValBuilderJob.fullBuild(ValBuilderJob.java:219)
	at org.eclipse.wst.validation.internal.ValBuilderJob.run(ValBuilderJob.java:178)
	at org.eclipse.wst.validation.internal.ValBuilderJob.runInWorkspace(ValBuilderJob.java:126)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

There probably just needs to be guards put up earlier on in the process to watch for a badly formatted dep.index file like mine?  Maybe schema check it or do a little HSQL db in its place?

Workaround:
I renamed my dep.index file to dep.index.old.  Eclipse then regenerated a proper dep.index file and I got no further errors.  I'd class this as Minor except I had to do quite a bit of googling on the DependencyIndex to infer that dep.index could be a potential troublemaker.  I doubt many would be as tenacious and would just nuke their workspace and start fresh.


Reproducible: Didn't try

Steps to Reproduce:
1. Make dep.index have 0 bytes
2. You'll get NPE errors during validation or Clean ...
Comment 1 Olivier Thomann CLA 2011-10-16 09:00:39 EDT
Move to WebTools
Comment 2 Rosendo Martinez CLA 2012-03-26 13:31:27 EDT
Well,  I think we can consider this case, dep.index file size = 0, like the case where file does not exists. In terms of getting dependencies, in both cases there will not be dependencies.

Attaching a new patch where, if the file size = 0, the _dependsOn and _dependents maps are just crated. Doing that, NPE can be avoided.
Comment 3 Rosendo Martinez CLA 2012-03-26 13:33:02 EDT
Created attachment 213188 [details]
Proposed HEAD patch

Simple fix to check if the file size is 0
Comment 4 Carl Anderson CLA 2012-09-13 10:57:10 EDT
Rosendo, this has all the approvals it needs to get into WTP 3.4.2.  Please commit it as soon as WTP 3.4.1 is final.
Comment 5 Rosendo Martinez CLA 2012-10-30 17:14:39 EDT
Committed and pushed.