Skip to content

Commit f0f88eb

Browse files
Copilotlmajano
andauthored
refactor: remove server scope and locks from BoxLang native class loading paths
Agent-Logs-Url: https://github.com/coldbox-modules/cbjavaloader/sessions/618d75fc-d52b-4f89-9293-5a5fb15482d7 Co-authored-by: lmajano <137111+lmajano@users.noreply.github.com>
1 parent 920c457 commit f0f88eb

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

models/Loader.cfc

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ component accessors="true" singleton {
3333
if ( !isArray( loadPaths ) ) {
3434
loadPaths = listToArray( loadPaths );
3535
}
36-
lock name="#variables.staticIDKey#" throwontimeout="true" timeout="30" type="exclusive" {
37-
server[ getStaticIDKey() ] = loadPaths;
38-
}
3936
if ( arrayLen( loadPaths ) ) {
4037
getRequestClassLoader().addPaths( loadPaths );
4138
}
@@ -86,11 +83,6 @@ component accessors="true" singleton {
8683
// BoxLang 1.8.0+: use native class loading
8784
if ( isBoxLangNative() ) {
8885
var newPaths = arrayOfJars( argumentCollection = arguments );
89-
lock name="#variables.staticIDKey#" throwontimeout="true" timeout="30" type="exclusive" {
90-
var stored = structKeyExists( server, getStaticIDKey() ) ? server[ getStaticIDKey() ] : [];
91-
stored.addAll( newPaths );
92-
server[ getStaticIDKey() ] = stored;
93-
}
9486
if ( arrayLen( newPaths ) ) {
9587
getRequestClassLoader().addPaths( newPaths );
9688
}
@@ -131,9 +123,14 @@ component accessors="true" singleton {
131123
* Get all the loaded URLs
132124
*/
133125
array function getLoadedURLs(){
134-
// BoxLang 1.8.0+: return the stored paths array
126+
// BoxLang 1.8.0+: get URLs directly from the request class loader
135127
if ( isBoxLangNative() ) {
136-
return structKeyExists( server, getStaticIDKey() ) ? server[ getStaticIDKey() ] : [];
128+
var loadedURLs = getRequestClassLoader().getURLs();
129+
var returnArray = arrayNew( 1 );
130+
for ( var url in loadedURLs ) {
131+
arrayAppend( returnArray, url.toString() );
132+
}
133+
return returnArray;
137134
}
138135

139136
var loadedURLs = getURLClassLoader().getURLs();
@@ -162,10 +159,11 @@ component accessors="true" singleton {
162159
* Get the Javaloader Version
163160
*/
164161
string function getVersion(){
165-
if ( isBoxLangNative() ) {
166-
return "boxlang-native";
162+
if ( isJavaLoaderInScope() ) {
163+
return getJavaLoaderFromScope().getVersion();
167164
}
168-
return getJavaLoaderFromScope().getVersion();
165+
// BoxLang native mode: JavaLoader is not in scope; return the same version string
166+
return "1.2";
169167
}
170168

171169
/**

0 commit comments

Comments
 (0)