Skip to content

Commit

Permalink
Merge branch 'master' into fix#5340
Browse files Browse the repository at this point in the history
  • Loading branch information
Aias00 authored Dec 26, 2024
2 parents c5b7b18 + f5733b3 commit 8b43eaf
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 14 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<!-- dependency version start -->
<jasypt.version>1.9.2</jasypt.version>
<mybatis.starter.version>3.0.3</mybatis.starter.version>
<mysql.version>8.0.29</mysql.version>
<mysql.version>8.3.0</mysql.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<guava.version>32.0.0-jre</guava.version>
<commons-collections4.version>4.4</commons-collections4.version>
Expand Down Expand Up @@ -315,8 +315,8 @@
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>${mysql.version}</version>
<scope>provided</scope>
</dependency>
Expand Down
4 changes: 2 additions & 2 deletions shenyu-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.internal.http.HttpMethod;
import okhttp3.logging.HttpLoggingInterceptor;
import okhttp3.logging.HttpLoggingInterceptor.Level;
import org.apache.commons.codec.digest.DigestUtils;
Expand Down Expand Up @@ -220,15 +221,16 @@ public String request(final String url, final Map<String, ?> form, final Map<Str
* @param url url
* @param json json
* @param header header
* @param method method
* @return Response
* @throws IOException IOException
*/
public Response requestJson(final String url, final String json,
final Map<String, String> header) throws IOException {
final Map<String, String> header, final HTTPMethod method) throws IOException {
RequestBody body = RequestBody.create(MEDIA_TYPE_JSON, json);
Request.Builder requestBuilder = new Request.Builder()
.url(url)
.post(body);
.method(method.value(), HttpMethod.requiresRequestBody(method.value()) ? body : null);
addHeader(requestBuilder, header);

Request request = requestBuilder.build();
Expand Down Expand Up @@ -305,7 +307,7 @@ public Response requestCall(final String url, final Map<String, ?> form, final M
if (Objects.nonNull(files) && !files.isEmpty()) {
return requestFile(url, form, header, files);
} else if (isJsonRequest(header)) {
return requestJson(url, JsonUtils.toJson(form), header);
return requestJson(url, JsonUtils.toJson(form), header, method);
} else {
return requestForResponse(url, form, header, method);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.springframework.http.client.ClientHttpResponse;

import java.io.IOException;
import java.util.Objects;

/**
* Rest Template interceptor adds request header information.
Expand All @@ -35,11 +36,12 @@ public class HeaderRequestInterceptor implements ClientHttpRequestInterceptor {
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body, final ClientHttpRequestExecution execution)
throws IOException {
// Send json by default
if (request.getHeaders().getContentType() == null) {
request.getHeaders().setContentType(MediaType.APPLICATION_JSON);
HttpHeaders headers = request.getHeaders();
if (Objects.isNull(headers.getContentType())) {
headers.setContentType(MediaType.APPLICATION_JSON);
}
// Use short links
request.getHeaders().add(HttpHeaders.CONNECTION, "close");
headers.add(HttpHeaders.CONNECTION, "close");
return execution.execute(request, body);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* alert notice send failed.
*/
public class AlertNoticeException extends RuntimeException {

private static final long serialVersionUID = 1904557336581968426L;

public AlertNoticeException(final String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
* AlertReceiver.
*/
public class AlertReceiverDTO implements Serializable {


private static final long serialVersionUID = 1790514185328089645L;

/**
* primary key id.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Objects;
import java.util.TimeZone;

/**
Expand Down Expand Up @@ -67,7 +68,7 @@ protected String renderContent(final AlarmContent alert) {
protected abstract String templateName();

private static String removeBlankLine(final String value) {
if (value == null) {
if (Objects.isNull(value)) {
return null;
}
return value.replaceAll("(?m)^\\s*$(\\n|\\r\\n)", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import jakarta.mail.internet.MimeMessage;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;

/**
* email alert notice.
Expand Down Expand Up @@ -80,7 +81,7 @@ private String buildAlertHtmlTemplate(final AlarmContent alert) {
context.setVariable("content", alert.getContent());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date alertTime = alert.getDateCreated();
if (alertTime == null) {
if (Objects.isNull(alert)) {
alertTime = new Date();
}
String alarmTime = simpleDateFormat.format(alertTime);
Expand Down

0 comments on commit 8b43eaf

Please sign in to comment.