This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 08192ccdcf Refactor to simplify the code
08192ccdcf is described below
commit 08192ccdcf029b62e15a27e684eedf9033ae2bf5
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Jun 17 16:22:43 2022 +0100
Refactor to simplify the code
The original cache implementation set these fields to null when the
cache was invalidated. Hence the NPE protection was required. That is no
longer the case so the protection can be removed.
---
.../apache/catalina/webresources/CachedResource.java | 19 +------------------
1 file changed, 1 insertion(+), 18 deletions(-)
diff --git a/java/org/apache/catalina/webresources/CachedResource.java
b/java/org/apache/catalina/webresources/CachedResource.java
index ea15590963..960571c7c5 100644
--- a/java/org/apache/catalina/webresources/CachedResource.java
+++ b/java/org/apache/catalina/webresources/CachedResource.java
@@ -184,61 +184,48 @@ public class CachedResource implements WebResource {
@Override
public long getLastModified() {
- Long cachedLastModified = this.cachedLastModified;
if (cachedLastModified == null) {
- cachedLastModified =
- Long.valueOf(webResource.getLastModified());
- this.cachedLastModified = cachedLastModified;
+ cachedLastModified = Long.valueOf(webResource.getLastModified());
}
return cachedLastModified.longValue();
}
@Override
public String getLastModifiedHttp() {
- String cachedLastModifiedHttp = this.cachedLastModifiedHttp;
if (cachedLastModifiedHttp == null) {
cachedLastModifiedHttp = webResource.getLastModifiedHttp();
- this.cachedLastModifiedHttp = cachedLastModifiedHttp;
}
return cachedLastModifiedHttp;
}
@Override
public boolean exists() {
- Boolean cachedExists = this.cachedExists;
if (cachedExists == null) {
cachedExists = Boolean.valueOf(webResource.exists());
- this.cachedExists = cachedExists;
}
return cachedExists.booleanValue();
}
@Override
public boolean isVirtual() {
- Boolean cachedIsVirtual = this.cachedIsVirtual;
if (cachedIsVirtual == null) {
cachedIsVirtual = Boolean.valueOf(webResource.isVirtual());
- this.cachedIsVirtual = cachedIsVirtual;
}
return cachedIsVirtual.booleanValue();
}
@Override
public boolean isDirectory() {
- Boolean cachedIsDirectory = this.cachedIsDirectory;
if (cachedIsDirectory == null) {
cachedIsDirectory = Boolean.valueOf(webResource.isDirectory());
- this.cachedIsDirectory = cachedIsDirectory;
}
return cachedIsDirectory.booleanValue();
}
@Override
public boolean isFile() {
- Boolean cachedIsFile = this.cachedIsFile;
if (cachedIsFile == null) {
cachedIsFile = Boolean.valueOf(webResource.isFile());
- this.cachedIsFile = cachedIsFile;
}
return cachedIsFile.booleanValue();
}
@@ -259,13 +246,11 @@ public class CachedResource implements WebResource {
@Override
public long getContentLength() {
- Long cachedContentLength = this.cachedContentLength;
if (cachedContentLength == null) {
long result = 0;
if (webResource != null) {
result = webResource.getContentLength();
cachedContentLength = Long.valueOf(result);
- this.cachedContentLength = cachedContentLength;
}
return result;
}
@@ -314,13 +299,11 @@ public class CachedResource implements WebResource {
@Override
public byte[] getContent() {
- byte[] cachedContent = this.cachedContent;
if (cachedContent == null) {
if (getContentLength() > objectMaxSizeBytes) {
return null;
}
cachedContent = webResource.getContent();
- this.cachedContent = cachedContent;
}
return cachedContent;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]