Skip to content

Commit c81824e

Browse files
committed
2 parents df3a33b + 5760e63 commit c81824e

6 files changed

Lines changed: 94 additions & 26 deletions

File tree

.github/workflows/main.yml

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
name: Java CI Combined
22

3-
on: [push, pull_request, workflow_dispatch]
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
inputs:
8+
lucee-versions:
9+
description: 'JSON array of Lucee versions to test'
10+
default: '["7.0/snapshot/light","7.0/stable/light","6.2/snapshot/light","6.2/stable/light"]'
11+
dry-run:
12+
description: 'Dry run - skip deploy to Maven'
13+
type: boolean
14+
default: false
415

516
jobs:
617
setup:
718
runs-on: ubuntu-latest
819
outputs:
920
version: ${{ steps.extract-version.outputs.VERSION }}
21+
lucee-matrix: ${{ steps.set-matrix.outputs.matrix }}
1022
steps:
1123
- name: Checkout repository
1224
uses: actions/checkout@v4
@@ -31,6 +43,16 @@ jobs:
3143
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
3244
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
3345
46+
- name: Set Lucee test matrix
47+
id: set-matrix
48+
run: |
49+
DEFAULT='["7.0/snapshot/light","7.0/stable/light","6.2/snapshot/light","6.2/stable/light"]'
50+
MATRIX="${{ inputs.lucee-versions || '' }}"
51+
if [ -z "$MATRIX" ]; then
52+
MATRIX="$DEFAULT"
53+
fi
54+
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
55+
3456
- name: Cache Lucee files
3557
uses: actions/cache@v4
3658
with:
@@ -43,23 +65,9 @@ jobs:
4365
env:
4466
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
4567

46-
build-and-test:
68+
build:
4769
runs-on: ubuntu-latest
4870
needs: setup
49-
env:
50-
testLabels: image
51-
testAdditional: ${{ github.workspace }}/tests
52-
LUCEE_TEST_VERSIONS_JAKARTA: ${{ vars.LUCEE_TEST_VERSIONS_JAKARTA }}
53-
strategy:
54-
fail-fast: false
55-
matrix:
56-
lucee: ${{ fromJSON(vars.LUCEE_TEST_VERSIONS_JAKARTA) }}
57-
java: [ 11, 21 ]
58-
services:
59-
minio:
60-
image: fclairamb/minio-github-actions
61-
ports:
62-
- 9000:9000
6371
steps:
6472
- uses: actions/checkout@v4
6573

@@ -69,6 +77,14 @@ jobs:
6977
java-version: '11'
7078
distribution: 'adopt'
7179

