more debug

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2988 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2011-04-07 00:33:37 +00:00
parent 94ddc21289
commit 417eafdefd
1 changed files with 27 additions and 17 deletions

View File

@ -288,6 +288,11 @@ public class ResourceCache
try try
{ {
int len=(int)resource.length(); int len=(int)resource.length();
if (len<0)
{
Log.warn("invalid resource: "+String.valueOf(resource)+" "+len);
return null;
}
Buffer buffer = new IndirectNIOBuffer(len); Buffer buffer = new IndirectNIOBuffer(len);
InputStream is = resource.getInputStream(); InputStream is = resource.getInputStream();
buffer.readFrom(is,len); buffer.readFrom(is,len);
@ -310,6 +315,11 @@ public class ResourceCache
return new DirectNIOBuffer(resource.getFile()); return new DirectNIOBuffer(resource.getFile());
int len=(int)resource.length(); int len=(int)resource.length();
if (len<0)
{
Log.warn("invalid resource: "+String.valueOf(resource)+" "+len);
return null;
}
Buffer buffer = new DirectNIOBuffer(len); Buffer buffer = new DirectNIOBuffer(len);
InputStream is = resource.getInputStream(); InputStream is = resource.getInputStream();
buffer.readFrom(is,len); buffer.readFrom(is,len);
@ -435,14 +445,14 @@ public class ResourceCache
Buffer buffer = _indirectBuffer.get(); Buffer buffer = _indirectBuffer.get();
if (buffer==null) if (buffer==null)
{ {
synchronized (_indirectBuffer) Buffer buffer2=ResourceCache.this.getIndirectBuffer(_resource);
{
if (_indirectBuffer.get()==null) if (buffer2==null)
{ Log.warn("Could not load "+this);
buffer=ResourceCache.this.getIndirectBuffer(_resource); else if (_indirectBuffer.compareAndSet(null,buffer2))
_indirectBuffer.set(buffer); buffer=buffer2;
} else
} buffer=_indirectBuffer.get();
} }
if (buffer==null) if (buffer==null)
return null; return null;
@ -456,14 +466,14 @@ public class ResourceCache
Buffer buffer = _directBuffer.get(); Buffer buffer = _directBuffer.get();
if (buffer==null) if (buffer==null)
{ {
synchronized (_directBuffer) Buffer buffer2=ResourceCache.this.getDirectBuffer(_resource);
{
if (_directBuffer.get()==null) if (buffer2==null)
{ Log.warn("Could not load "+this);
buffer=ResourceCache.this.getDirectBuffer(_resource); else if (_directBuffer.compareAndSet(null,buffer2))
_directBuffer.set(buffer); buffer=buffer2;
} else
} buffer=_directBuffer.get();
} }
if (buffer==null) if (buffer==null)
return null; return null;
@ -491,7 +501,7 @@ public class ResourceCache
@Override @Override
public String toString() public String toString()
{ {
return "{"+_resource+","+_contentType+","+_lastModifiedBytes+"}"; return String.format("%s %s %d %s %s",_resource,_resource.exists(),_resource.lastModified(),_contentType,_lastModifiedBytes);
} }
} }
} }