Bug 121148 NPE occurs from a currupted state cache.
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java
index f3dbcc1..5e293a9 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2006 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -42,7 +42,6 @@
 	private ArrayList dependents;
 
 	private LazyData lazyData;
-	private long lazyTimeStamp;
 
 	public BundleDescriptionImpl() {
 		// 
@@ -383,7 +382,6 @@
 	void setFullyLoaded(boolean fullyLoaded) {
 		if (fullyLoaded) {
 			stateBits |= FULLY_LOADED;
-			lazyTimeStamp = System.currentTimeMillis();
 		} else {
 			stateBits &= ~FULLY_LOADED;
 		}
@@ -412,8 +410,10 @@
 	private void fullyLoad() {
 		if ((stateBits & LAZY_LOADED) == 0)
 			return;
-		if (isFullyLoaded())
+		if (isFullyLoaded()) {
+			containingState.getReader().setAccessedFlag(true); // set reader accessed flag
 			return;
+		}
 		try {
 			containingState.getReader().fullyLoad(this);
 		} catch (IOException e) {
@@ -436,10 +436,10 @@
 		lazyData.resolvedImports = newImports;
 	}
 
-	void unload(long currentTime, long expireTime) {
+	void unload() {
 		if ((stateBits & LAZY_LOADED) == 0)
 			return;
-		if (!isFullyLoaded() || (currentTime - lazyTimeStamp - expireTime) <= 0)
+		if (!isFullyLoaded())
 			return;
 		setFullyLoaded(false);
 		LazyData tempData = lazyData;
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java
index 66b1273..cb275ba 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateImpl.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2006 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -568,12 +568,15 @@
 	}
 
 	public void unloadLazyData(long expireTime) {
-		long currentTime = System.currentTimeMillis();
-		BundleDescription[] bundles = getBundles();
 		// make sure no other thread is trying to unload or load
 		synchronized (reader) {
+			if (reader.getAccessedFlag()) {
+				reader.setAccessedFlag(false); // reset accessed flag
+				return;
+			}
+			BundleDescription[] bundles = getBundles();
 			for (int i = 0; i < bundles.length; i++)
-				((BundleDescriptionImpl) bundles[i]).unload(currentTime, expireTime);
+				((BundleDescriptionImpl) bundles[i]).unload();
 		}
 	}
 
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateReader.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateReader.java
index ad66a26..49d2896 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateReader.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateReader.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2006 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -33,6 +33,7 @@
 
 	private boolean lazyLoad = true;
 	private int numBundles;
+	private boolean accessedFlag = false;
 
 	public static final byte STATE_CACHE_VERSION = 22;
 	public static final byte NULL = 0;
@@ -468,7 +469,16 @@
 		return lazyLoad;
 	}
 
+	boolean getAccessedFlag() {
+		return accessedFlag;
+	}
+
+	void setAccessedFlag(boolean accessedFlag) {
+		this.accessedFlag = accessedFlag;
+	}
+
 	synchronized void fullyLoad() {
+		setAccessedFlag(true);
 		DataInputStream in = null;
 		try {
 			in = openLazyFile();
@@ -487,6 +497,7 @@
 	}
 
 	synchronized void fullyLoad(BundleDescriptionImpl target) throws IOException {
+		setAccessedFlag(true);
 		DataInputStream in = null;
 		try {
 			in = openLazyFile();