Skip to content

Commit 370b91b

Browse files
committed
Merge remote-tracking branch 'origin/main' into 6.x
2 parents 35194e3 + 11b6bb2 commit 370b91b

File tree

5 files changed

+1193
-42
lines changed

5 files changed

+1193
-42
lines changed

Diff for: src/main/java/org/gitlab4j/api/models/ApplicationSettings.java

+20-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
package org.gitlab4j.api.models;
22

3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import com.fasterxml.jackson.databind.node.ObjectNode;
35
import java.io.Serializable;
6+
import java.lang.reflect.Array;
7+
import java.util.ArrayList;
48
import java.util.Date;
59
import java.util.HashMap;
10+
import java.util.List;
611
import java.util.Map;
712

813
import org.gitlab4j.api.GitLabApiException;
@@ -93,7 +98,7 @@ public Object addSetting(String setting, Object value) throws GitLabApiException
9398
public Object addSetting(Setting setting, Object value) throws GitLabApiException {
9499

95100
if (value instanceof JsonNode) {
96-
value = jsonNodeToValue((JsonNode)value);
101+
value = jsonNodeToValue((JsonNode)value, setting);
97102
}
98103

99104
setting.validate(value);
@@ -113,7 +118,7 @@ public void clearSettings() {
113118
settings.clear();
114119
}
115120

116-
private Object jsonNodeToValue(JsonNode node) {
121+
private Object jsonNodeToValue(JsonNode node, Setting setting) {
117122

118123
Object value = node;
119124
if (node instanceof NullNode) {
@@ -129,14 +134,20 @@ private Object jsonNodeToValue(JsonNode node) {
129134
} else if (node instanceof DoubleNode) {
130135
value = (float)((DoubleNode)node).asDouble();
131136
} else if (node instanceof ArrayNode) {
132-
133-
int numItems = node.size();
134-
String[] values = new String[numItems];
135-
for (int i = 0; i < numItems; i++) {
136-
values[i] = node.path(i).asText();
137+
if (node.isEmpty()) {
138+
value = setting.emptyArrayValue();
139+
} else {
140+
List<Object> values = new ArrayList<>(node.size());
141+
node.forEach(element -> values.add(jsonNodeToValue(element, setting)));
142+
Class<?> type = values.get(0).getClass();
143+
value = Array.newInstance(type, values.size());
144+
for (int i = 0; i < values.size(); i++) {
145+
Array.set(value, i, type.cast(values.get(i)));
146+
}
137147
}
138-
139-
value = values;
148+
} else if (node instanceof ObjectNode) {
149+
ObjectMapper mapper = new ObjectMapper();
150+
value = mapper.convertValue(node, HashMap.class);
140151
}
141152

142153
return (value);

Diff for: src/main/java/org/gitlab4j/api/models/Job.java

+9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class Job implements Serializable {
2828
private String webUrl;
2929
private String stage;
3030
private JobStatus status;
31+
private String failureReason;
3132
private String when;
3233
private Boolean manual;
3334
private Boolean allowFailure;
@@ -164,6 +165,14 @@ public void setStatus(JobStatus status) {
164165
this.status = status;
165166
}
166167

168+
public String getFailureReason() {
169+
return this.failureReason;
170+
}
171+
172+
public void setFailureReason(String failureReason) {
173+
this.failureReason = failureReason;
174+
}
175+
167176
public String getCoverage() {
168177
return coverage;
169178
}

0 commit comments

Comments
 (0)