Skip to content

Commit bb46223

Browse files
authored
Merge pull request #258 from microsphere-projects/dev
Enhance test coverage and update dependencies for development
2 parents 603b7bb + 71d6064 commit bb46223

34 files changed

+1863
-78
lines changed

.github/workflows/maven-publish.yml

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ on:
1414
workflow_dispatch:
1515
inputs:
1616
revision:
17-
description: 'The version to release'
17+
description: 'The version to publish (must match ${major}.${minor}.${patch})'
1818
required: true
19-
default: '0.0.1-SNAPSHOT'
19+
default: '${major}.${minor}.${patch}'
2020

2121
jobs:
2222
build:
@@ -26,6 +26,13 @@ jobs:
2626
- name: Checkout Source
2727
uses: actions/checkout@v5
2828

29+
- name: Validate version format
30+
run: |
31+
if ! echo "${{ inputs.revision }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
32+
echo "Error: version '${{ inputs.revision }}' does not match the required pattern major.minor.patch"
33+
exit 1
34+
fi
35+
2936
- name: Setup Maven Central Repository
3037
uses: actions/setup-java@v5
3138
with:
@@ -51,3 +58,57 @@ jobs:
5158
SIGN_KEY_ID: ${{ secrets.OSS_SIGNING_KEY_ID_LONG }}
5259
SIGN_KEY: ${{ secrets.OSS_SIGNING_KEY }}
5360
SIGN_KEY_PASS: ${{ secrets.OSS_SIGNING_PASSWORD }}
61+
62+
release:
63+
runs-on: ubuntu-latest
64+
needs: build
65+
permissions:
66+
contents: write
67+
steps:
68+
- name: Checkout Source
69+
uses: actions/checkout@v5
70+
with:
71+
fetch-depth: 0
72+
73+
- name: Create Tag
74+
run: |
75+
git config user.name "github-actions[bot]"
76+
git config user.email "github-actions[bot]@users.noreply.github.com"
77+
if git rev-parse "${{ inputs.revision }}" >/dev/null 2>&1; then
78+
echo "Tag ${{ inputs.revision }} already exists, skipping."
79+
else
80+
git tag ${{ inputs.revision }}
81+
git push origin ${{ inputs.revision }}
82+
fi
83+
84+
- name: Create Release
85+
run: |
86+
if gh release view "v${{ inputs.revision }}" >/dev/null 2>&1; then
87+
echo "Release v${{ inputs.revision }} already exists, skipping."
88+
else
89+
gh release create v${{ inputs.revision }} \
90+
--title "v${{ inputs.revision }}" \
91+
--generate-notes \
92+
--latest
93+
fi
94+
env:
95+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
97+
- name: Increment patch version
98+
run: |
99+
CURRENT="${{ inputs.revision }}"
100+
MAJOR=$(echo "$CURRENT" | cut -d. -f1)
101+
MINOR=$(echo "$CURRENT" | cut -d. -f2)
102+
PATCH=$(echo "$CURRENT" | cut -d. -f3)
103+
NEXT_PATCH=$((PATCH + 1))
104+
NEXT_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}-SNAPSHOT"
105+
sed -i "s|^\( *\)<revision>[^<]*</revision>|\1<revision>${NEXT_VERSION}</revision>|" pom.xml
106+
echo "Bumped version from ${CURRENT} to ${NEXT_VERSION}"
107+
108+
- name: Commit and push next version
109+
run: |
110+
git config user.name "github-actions[bot]"
111+
git config user.email "github-actions[bot]@users.noreply.github.com"
112+
git add pom.xml
113+
git diff --cached --quiet && echo "No changes to commit" || \
114+
git commit -m "chore: bump version to next patch after publishing ${{ inputs.revision }}" && git push
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This workflow automatically merges the 'main' branch into 'dev' and 'release' branches
2+
# whenever changes are pushed to 'main', without requiring manual confirmation.
3+
4+
name: Merge Main to Dev and Release
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
11+
concurrency:
12+
group: merge-main-to-branches
13+
cancel-in-progress: false
14+
15+
jobs:
16+
merge-to-dev:
17+
name: Merge main → dev
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write
21+
steps:
22+
- name: Checkout Repository
23+
uses: actions/checkout@v5
24+
with:
25+
fetch-depth: 0
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
28+
- name: Merge main into dev
29+
run: |
30+
git config user.name "github-actions[bot]"
31+
git config user.email "github-actions[bot]@users.noreply.github.com"
32+
if ! git checkout dev; then
33+
echo "::error::Branch 'dev' does not exist. Skipping merge."
34+
exit 1
35+
fi
36+
if ! git merge --no-ff origin/main -m "chore: merge main into dev [skip ci]"; then
37+
echo "::error::Merge conflict detected when merging main into dev. Manual intervention required."
38+
exit 1
39+
fi
40+
git push origin dev
41+
42+
merge-to-release:
43+
name: Merge main → release
44+
runs-on: ubuntu-latest
45+
permissions:
46+
contents: write
47+
steps:
48+
- name: Checkout Repository
49+
uses: actions/checkout@v5
50+
with:
51+
fetch-depth: 0
52+
token: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Merge main into release
55+
run: |
56+
git config user.name "github-actions[bot]"
57+
git config user.email "github-actions[bot]@users.noreply.github.com"
58+
if ! git checkout release; then
59+
echo "::error::Branch 'release' does not exist. Skipping merge."
60+
exit 1
61+
fi
62+
if ! git merge --no-ff origin/main -m "chore: merge main into release [skip ci]"; then
63+
echo "::error::Merge conflict detected when merging main into release. Manual intervention required."
64+
exit 1
65+
fi
66+
git push origin release

