Skip to content

Commit 82a3954

Browse files
Merge pull request #121 from jenkinsci/fix/more-serialisation-hacks
fix: more serialisation hacks
2 parents 1227731 + 6096309 commit 82a3954

File tree

5 files changed

+27
-12
lines changed

5 files changed

+27
-12
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ jobs:
2828

2929
steps:
3030
- name: Checkout repository
31-
uses: actions/checkout@v2
31+
uses: actions/checkout@v3
3232

3333
- name: Set up JDK 11
34-
uses: actions/setup-java@v2
34+
uses: actions/setup-java@v3
3535
with:
3636
distribution: 'temurin'
3737
java-version: 11

.github/workflows/update-release-draft.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
if: ${{ ! contains(github.event.head_commit.message, '[maven-release-plugin] prepare release') }}
1212
steps:
1313
- name: Update Release Draft
14-
uses: release-drafter/release-drafter@v5.18.1
14+
uses: release-drafter/release-drafter@v5.19.0
1515
env:
1616
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/upload-release-artifact.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Update Release Draft
14-
uses: release-drafter/release-drafter@v5.15.0
14+
uses: release-drafter/release-drafter@v5.19.0
1515
id: release-drafter
1616
with:
1717
publish: true
1818
env:
1919
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2020

2121
- name: Checkout repository
22-
uses: actions/checkout@v2
22+
uses: actions/checkout@v3
2323

2424
- name: Set up JDK 11
25-
uses: actions/setup-java@v2
25+
uses: actions/setup-java@v3
2626
with:
2727
distribution: 'temurin'
2828
java-version: 11

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.jenkins-ci.plugins</groupId>
77
<artifactId>plugin</artifactId>
8-
<version>4.34</version>
8+
<version>4.37</version>
99
<relativePath />
1010
</parent>
1111

src/main/java/io/jenkins/plugins/restlistparam/logic/ValueResolver.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package io.jenkins.plugins.restlistparam.logic;
22

3-
import com.jayway.jsonpath.InvalidJsonException;
4-
import com.jayway.jsonpath.InvalidPathException;
5-
import com.jayway.jsonpath.JsonPath;
6-
import com.jayway.jsonpath.PathNotFoundException;
3+
import com.jayway.jsonpath.*;
74
import io.jenkins.plugins.restlistparam.Messages;
85
import io.jenkins.plugins.restlistparam.model.MimeType;
96
import io.jenkins.plugins.restlistparam.model.ResultContainer;
@@ -128,7 +125,7 @@ public static ResultContainer<List<ValueItem>> resolveJsonPath(final String json
128125
resolved.stream()
129126
.map(JsonPath::parse)
130127
.map(context -> context.read("$"))
131-
.map(read -> (read instanceof Map) ? JsonPath.parse(read).jsonString() : (String) read)
128+
.map(ValueResolver::convertToString)
132129
.map(value -> new ValueItem(value, parseDisplayValue(value, displayExpression)))
133130
.collect(Collectors.toList())
134131
);
@@ -158,6 +155,24 @@ public static ResultContainer<List<ValueItem>> resolveJsonPath(final String json
158155
return container;
159156
}
160157

158+
public static String convertToString(Object obj) {
159+
if (obj instanceof Map) {
160+
return JsonPath.parse(obj).jsonString();
161+
}
162+
else if (obj instanceof Integer) {
163+
return Integer.toString((Integer) obj);
164+
}
165+
else if (obj instanceof Float) {
166+
return Float.toString((Float) obj);
167+
}
168+
else if (obj instanceof String) {
169+
return (String) obj;
170+
}
171+
else {
172+
throw new ClassCastException("Unable to cast '" + obj.getClass().getCanonicalName() + "' to String");
173+
}
174+
}
175+
161176
/**
162177
* Apply the display expression filter on a given value (only JSON supported).
163178
*

0 commit comments

Comments
 (0)