Skip to content

Commit

Permalink
expose argument nameCaseSensitive in all methods and use more direct …
Browse files Browse the repository at this point in the history
…approach in VariablesUtil (minor change)
  • Loading branch information
michaeloffner committed Dec 17, 2024
1 parent a65ef22 commit 2f84ac1
Show file tree
Hide file tree
Showing 27 changed files with 306 additions and 210 deletions.
2 changes: 2 additions & 0 deletions core/src/main/java/lucee/commons/io/TemporaryStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.InputStream;
import java.io.OutputStream;

import lucee.commons.io.log.LogUtil;
import lucee.commons.io.res.Resource;
import lucee.commons.io.res.util.ResourceUtil;
import lucee.commons.lang.SerializableObject;
Expand Down Expand Up @@ -197,6 +198,7 @@ public static Resource getTempDirectory() {
tempFile = getCanonicalResourceEL(tempFile);
}
catch (IOException ioe) {
LogUtil.warn("temporary-stream", ioe);
}
finally {
if (tmp != null) tmp.delete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ private static Object[] getCorrelationIdentifier() {

// CorrelationIdentifier.getTraceId()
if (getTraceId == null) {
getTraceId = Reflector.getMethod(correlationIdentifierClass, "getTraceId", EMPTY_CLASS);
getTraceId = Reflector.getMethod(correlationIdentifierClass, "getTraceId", EMPTY_CLASS, true);
}

// CorrelationIdentifier.getSpanId()
if (getSpanId == null) {
getSpanId = Reflector.getMethod(correlationIdentifierClass, "getSpanId", EMPTY_CLASS);
getSpanId = Reflector.getMethod(correlationIdentifierClass, "getSpanId", EMPTY_CLASS, true);
}
Object[] tmp = new Object[] { getTraceId.invoke(null, EMPTY_OBJ), getSpanId.invoke(null, EMPTY_OBJ) };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ public static void _deleteContent(Resource src, ResourceFilter filter, boolean d
src.remove(false);
}
catch (IOException e) {
LogUtil.warn("resource", e);
// LogUtil.warn("resource", e);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/lucee/commons/sql/OracleBlob.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ public static Blob createBlob(Connection conn, byte[] barr, Blob defaultValue) {

// BLOB blob = BLOB.createTemporary(conn, false, BLOB.DURATION_SESSION);
if (createTemporary == null || createTemporary.getDeclaringClass() != clazz) {
createTemporary = Reflector.getMethod(clazz, "createTemporary", new Class[] { Connection.class, boolean.class, int.class });
createTemporary = Reflector.getMethod(clazz, "createTemporary", new Class[] { Connection.class, boolean.class, int.class }, true);
}
Object blob = createTemporary.invoke(null, new Object[] { conn, Boolean.FALSE, duration });

// blob.open(BLOB.MODE_READWRITE);
if (open == null || open.getDeclaringClass() != clazz) {
open = Reflector.getMethod(clazz, "open", new Class[] { int.class });
open = Reflector.getMethod(clazz, "open", new Class[] { int.class }, true);
}
open.invoke(blob, new Object[] { mode });

// blob.setBytes(1,barr);
if (setBytes == null || setBytes.getDeclaringClass() != clazz) {
setBytes = Reflector.getMethod(clazz, "setBytes", new Class[] { long.class, byte[].class });
setBytes = Reflector.getMethod(clazz, "setBytes", new Class[] { long.class, byte[].class }, true);
}
setBytes.invoke(blob, new Object[] { Long.valueOf(1), barr });

Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/lucee/commons/sql/OracleClob.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ public static Clob createClob(Connection conn, String value, Clob defaultValue)

// CLOB c = CLOB.createTemporary(conn, false, CLOB.DURATION_SESSION);
if (createTemporary == null || createTemporary.getDeclaringClass() != clazz) {
createTemporary = Reflector.getMethod(clazz, "createTemporary", new Class[] { Connection.class, boolean.class, int.class });
createTemporary = Reflector.getMethod(clazz, "createTemporary", new Class[] { Connection.class, boolean.class, int.class }, true);
}
Object clob = createTemporary.invoke(null, new Object[] { conn, Boolean.FALSE, duration });

// c.open(CLOB.MODE_READWRITE);
if (open == null || open.getDeclaringClass() != clazz) {
open = Reflector.getMethod(clazz, "open", new Class[] { int.class });
open = Reflector.getMethod(clazz, "open", new Class[] { int.class }, true);
}
open.invoke(clob, new Object[] { mode });

// c.setString(1,value);
if (setString == null || setString.getDeclaringClass() != clazz) {
setString = Reflector.getMethod(clazz, "setString", new Class[] { long.class, String.class });
setString = Reflector.getMethod(clazz, "setString", new Class[] { long.class, String.class }, true);
}
setString.invoke(clob, new Object[] { Long.valueOf(1), value });

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/lucee/runtime/cache/CacheUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public static void remove(ConfigWeb config, CacheConnection cc) throws Throwable
Cache c = cc.getInstance(config);
// FUTURE no reflection needed
Object[] empty = new Object[0];
MethodInstance remove = Reflector.getMethodInstance(c.getClass(), KeyImpl.init("remove"), empty, true);
MethodInstance remove = Reflector.getMethodInstance(c.getClass(), KeyImpl.init("remove"), empty, true, true);
if (!remove.hasMethod()) {
c.remove((CacheEntryFilter) null);
return;
Expand All @@ -291,7 +291,7 @@ public static void release(CacheConnection cc) throws IOException {

// FUTURE no reflection needed
Object[] empty = new Object[0];
MethodInstance release = Reflector.getMethodInstance(c.getClass(), KeyImpl.init("release"), empty, true);
MethodInstance release = Reflector.getMethodInstance(c.getClass(), KeyImpl.init("release"), empty, true, true);
if (!release.hasMethod()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public CPPCustomTag(String serverLibrary, String procedure, boolean keepAlive) t

}
try {
processRequest = Reflector.getMethod(clazz, "processRequest", new Class[] { String.class, String.class, Request.class, Response.class, boolean.class });
processRequest = Reflector.getMethod(clazz, "processRequest", new Class[] { String.class, String.class, Request.class, Response.class, boolean.class }, true);
}
catch (Exception e) {
throw new CFXTagException(e);
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/lucee/runtime/config/ConfigAdmin.java
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@ private void unloadStartupIfNecessary(ConfigPro config, ClassDefinition<?> cd, b
if (startup.cd.equals(cd) && !force) return;

try {
lucee.transformer.dynamic.meta.Method fin = Reflector.getMethod(startup.instance.getClass(), "finalize", new Class[0], null);
lucee.transformer.dynamic.meta.Method fin = Reflector.getMethod(startup.instance.getClass(), "finalize", new Class[0], true, null);
if (fin != null) {
fin.invoke(startup.instance, new Object[0]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4472,7 +4472,7 @@ private static void _loadStartupHook(ConfigServerImpl configServer, ConfigImpl c
if (existing != null) {
if (existing.cd.equals(cd)) continue;
try {
Method fin = Reflector.getMethod(existing.instance.getClass(), "finalize", new Class[0], null);
Method fin = Reflector.getMethod(existing.instance.getClass(), "finalize", new Class[0], true, null);
if (fin != null) {
fin.invoke(existing.instance, new Object[0]);
}
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/java/lucee/runtime/java/JavaObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public Object get(PageContext pc, String propertyName) throws PageException {
}
}
// Getter
MethodInstance mi = Reflector.getGetterEL(clazz, propertyName);
MethodInstance mi = Reflector.getGetterEL(clazz, propertyName, false);
if (mi != null) {
if (mi.getMethod().isStatic()) {
try {
Expand Down Expand Up @@ -136,7 +136,7 @@ public Object get(PageContext pc, String propertyName, Object defaultValue) {
}
}
// Getter
MethodInstance mi = Reflector.getGetterEL(clazz, propertyName);
MethodInstance mi = Reflector.getGetterEL(clazz, propertyName, false);
if (mi != null) {
try {
if (mi.getMethod().isStatic()) {
Expand Down Expand Up @@ -250,13 +250,13 @@ else if (methodName.equalsIgnoreCase("getClass")) {
return clazz;
}
else if (isInit) {
return Reflector.callMethod(object, methodName, arguments);
return Reflector.callMethod(object, methodName, arguments, false);
}

try {
// get method
// if ("toHexString".equals(methodName)) print.ds();
MethodInstance mi = Reflector.getMethodInstance(clazz, KeyImpl.init(methodName), arguments, false);
MethodInstance mi = Reflector.getMethodInstance(clazz, KeyImpl.init(methodName), arguments, false, false);
// call static method if exist
if (mi.getMethod().isStatic()) {
return mi.invoke(null);
Expand Down
Loading

0 comments on commit 2f84ac1

Please sign in to comment.