Skip to content

Commit f123eb5

Browse files
committed
LDEV-6107 - encapsulate variables to prevent write access
1 parent 92aed7a commit f123eb5

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

core/src/main/java/lucee/runtime/PageSourceImpl.java

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,26 @@ public final class PageSourceImpl implements PageSource {
9191
private boolean flush = false;
9292

9393
private static class PageAndClassName {
94-
private Page page;
95-
private String className;
94+
private Page _page;
95+
private String _className;
9696

9797
public void reset() {
98-
this.page = null;
99-
this.className = null;
98+
this._page = null;
99+
this._className = null;
100100
}
101101

102102
public void set(Page page) {
103-
this.page = page;
104-
if (page != null) className = page.getClass().getName();
103+
this._page = page;
104+
if (page != null) _className = page.getClass().getName();
105105
}
106106

107+
public Page getPage() {
108+
return _page;
109+
}
110+
111+
public String getClassName() {
112+
return _className;
113+
}
107114
}
108115

109116
PageSourceImpl(MappingImpl mapping, String relPath, boolean isOutSide) {
@@ -119,7 +126,7 @@ public void set(Page page) {
119126
* @return
120127
*/
121128
public Page getPage() {
122-
return pcn.page;
129+
return pcn.getPage();
123130
}
124131

125132
public PageSource getParent() {
@@ -152,7 +159,7 @@ else if (realPath.startsWith("./")) {
152159
public Page loadPage(PageContext pc, boolean forceReload) throws PageException {
153160
if (forceReload) pcn.reset();
154161

155-
Page page = pcn.page;
162+
Page page = pcn.getPage();
156163
if (mapping.isPhysicalFirst()) {
157164
page = loadPhysical(pc, page);
158165
if (page == null) page = loadArchive(page);
@@ -171,7 +178,7 @@ public Page loadPage(PageContext pc, boolean forceReload) throws PageException {
171178
public Page loadPageThrowTemplateException(PageContext pc, boolean forceReload, Page defaultValue) throws PageException {
172179
if (forceReload) pcn.reset();
173180

174-
Page page = pcn.page;
181+
Page page = pcn.getPage();
175182
if (mapping.isPhysicalFirst()) {
176183
page = loadPhysical(pc, page);
177184
if (page == null) page = loadArchive(page);
@@ -189,7 +196,7 @@ public Page loadPageThrowTemplateException(PageContext pc, boolean forceReload,
189196
public Page loadPage(PageContext pc, boolean forceReload, Page defaultValue) {
190197
if (forceReload) pcn.reset();
191198

192-
Page page = pcn.page;
199+
Page page = pcn.getPage();
193200
if (mapping.isPhysicalFirst()) {
194201
try {
195202
page = loadPhysical(pc, page);
@@ -330,7 +337,7 @@ && isLoad(LOAD_PHYSICAL))
330337
// load page
331338
else {
332339
try {
333-
String cn = pcn.className;
340+
String cn = pcn.getClassName();
334341
boolean done = false;
335342
if (cn != null) {
336343
try {
@@ -381,7 +388,7 @@ && isLoad(LOAD_PHYSICAL))
381388

382389
public boolean releaseWhenOutdatted() {
383390
if (!mapping.hasPhysical() || !isLoad(LOAD_PHYSICAL)) return false;
384-
Page page = pcn.page;
391+
Page page = pcn.getPage();
385392
Resource srcFile = getPhyscalFile();
386393
long srcLastModified = srcFile.lastModified();
387394
// Page exists
@@ -402,12 +409,12 @@ public boolean releaseWhenOutdatted() {
402409

403410
public void flush() {
404411
if (LogUtil.doesTrace(mapping.getLog())) mapping.getLog().trace("page-source", "flush [" + getDisplayPath() + "]");
405-
pcn.page = null;
412+
pcn.reset();
406413
flush = true;
407414
}
408415

409416
private boolean isLoad(byte load) {
410-
Page page = pcn.page;
417+
Page page = pcn.getPage();
411418
return page != null && load == page.getLoadType();
412419
}
413420

@@ -1043,7 +1050,7 @@ public Resource getResourceTranslated(PageContext pc) throws ExpressionException
10431050
}
10441051

10451052
public void clear() {
1046-
mapping.clear(pcn.className);
1053+
mapping.clear(pcn.getClassName());
10471054
pcn.reset();
10481055
}
10491056

@@ -1053,7 +1060,7 @@ public void clear() {
10531060
* @param cl
10541061
*/
10551062
public boolean clear(ClassLoader cl) {
1056-
Page page = pcn.page;
1063+
Page page = pcn.getPage();
10571064
if (page != null && page.getClass().getClassLoader().equals(cl)) {
10581065
pcn.reset();
10591066
return true;
@@ -1062,7 +1069,7 @@ public boolean clear(ClassLoader cl) {
10621069
}
10631070

10641071
public boolean isLoad() {
1065-
return pcn.page != null;//// load!=LOAD_NONE;
1072+
return pcn.getPage() != null;//// load!=LOAD_NONE;
10661073
}
10671074

10681075
@Override
@@ -1144,7 +1151,7 @@ public boolean executable() {
11441151

11451152
public void resetLoaded() {
11461153
if (LogUtil.doesTrace(mapping.getLog())) mapping.getLog().trace("page-source", "reset loaded [" + getDisplayPath() + "]");
1147-
Page p = pcn.page;
1154+
Page p = pcn.getPage();
11481155
if (p != null) p.setLoadType((byte) 0);
11491156
}
11501157

loader/build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<project default="core" basedir="." name="Lucee"
33
xmlns:resolver="antlib:org.apache.maven.resolver.ant">
44

5-
<property name="version" value="7.0.2.90-SNAPSHOT"/>
5+
<property name="version" value="7.0.2.91-SNAPSHOT"/>
66

77
<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
88
<classpath>

loader/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>org.lucee</groupId>
55
<artifactId>lucee</artifactId>
6-
<version>7.0.2.90-SNAPSHOT</version>
6+
<version>7.0.2.91-SNAPSHOT</version>
77
<packaging>jar</packaging>
88

99
<name>Lucee Loader Build</name>

0 commit comments

Comments
 (0)