Repository navigation
LDEV-6763 COM extension: createComObject, releaseComObject (Jacob 1.21) - #1
Conversation
…he extension needs the property revision
GianTschingt
left a comment
There was a problem hiding this comment.
Thanks for pulling this out of core, the structure is clean and the diff against the old core code is small. I'm not approving yet, mainly because of the build/release side and because nothing exercises the COM code on Windows. Grouped by priority:
Must-fix
- Jacob dependency is not resolvable from Maven Central.
com.jacob:jacob:1.21is installed fromsource/java/libby theinstall-jacobtarget (source/java/pom.xml:175-181). That works inside this build, but the publishedorg.lucee:comPOM (and so the lite.lex, ormaven="org.lucee:com:..."installs) will reference an artifact that Central doesn't have. Only the full.lexcarries the jar in itsmaven/folder.io.github.osobolev:jacob:1.21is on Central (jar plus the x86/x64 DLLs), and the committed jar/DLLs here have different checksums than those, so please either (a) switch to that coordinate, or (b) shade Jacob into the extension jar, or (c) document exactly where the committed binaries come from. If (c), please add their SHA-256 values and the upstream source tag to the README. - Release workflow doesn't follow the standard release action (see extension-redis
.github/workflows/main.yml): nodeploy/qualifierworkflow_dispatchinputs, no automatic build number (highest of git tags + Central/snapshot metadata + 1), noconcurrencygroup, version is a hardcoded1.0.0.1-ALPHAinstead ofextension.version.base+extension.version.qualifier. Thedeployjob (main.yml:96-139) also runs on every event includingpull_request, and the first non-ALPHA/SNAPSHOT version would go tomvn deployfrom PRs. Gate it like redis (DO_DEPLOYonly for push to the default branch or manual deploy, and skip when the secrets are empty). - Test matrix has no fork fallback (
main.yml:48):fromJSON(vars.LUCEE_TEST_VERSIONS_7)fails on fork PRs where the variable is empty. Please add the "Resolve Lucee test matrix" step (variable if set, otherwise latest7.0/7.1/8.0all/light, and 9.0 as required line since that is where core no longer ships COM). - Nothing runs the COM code. CI is
ubuntu-latestonly, sotests/createComObject.cfconly proves the "Windows only" error path. Please add awindows-latestjob (JDK 21, same script-runner step) with real tests, e.g.Scripting.Dictionary(Add/Item/Count/Exists,Keys()array,for (k in dict)),WScript.Shell(ExpandEnvironmentStrings("%windir%")),Scripting.FileSystemObject(GetFile(path).DateLastModified, folderFilesenumeration, passing a COMObject as an argument),releaseComObject, and unknown ProgID. The date check would catch the issue in the inline comment onCOMUtil.java:37. - PR description still says
lucee/Lucee#TBD. The core PR is merged as lucee/Lucee#3402 (9.0), so 9.0 builds now have no COM at all until this is released. Please link it.
Should-fix
- Thread/resource handling. Jacob initialises each thread as MTA implicitly on the first object (
ROT.addObject), but nothing in the extension (or the old core code) ever callsComThread.Release(). The per-thread table keeps strong references to everyVariant/Dispatchcreated on that thread (aHashMapunless-Dcom.jacob.autogc=true), so a request thread that touches COM in a loop holds on to everything for the life of the thread, andCOMObject.release()(COMObject.java:203) only frees that one dispatch. Options: setcom.jacob.autogc=truebefore the first Jacob class loads (inDllSetup), and/or release at request end. Please at least document it, and ideally add a Windows test that creates many objects. Also worth a sentence in the README that objects live in the MTA, legacy STA-only components may need more. ComFailExceptionleaks as a raw runtime exception.new Dispatch(name)for an unregistered ProgID (COMObject.java:48) throws a barecom.jacob.com.ComFailException; please catch it and rethrow an application exception that includes the ProgID and the HRESULT message.get(pc, key, defaultValue)andsetEL(COMObject.java:66-68,77-80) call Jacob outside any try, soisNull(obj.missing)/obj.missing ?: xthrow instead of returning the default.DllSetup: (a)System.setProperty(jacob.dll.path/name)(DllSetup.java:60-61) overrides a value the admin set on purpose, please respect an existingjacob.dll.path; (b) an existing file is accepted if it is non-empty (:43), so a truncated or stale file with the right name is never replaced, compare size or hash with the bundled resource; (c) delete the temp file in afinally(:48-57), and include the target path in the failure message so a read-onlybinfolder is easy to diagnose; (d) a JNI library can only be loaded by one classloader per JVM, so after an extension update/reload without a server restartSystem.loadwill most likely fail with "already loaded in another classloader", worth a clear message/doc; (e)getJREArch()is only x86 or x64, on a Windows ARM64 JVM it will pick the x64 DLL, which should at least fail with a readable message; (f)doneis read outside the lock, make itvolatile.- Version/baseline.
luceeCoreVersionand theluceedependency are 7.0.0.395 (pom.xml:23,source/java/pom.xml:185) while the extension is meant to replace core COM in 9.0. Please confirm which minimum is intended (7.0/7.1/8.0 still ship their own COM, so installing it there is at best redundant) and that the extension metadata and the README say the same. - Licence.
License.txtand the bundledresources/jacob/LICENSE.TXTare there, but since LGPL code and binaries are redistributed, add a short NOTICE/README section naming Jacob 1.21 (LGPL), the upstream source location, and that the bundled library can be replaced (LGPL terms). It also covers point 1. - Docs. Add the breaking changes to the README:
createObject("com", ...)and<cfobject type="com">are replaced bycreateComObject(), and exception class names change (lucee.commons.jacob.com.*from core vscom.jacob.com.*), which matters for anyone catching by type.
Nice-to-have
- Cache the
SimpleDumpDataconstructor (COMObject.java:113-121). The reflection is understandable since the class isn't part of the loader API, but a failure there shouldn't turn adump()into a runtime exception; fall back to a plain text row. remove()in the iterators (COMKeyWrapperIterator.java:28,COMValueWrapperIterator.java:21,COMObject.java:231/259) releases the enumerator instead of throwingUnsupportedOperationException, andnext()at the end of the enumeration gives an NPE (enumVariant.Next()returns null) instead ofNoSuchElementException. Release theEnumVariantonce it's exhausted.COMObject.iterator()(:207) is missing@Override; double check the extension id221842AA-DCBB-49DE-ADF0E2A28B7F58ACis new (not copied from another extension).
Happy to re-review once the build side and Windows tests are in. The code itself looks close.
…kflow like the other extensions with matrix fallback and a Windows job, DllSetup, COM exceptions, iterators, date and currency conversion, tests, README
…pdate provider serves it, luceeCoreVersion 7.0.5.41
…M support of the core of Lucee 7/8: set them only while the library is loaded, own property for a custom library
… of the Lucee core (LDEV3314 fails on Windows with 8.0 without being related to the extension)
…tead of testFilter (testFilter matched nothing on Windows)
…unner found no tests with a mixed path
… (Dictionary.Keys, Item), the message names the vt value, no loop over a collection of COM objects in the test
|
Thanks for the review. Status of the points of the review summary (the inline threads are answered and resolved): Must-fix
Should-fix
Nice-to-have: All checks are green, including the three Windows jobs. Ready for another look. |
GianTschingt
left a comment
There was a problem hiding this comment.
Thanks, all points from my review are addressed: Jacob 1.21 from Maven Central with the DLLs fetched at build time, the release workflow follows the standard one, real Windows tests (including the date check), the exception and DllSetup fixes, and the README covers the migration and the licence. Looks good to me.
One small follow-up I'd do separately: add 9.0 to the test matrix, now that LUCEE_TEST_VERSIONS_9 and the LUCEE_MAVEN_URL fallback exist, since 9.0 is the line where the core no longer has COM.
First version of the COM extension, part of LDEV-6763 (Lucee 9 epic LDEV-6590). The COM support (Jacob) is removed from the Lucee core in lucee/Lucee#3402 (merged into 9.0 builds, so 9.0 has no COM until this is released) and moves here.
What it is
createComObject( className )andreleaseComObject( comObject )(replacecreateObject("com", ...)/<cfobject type="com">and the core functionreleaseComObject)io.github.osobolev:jacob), instead of the old fork in the core. The native librariesjacob-1.21-x64.dll/jacob-1.21-x86.dllof the same release are downloaded from Central at build time (nothing binary is committed, checksums in the README), packaged as resources of the extension jar and copied tolucee-server/binon first use (DllSetup, respectsjacob.dll.path, replaces a stale file,com.jacob.autogc=true).Require-Extension), installed on demand.SimpleDumpData(a core class) is created by reflection for the dump.pom.xml+build.xml+source/java/pom.xml, lite and full.lex).Tested
.lex(full 282 KB incl. Jacob, lite without maven folder), installed it into the Lucee 9 single jar (PR LDEV-6711 single jar: root pom builds loader and core as one jar Lucee#3357): the functions are found,createComObjectthrows "COM objects are only supported on Windows" on macOS,releaseComObjectignores non COM objects.tests/createComObject.cfcrun with script-runner on macOS: the platform independent specs pass, the Windows specs are skipped. The Windows specs (Scripting.Dictionary, WScript.Shell, Scripting.FileSystemObject incl. dates, enumeration and COM objects as arguments, unknown ProgID, many objects) run in the newtest-windowsjob. They were written without a Windows machine, the first CI run is their first run.extension.version.base/qualifier, automatic build number,deploy/qualifierinputs, deploy only on push to main or manual, GitHub release, S3), plus the "Resolve Lucee test matrix" fallback (7.0, 7.1, 8.0, 9.0).Open
source/images/logo.pngis a placeholder (solid colour), needs a real logo221842AA-DCBB-49DE-ADF0E2A28B7F58ACis new, the extension has to be registered at the extension provider after the first releaseluceeCoreVersionis7.0.0.395(the loader API is enough, so code can be migrated before the upgrade; 7.x/8.0 still have COM in the core, there the extension is redundant),introducedofcreateComObjectis 9.0.0.0