Skip to content

Commit

Permalink
Merge branch '6.1' into 6.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	core/src/main/java/lucee/runtime/config/ConfigImpl.java
#	core/src/main/java/lucee/runtime/config/ConfigPro.java
#	core/src/main/java/lucee/runtime/config/ConfigServerImpl.java
#	core/src/main/java/lucee/runtime/config/ConfigWebImpl.java
#	core/src/main/java/lucee/runtime/config/SingleContextConfigWeb.java
#	core/src/main/java/lucee/runtime/extension/RHExtension.java
#	loader/build.xml
#	loader/pom.xml
  • Loading branch information
michaeloffner committed Jul 22, 2024
2 parents 0aca224 + 935eaff commit 741be35
Show file tree
Hide file tree
Showing 13 changed files with 319 additions and 147 deletions.
12 changes: 8 additions & 4 deletions core/src/main/java/lucee/runtime/config/ConfigFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,18 @@ static Struct loadDocumentCreateIfFails(Resource configFile, String type) throws
catch (Exception e) {
// rename buggy config files
if (configFile.exists()) {
LogUtil.log(ThreadLocalPageContext.getConfig(), Log.LEVEL_INFO, ConfigFactory.class.getName(),
"Config file [" + configFile + "] was not valid and has been replaced");
LogUtil.log(ThreadLocalPageContext.get(), ConfigFactory.class.getName(), e);
int count = 1;
Resource bugFile;
int count = 1;
Resource configDir = configFile.getParentResource();
while ((bugFile = configDir.getRealResource("lucee-" + type + "." + (count++) + ".buggy")).exists()) {
}

LogUtil.log(ThreadLocalPageContext.getConfig(), Log.LEVEL_INFO, ConfigFactory.class.getName(),
"The configuration file [" + configFile
+ "] contained syntax errors and could not be read. A new configuration file has been created, and the invalid file has been renamed to [" + bugFile
+ "].");
LogUtil.log(ThreadLocalPageContext.get(), ConfigFactory.class.getName(), e);

IOUtil.copy(configFile, bugFile);
configFile.delete();
}
Expand Down
49 changes: 35 additions & 14 deletions core/src/main/java/lucee/runtime/config/ConfigImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ public abstract class ConfigImpl extends ConfigBase implements ConfigPro {

// FUTURE add to interface
public static final short ADMINMODE_SINGLE = 1;

public static final short ADMINMODE_MULTI = 2;
public static final short ADMINMODE_AUTO = 4;

Expand Down Expand Up @@ -437,10 +436,14 @@ public abstract class ConfigImpl extends ConfigBase implements ConfigPro {
private boolean showMetric;

private boolean showTest;

private JavaSettings javaSettings;
private Map<String, JavaSettings> javaSettingsInstances = new ConcurrentHashMap<>();

private boolean fullNullSupport = false;

private Resource extInstalled;
private Resource extAvailable;

/**
* @return the allowURLRequestTimeout
*/
Expand Down Expand Up @@ -2695,15 +2698,6 @@ public Resource getVideoDirectory() {
return dir;
}

@Override
public Resource getExtensionDirectory() {
// TODO take from tag <extensions>
Resource dir = getConfigDir().getRealResource("extensions/installed");
if (!dir.exists()) dir.mkdirs();

return dir;
}

@Override
public ExtensionProvider[] getExtensionProviders() {
throw new RuntimeException("no longer supported, use getRHExtensionProviders() instead.");
Expand Down Expand Up @@ -3906,8 +3900,6 @@ boolean isEmpty(ClassDefinition cd) {
return cd == null || StringUtil.isEmpty(cd.getClassName());
}

private boolean fullNullSupport = false;

protected final void setFullNullSupport(boolean fullNullSupport) {
this.fullNullSupport = fullNullSupport;
}
Expand Down Expand Up @@ -4018,10 +4010,39 @@ public JavaSettings getJavaSettings() {
if (javaSettings == null) {
javaSettings = JavaSettingsImpl.getInstance(this, new StructImpl());
}

}
}
return javaSettings;
}

@Override
public Resource getExtensionDirectory() {
return getExtensionInstalledDir();
}

@Override
public Resource getExtensionInstalledDir() {
if (extInstalled == null) {
synchronized (SystemUtil.createToken("extensions", "installed")) {
if (extInstalled == null) {
extInstalled = getConfigDir().getRealResource("extensions/installed");
if (!extInstalled.exists()) extInstalled.mkdirs();
}
}
}
return extInstalled;
}

@Override
public Resource getExtensionAvailableDir() {
if (extAvailable == null) {
synchronized (SystemUtil.createToken("extensions", "available")) {
if (extAvailable == null) {
extAvailable = getConfigDir().getRealResource("extensions/available");
if (!extAvailable.exists()) extAvailable.mkdirs();
}
}
}
return extAvailable;
}
}
4 changes: 4 additions & 0 deletions core/src/main/java/lucee/runtime/config/ConfigPro.java
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ public Resource[] getResources(PageContext pc, Mapping[] mappings, String realPa

public boolean getShowTest();

public Resource getExtensionInstalledDir();

public Resource getExtensionAvailableDir();

public JavaSettings getJavaSettings();

public JavaSettings getJavaSettings(String id);
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/java/lucee/runtime/config/ConfigWebImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1942,4 +1942,14 @@ public Resource getMavenDir() {
public JavaSettings getJavaSettings() {
return instance.getJavaSettings();
}

@Override
public Resource getExtensionInstalledDir() {
return instance.getExtensionInstalledDir();
}

@Override
public Resource getExtensionAvailableDir() {
return instance.getExtensionAvailableDir();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2121,4 +2121,14 @@ public Resource getMavenDir() {
public JavaSettings getJavaSettings() {
return cs.getJavaSettings();
}

@Override
public Resource getExtensionInstalledDir() {
return cs.getExtensionInstalledDir();
}

@Override
public Resource getExtensionAvailableDir() {
return cs.getExtensionAvailableDir();
}
}
84 changes: 36 additions & 48 deletions core/src/main/java/lucee/runtime/db/HSQLDBHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ private static String toUsableType(int type) {
* @throws DatabaseException
*/
private static void removeTable(Connection conn, String name) throws SQLException {
name = name.replace('.', '_');
Statement stat = conn.createStatement();
stat.execute("DROP TABLE " + name);
DBUtil.commitEL(conn);
Expand Down Expand Up @@ -362,11 +361,8 @@ private static void _executeStatement(Connection conn, String sql) throws SQLExc
* @throws DatabaseException
*/
private static Struct getUsedColumnsForQuery(Connection conn, SQL sql) {

// TODO this could be potentially cached against the sql text

Stopwatch stopwatch = new Stopwatch(Stopwatch.UNIT_MILLI);
stopwatch.start();
// Stopwatch stopwatch = new Stopwatch(Stopwatch.UNIT_MILLI);
// stopwatch.start();
ResultSet rs = null;
ResultSetMetaData rsmd = null;
String view = "V_QOQ_TEMP";
Expand Down Expand Up @@ -467,7 +463,6 @@ public QueryImpl execute(PageContext pc, final SQL sql, int maxrows, int fetchsi
}
catch (Exception ex) {
}

}
catch (Exception e) {
qoqException = e;
Expand All @@ -476,7 +471,6 @@ public QueryImpl execute(PageContext pc, final SQL sql, int maxrows, int fetchsi
// If our first pass at the QoQ failed, lets look at the exception to see what we want to do with
// it.
if (qoqException != null) {

// Track the root cause
Exception rootCause = qoqException;

Expand Down Expand Up @@ -557,31 +551,30 @@ public static QueryImpl __execute(PageContext pc, SQL sql, int maxrows, int fetc
ConfigPro config = (ConfigPro) pc.getConfig();
DatasourceConnection dc = null;
Connection conn = null;
try {
DatasourceConnPool pool = config.getDatasourceConnectionPool(config.getDataSource(QOQ_DATASOURCE_NAME), "sa", "");
dc = pool.borrowObject();
conn = dc.getConnection();

// executeStatement(conn, "CONNECT"); // create a new HSQLDB session for temp tables
DBUtil.setAutoCommitEL(conn, false);

// sql.setSQLString(HSQLUtil.sqlToZQL(sql.getSQLString(),false));
// TODO this is currently single threaded
synchronized (lock) {
try {
// we now only lock the data loading, not the execution of the query, but should this be done via
// cflock by the developer?
synchronized (lock) {
DatasourceConnPool pool = config.getDatasourceConnectionPool(config.getDataSource(QOQ_DATASOURCE_NAME), "sa", "");
dc = pool.borrowObject();
conn = dc.getConnection();
// executeStatement(conn, "CONNECT"); // TODO create a new HSQLDB session for temp tables
DBUtil.setAutoCommitEL(conn, false);

try {
Iterator<String> it = tables.iterator();
String cfQueryName = null; // name of the source query variable
String dbTableName = null; // name of the table in the database
String cfQueryName = null; // name of the source cfml query variable
String dbTableName = null; // name of the target table in the database
String modSql = null;
// int len=tables.size();
while (it.hasNext()) {
cfQueryName = it.next().toString();// tables.get(i).toString();
dbTableName = cfQueryName.replace('.', '_');

// this could match the wrong strings??
modSql = StringUtil.replace(sql.getSQLString(), cfQueryName, dbTableName, false);
sql.setSQLString(modSql);
if (!cfQueryName.toLowerCase().equals(dbTableName.toLowerCase())){
// TODO this could match the wrong strings??
modSql = StringUtil.replace(sql.getSQLString(), cfQueryName, dbTableName, false);
sql.setSQLString(modSql);
}
if (sql.getItems() != null && sql.getItems().length > 0) sql = new SQLImpl(sql.toString());
// temp tables still get created will all the source columns,
// only populateTables is driven by the required columns calculated from the view
Expand Down Expand Up @@ -630,32 +623,27 @@ public static QueryImpl __execute(PageContext pc, SQL sql, int maxrows, int fetc
}

}
catch (SQLException e) {
throw (IllegalQoQException) (new IllegalQoQException("QoQ HSQLDB: error executing sql statement on query.", e.getMessage(), sql, null).initCause(e));
}
}
catch (SQLException e) {
throw (IllegalQoQException) (new IllegalQoQException("QoQ HSQLDB: error executing sql statement on query.", e.getMessage(), sql, null).initCause(e));
// DatabaseException de = new DatabaseException("QoQ HSQLDB: error executing sql statement on query
// [" + e.getMessage() + "]", null , sql, null);
// throw de;
catch (Exception ee) {
throw (IllegalQoQException) (new IllegalQoQException("QoQ HSQLDB: error executing sql statement on query.", ee.getMessage(), sql, null).initCause(ee));
}
}
catch (Exception ee) {
throw (IllegalQoQException) (new IllegalQoQException("QoQ HSQLDB: error executing sql statement on query.", ee.getMessage(), sql, null).initCause(ee));
// DatabaseException de = new DatabaseException("QoQ HSQLDB: error executing sql statement on query
// [" + ee.getMessage() + "]", null , sql, null);
// throw ee;
}
finally {
if (conn != null) {
removeAll(conn, qoqTables);
// executeStatement(conn, "DISCONNECT"); // close HSQLDB session with temp tables
DBUtil.setAutoCommitEL(conn, true);
}
if (dc != null) ((DatasourceConnectionPro) dc).release();
finally {
if (conn != null) {
removeAll(conn, qoqTables);
//executeStatement(conn, "DISCONNECT"); // close HSQLDB session with temp tables
DBUtil.setAutoCommitEL(conn, true);
}
if (dc != null) ((DatasourceConnectionPro) dc).release();

// manager.releaseConnection(dc);
// manager.releaseConnection(dc);
}
// TODO we are swallowing errors, shouldn't be passing a null value back
if (nqr != null) nqr.setExecutionTime(stopwatch.time());
return nqr;
}
// TOOD we are swalloing errors, shouldn't be passing a null value bacl
if (nqr != null) nqr.setExecutionTime(stopwatch.time());
return nqr;

}
}
Loading

0 comments on commit 741be35

Please sign in to comment.