microsphere-java-core/src/main/java/io/microsphere/collection/Lists.java

Lines changed: 72 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,15 @@ public abstract class Lists implements Utils {
117117
@Nonnull
118118
@Immutable
119119
public static <E> List<E> ofList() {
120-
if (of0MethodHandle == null) {
120+
return ofList0(of0MethodHandle);
121+
}
122+
123+
static <E> List<E> ofList0(MethodHandle methodHandle) {
124+
if (methodHandle == null) {
121125
return emptyList();
122126
}
123127
try {
124-
return (List<E>) of0MethodHandle.invokeExact();
128+
return (List<E>) methodHandle.invokeExact();
125129
} catch (Throwable e) {
126130
return emptyList();
127131
}
@@ -146,11 +150,15 @@ public static <E> List<E> ofList() {
146150
@Nonnull
147151
@Immutable
148152
public static <E> List<E> ofList(E e1) {
149-
if (of1MethodHandle == null) {
153+
return ofList1(of1MethodHandle, e1);
154+
}
155+
156+
static <E> List<E> ofList1(MethodHandle methodHandle, E e1) {
157+
if (methodHandle == null) {
150158
return singletonList(e1);
151159
}
152160
try {
153-
return (List<E>) of1MethodHandle.invokeExact(e1);
161+
return (List<E>) methodHandle.invokeExact(e1);
154162
} catch (Throwable e) {
155163
return singletonList(e1);
156164
}
@@ -176,11 +184,15 @@ public static <E> List<E> ofList(E e1) {
176184
@Nonnull
177185
@Immutable
178186
public static <E> List<E> ofList(E e1, E e2) {
179-
if (of2MethodHandle == null) {
187+
return ofList2(of2MethodHandle, e1, e2);
188+
}
189+
190+
static <E> List<E> ofList2(MethodHandle methodHandle, E e1, E e2) {
191+
if (methodHandle == null) {
180192
return of(e1, e2);
181193
}
182194
try {
183-
return (List<E>) of2MethodHandle.invokeExact(e1, e2);
195+
return (List<E>) methodHandle.invokeExact(e1, e2);
184196
} catch (Throwable e) {
185197
return of(e1, e2);
186198
}
@@ -207,11 +219,15 @@ public static <E> List<E> ofList(E e1, E e2) {
207219
@Nonnull
208220
@Immutable
209221
public static <E> List<E> ofList(E e1, E e2, E e3) {
210-
if (of3MethodHandle == null) {
222+
return ofList3(of3MethodHandle, e1, e2, e3);
223+
}
224+
225+
static <E> List<E> ofList3(MethodHandle methodHandle, E e1, E e2, E e3) {
226+
if (methodHandle == null) {
211227
return of(e1, e2, e3);
212228
}
213229
try {
214-
return (List<E>) of3MethodHandle.invokeExact(e1, e2, e3);
230+
return (List<E>) methodHandle.invokeExact(e1, e2, e3);
215231
} catch (Throwable e) {
216232
return of(e1, e2, e3);
217233
}
@@ -239,11 +255,15 @@ public static <E> List<E> ofList(E e1, E e2, E e3) {
239255
@Nonnull
240256
@Immutable
241257
public static <E> List<E> ofList(E e1, E e2, E e3, E e4) {
242-
if (of4MethodHandle == null) {
258+
return ofList4(of4MethodHandle, e1, e2, e3, e4);
259+
}
260+
261+
static <E> List<E> ofList4(MethodHandle methodHandle, E e1, E e2, E e3, E e4) {
262+
if (methodHandle == null) {
243263
return of(e1, e2, e3, e4);
244264
}
245265
try {
246-
return (List<E>) of4MethodHandle.invokeExact(e1, e2, e3, e4);
266+
return (List<E>) methodHandle.invokeExact(e1, e2, e3, e4);
247267
} catch (Throwable e) {
248268
return of(e1, e2, e3, e4);
249269
}
@@ -272,11 +292,15 @@ public static <E> List<E> ofList(E e1, E e2, E e3, E e4) {
272292
@Nonnull
273293
@Immutable
274294
public static <E> List<E> ofList(E e1, E e2, E e3, E e4, E e5) {
275-
if (of5MethodHandle == null) {
295+
return ofList5(of5MethodHandle, e1, e2, e3, e4, e5);
296+
}
297+
298+
static <E> List<E> ofList5(MethodHandle methodHandle, E e1, E e2, E e3, E e4, E e5) {
299+
if (methodHandle == null) {
276300
return of(e1, e2, e3, e4, e5);
277301
}
278302
try {
279-
return (List<E>) of5MethodHandle.invokeExact(e1, e2, e3, e4, e5);
303+
return (List<E>) methodHandle.invokeExact(e1, e2, e3, e4, e5);
280304
} catch (Throwable e) {
281305
return of(e1, e2, e3, e4, e5);
282306
}
@@ -298,11 +322,15 @@ public static <E> List<E> ofList(E e1, E e2, E e3, E e4, E e5) {
298322
@Nonnull
299323
@Immutable
300324
static <E> List<E> ofList(E e1, E e2, E e3, E e4, E e5, E e6) {
301-
if (of6MethodHandle == null) {
325+
return ofList6(of6MethodHandle, e1, e2, e3, e4, e5, e6);
326+
}
327+
328+
static <E> List<E> ofList6(MethodHandle methodHandle, E e1, E e2, E e3, E e4, E e5, E e6) {
329+
if (methodHandle == null) {
302330
return of(e1, e2, e3, e4, e5, e6);
303331
}
304332
try {
305-
return (List<E>) of6MethodHandle.invokeExact(e1, e2, e3, e4, e5, e6);
333+
return (List<E>) methodHandle.invokeExact(e1, e2, e3, e4, e5, e6);
306334
} catch (Throwable e) {
307335
return of(e1, e2, e3, e4, e5, e6);
308336
}
@@ -333,11 +361,15 @@ static <E> List<E> ofList(E e1, E e2, E e3, E e4, E e5, E e6) {
333361
@Nonnull
334362
@Immutable
335363
public static <E> List<E> ofList(E e1, E e2, E e3, E e4, E e5, E e6, E e7) {
336-
if (of7MethodHandle == null) {
364+
return ofList7(of7MethodHandle, e1, e2, e3, e4, e5, e6, e7);
365+
}
366+
367+
static <E> List<E> ofList7(MethodHandle methodHandle, E e1, E e2, E e3, E e4, E e5, E e6, E e7) {
368+
if (methodHandle == null) {
337369
return of(e1, e2, e3, e4, e5, e6, e7);
338370
}
339371
try {
340-
return (List<E>) of7MethodHandle.invokeExact(e1, e2, e3, e4, e5, e6, e7);
372+
return (List<E>) methodHandle.invokeExact(e1, e2, e3, e4, e5, e6, e7);
341373
} catch (Throwable e) {
342374
return of(e1, e2, e3, e4, e5, e6, e7);
343375
}
@@ -369,11 +401,15 @@ public static <E> List<E> ofList(E e1, E e2, E e3, E e4, E e5, E e6, E e7) {
369401
@Nonnull
370402
@Immutable
371403
public static <E> List<E> ofList(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) {
372-
if (of8MethodHandle == null) {
404+
return ofList8(of8MethodHandle, e1, e2, e3, e4, e5, e6, e7, e8);
405+
}
406+
407+
static <E> List<E> ofList8(MethodHandle methodHandle, E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) {
408+
if (methodHandle == null) {
373409
return of(e1, e2, e3, e4, e5, e6, e7, e8);
374410
}
375411
try {
376-
return (List<E>) of8MethodHandle.invokeExact(e1, e2, e3, e4, e5, e6, e7, e8);
412+
return (List<E>) methodHandle.invokeExact(e1, e2, e3, e4, e5, e6, e7, e8);
377413
} catch (Throwable e) {
378414
return of(e1, e2, e3, e4, e5, e6, e7, e8);
379415
}
@@ -406,11 +442,15 @@ public static <E> List<E> ofList(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8)
406442
@Nonnull
407443
@Immutable
408444
public static <E> List<E> ofList(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) {
409-
if (of9MethodHandle == null) {
445+
return ofList9(of9MethodHandle, e1, e2, e3, e4, e5, e6, e7, e8, e9);
446+
}
447+
448+
static <E> List<E> ofList9(MethodHandle methodHandle, E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) {
449+
if (methodHandle == null) {
410450
return of(e1, e2, e3, e4, e5, e6, e7, e8, e9);
411451
}
412452
try {
413-
return (List<E>) of9MethodHandle.invokeExact(e1, e2, e3, e4, e5, e6, e7, e8, e9);
453+
return (List<E>) methodHandle.invokeExact(e1, e2, e3, e4, e5, e6, e7, e8, e9);
414454
} catch (Throwable e) {
415455
return of(e1, e2, e3, e4, e5, e6, e7, e8, e9);
416456
}
@@ -436,11 +476,15 @@ public static <E> List<E> ofList(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8,
436476
@Nonnull
437477
@Immutable
438478
static <E> List<E> ofList(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) {
439-
if (of10MethodHandle == null) {
479+
return ofList10(of10MethodHandle, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
480+
}
481+
482+
static <E> List<E> ofList10(MethodHandle methodHandle, E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) {
483+
if (methodHandle == null) {
440484
return of(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
441485
}
442486
try {
443-
return (List<E>) of10MethodHandle.invokeExact(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
487+
return (List<E>) methodHandle.invokeExact(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
444488
} catch (Throwable e) {
445489
return of(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10);
446490
}
@@ -470,11 +514,15 @@ public static <E> List<E> ofList(E... elements) {
470514
if (length(elements) < 1) {
471515
return ofList();
472516
}
473-
if (ofMethodHandle == null) {
517+
return ofListElements(ofMethodHandle, elements);
518+
}
519+
520+
static <E> List<E> ofListElements(MethodHandle methodHandle, E[] elements) {
521+
if (methodHandle == null) {
474522
return of(elements);
475523
}
476524
try {
477-
return (List<E>) ofMethodHandle.invokeExact(elements);
525+
return (List<E>) methodHandle.invokeExact(elements);
478526
} catch (Throwable e) {
479527
return of(elements);
480528
}

0 commit comments

Comments
 (0)