package org.zeropage;

import java.util.Set;

public class CacheLinkSource extends LinkSourceDecorator {
    CacheStorage cache;

    public CacheLinkSource(LinkSource innerObject, CacheStorage cacheStorage) {
        this.innerSource = innerObject;
        this.cache = cacheStorage;
    }

    @Override
    public Set<String> getLinks(String from) throws Exception {
        if(this.cache.getData(from)==null) {
            if(innerSource==null) {
                return null;
            } else {
                return innerSource.getLinks(from);
            }
        }
        return this.cache.getData(from);
    }
}

@@ -374,16 +374,76 @@
      if(
+this.cache.hasKey(from)) %7B%0A            Set%3CString%3E result = 
 this.cac
@@ -458,25 +458,17 @@
 ta(from)
-==null) %7B
+;
 %0A       
@@ -479,26 +479,35 @@
  if(
-innerSource==null)
+result != null)%0A           
  %7B%0A 
@@ -528,20 +528,22 @@
  return 
-null
+result
 ;%0A      
@@ -553,15 +553,8 @@
    %7D
- else %7B
 %0A   
@@ -554,32 +554,35 @@
   %7D%0A        
+%7D%0A%0A
         
 return inner
@@ -569,23 +569,19 @@
         
-return 
+if(
 innerSou
@@ -587,24 +587,17 @@
 urce
-.getLinks(from);
+==null) %7B
 %0A   
@@ -597,33 +597,44 @@
 ) %7B%0A            
-%7D
+return null;
 %0A        %7D%0A     
@@ -627,25 +627,33 @@
        %7D
-%0A
+ else %7B%0A 
         
 return t
@@ -648,40 +648,56 @@
     
+   
 return 
-this.cache.getData(from);
+innerSource.getLinks(from);%0A        %7D%0A
 %0A   

fix CacheLinkSource to use 'hasKey'.