80+
- name: Cache Maven packages
81+
uses: actions/cache@v4
82+
with:
83+
path: ~/.m2
84+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
85+
restore-keys: |
86+
${{ runner.os }}-maven-
87+
7288
- name: Build and Install with Maven
7389
run: |
7490
echo "------- Maven Install -------";
@@ -77,9 +93,31 @@ jobs:
7793
- name: Upload Artifact
7894
uses: actions/upload-artifact@v4
7995
with:
80-
name: image-lex-${{ matrix.lucee.version }}-${{ matrix.java }}
96+
name: image-lex
8197
path: target/*.lex
8298

99+
test:
100+
runs-on: ubuntu-latest
101+
needs: [setup, build]
102+
strategy:
103+
fail-fast: false
104+
matrix:
105+
lucee: ${{ fromJSON(needs.setup.outputs.lucee-matrix) }}
106+
java: [ 11, 21 ]
107+
services:
108+
minio:
109+
image: fclairamb/minio-github-actions
110+
ports:
111+
- 9000:9000
112+
steps:
113+
- uses: actions/checkout@v4
114+
115+
- name: Download Artifact
116+
uses: actions/download-artifact@v4
117+
with:
118+
name: image-lex
119+
path: target
120+
83121
- name: Checkout Lucee
84122
uses: actions/checkout@v4
85123
with:
@@ -97,8 +135,7 @@ jobs:
97135
with:
98136
webroot: ${{ github.workspace }}/lucee/test
99137
execute: /bootstrap-tests.cfm
100-
luceeVersion: ${{ matrix.lucee.version }}
101-
luceeVersionQuery: ${{ matrix.lucee.query }}
138+
luceeVersion: ${{ matrix.lucee }}
102139
extensionDir: ${{ github.workspace }}/target
103140
env:
104141
testLabels: image
@@ -108,8 +145,8 @@ jobs:
108145

109146
deploy:
110147
runs-on: ubuntu-latest
111-
needs: [setup, build-and-test]
112-
if: always() && needs.build-and-test.result == 'success'
148+
needs: [setup, test]
149+
if: always() && needs.test.result == 'success' && github.ref == 'refs/heads/master' && !inputs.dry-run
113150
steps:
114151
- name: Checkout repository
115152
uses: actions/checkout@v4
@@ -146,4 +183,4 @@ jobs:
146183
else
147184
echo "------- Maven Deploy release on ${{ github.event_name }} -------";
148185
mvn -B -e -f pom.xml clean deploy -DperformRelease=true --settings maven-settings.xml
149-
fi
186+
fi

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ WEB-INF
2828
*.iml
2929
*.ipr
3030
*.iws
31+
test-output/

source/java/src/org/lucee/extension/image/tag/jakarta/Image.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,11 @@ private String touchDestination() throws IOException, PageException {
405405
destination = folder.getRealResource(name);
406406
cleanOld(folder);
407407

408-
// create path
409-
String cp = pageContext.getHttpServletRequest().getContextPath();
408+
// create path (use reflection to avoid jakarta/javax bytecode binding)
409+
Object req = eng.getClassUtil().callMethod(pageContext,
410+
eng.getCastUtil().toKey("getHttpServletRequest"), new Object[] {});
411+
String cp = (String) eng.getClassUtil().callMethod(req,
412+
eng.getCastUtil().toKey("getContextPath"), new Object[] {});
410413
if (eng.getStringUtil().isEmpty(cp))
411414
cp = "";
412415
return cp + "/lucee/graph.cfm?img=" + name + "&type="

source/java/src/org/lucee/extension/image/tag/javax/Image.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,11 @@ private String touchDestination() throws IOException, PageException {
365365
destination = folder.getRealResource(name);
366366
cleanOld(folder);
367367

368-
// create path
369-
String cp = pageContext.getHttpServletRequest().getContextPath();
368+
// create path (use reflection to avoid jakarta/javax bytecode binding)
369+
Object req = eng.getClassUtil().callMethod(pageContext,
370+
eng.getCastUtil().toKey("getHttpServletRequest"), new Object[] {});
371+
String cp = (String) eng.getClassUtil().callMethod(req,
372+
eng.getCastUtil().toKey("getContextPath"), new Object[] {});
370373
if (eng.getStringUtil().isEmpty(cp)) cp = "";
371374
return cp + "/lucee/graph.cfm?img=" + name + "&type=" + (eng.getListUtil().last(ImageUtil.getMimeTypeFromFormat(format), "/", true).trim());
372375
}

tests/LDEV6157.cfc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
component extends="org.lucee.cfml.test.LuceeTestCase" labels="image" {
2+
3+
function run( testResults, testBox ) {
4+
describe( "LDEV-6157 cfimage jakarta/javax compat", function() {
5+
6+
it( title="cfimage action=writeToBrowser should not throw jakarta error on Lucee 6", body=function() {
7+
local.result = _internalRequest(
8+
template: "#createURI( 'LDEV6157' )#/LDEV6157.cfm"
9+
);
10+
expect( result.filecontent.trim() ).toInclude( "<img " );
11+
});
12+
13+
});
14+
}
15+
16+
private string function createURI( string calledName, boolean contract=true ) {
17+
var base = getDirectoryFromPath( getCurrentTemplatePath() );
18+
var baseURI = contract ? contractPath( base ) : "/test/#listLast( base, '\/' )#";
19+
return baseURI & "/" & calledName;
20+
}
21+
22+
}

tests/LDEV6157/LDEV6157.cfm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<cfset img = imageNew( "", 100, 100, "rgb", "red" )>
2+
<cfimage action="writeToBrowser" source="#img#" format="png">

0 commit comments

Comments
 (0)