Skip to content

Commit

Permalink
perf($Java): upgrade Java (Temurin) to 17.0.2+8
Browse files Browse the repository at this point in the history
upgrade Java (Temurin) to 17.0.2+8
https://github.com/adoptium/temurin17-binaries/releases/tag/jdk-17.0.2%2B8

BREAKING CHANGE: upgrade Java (Temurin) to 17.0.2+8
  • Loading branch information
johnnymillergh committed Apr 6, 2022
1 parent fb14be5 commit 0b5a979
Show file tree
Hide file tree
Showing 28 changed files with 250 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
* Description: RbacReactiveAuthorizationManagerImpl
Expand Down Expand Up @@ -80,12 +79,12 @@ private Mono<List<GetPermissionListByRoleIdListResponse.Permission>> retrievePer
// Get permission list based on the Mono<List<Long>>
// auth-center will respond /** for role "admin"
return roleIdListMono.flatMap(
roleIdList -> {
val payload = new GetPermissionListByRoleIdListPayload();
payload.setRoleIdList(roleIdList);
payload.setPermissionTypeList(Lists.newArrayList(PermissionType.BUTTON));
return this.authCenterRemoteApi.getPermissionListByRoleIdList(payload);
})
roleIdList -> {
val payload = new GetPermissionListByRoleIdListPayload();
payload.setRoleIdList(roleIdList);
payload.setPermissionTypeList(Lists.newArrayList(PermissionType.BUTTON));
return this.authCenterRemoteApi.getPermissionListByRoleIdList(payload);
})
.switchIfEmpty(Mono.error(new SecurityException(HttpStatus.FORBIDDEN, "Permission not found!")));
}

Expand All @@ -103,9 +102,9 @@ public Mono<AuthorizationDecision> check(Mono<Authentication> authentication, Au
val buttonPermissionList = permissionList.stream()
.filter(permission -> StrUtil.isNotBlank(permission.getUrl()))
.filter(permission -> StrUtil.isNotBlank(permission.getMethod()))
.collect(Collectors.toList());
.toList();
val userPrincipal = mapper.getT2();
for (var buttonPermission : buttonPermissionList) {
for (val buttonPermission : buttonPermissionList) {
if (this.checkRestfulAccess(buttonPermission, request)) {
log.info("Authorization success! Resource [{}] {} is accessible for user(username: {})",
request.getMethod(), request.getURI(), userPrincipal.getUsername());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.jmsoftware.maf.apigateway.configuration;

import cn.hutool.core.util.ObjectUtil;
import com.jmsoftware.maf.apigateway.property.RedisRateLimiterConfigurationProperties;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -76,7 +75,7 @@ void postConstruct() {
public KeyResolver ipKeyResolver() {
return exchange -> {
val remoteAddress = exchange.getRequest().getRemoteAddress();
if (ObjectUtil.isNotNull(remoteAddress)) {
if (remoteAddress != null) {
return Mono.just(remoteAddress.getHostName());
}
return Mono.just("unknown-address");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.stream.Collectors;

import static cn.hutool.core.text.CharSequenceUtil.format;
import static com.jmsoftware.maf.springcloudstarter.function.Slf4j.lazyDebug;
Expand Down Expand Up @@ -67,7 +66,7 @@ public GetPermissionListByRoleIdListResponse getPermissionListByRoleIdList(
permissionList
.stream()
.map(PermissionMapStructMapper.INSTANCE::of)
.collect(Collectors.toList())
.toList()
);
return response;
}
Expand Down Expand Up @@ -97,7 +96,7 @@ public GetServicesInfoResponse getServicesInfo() {
serviceInfo.setHttpApiResources(httpApiResourcesResponse);
lazyDebug(log, () -> format("Added serviceInfo: {}", serviceInfo));
return serviceInfo;
}).collect(Collectors.toList())
}).toList()
);
if (CollUtil.isEmpty(response.getList())) {
log.warn("Got am empty ServiceInfo list");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public List<RoleExcelBean> getListForExporting() {
.getRecords()
.stream()
.map(RoleExcelBean::transformBy)
.collect(Collectors.toList());
.toList();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.jmsoftware.maf.authcenter.permission.response.GetServicesInfoResponse;
import com.jmsoftware.maf.authcenter.permission.service.PermissionService;
import com.jmsoftware.maf.common.bean.ResponseBodyBean;
import com.jmsoftware.maf.common.exception.InternalServerException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down Expand Up @@ -32,7 +31,7 @@ public class PermissionController {
* <a href='https://github.com/spring-cloud/spring-cloud-netflix/issues/990#issuecomment-214943106'>RestTemplate Excample</a>
*/
@GetMapping("/permissions/services-info")
public ResponseBodyBean<GetServicesInfoResponse> getServicesInfo() throws InternalServerException {
public ResponseBodyBean<GetServicesInfoResponse> getServicesInfo() {
return ResponseBodyBean.ofSuccess(this.permissionService.getServicesInfo());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.lang.Nullable;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Collections;
Expand All @@ -31,6 +32,7 @@ public class PageResponseBodyBean<T> extends TrackableBean implements Serializab
/**
* The constant serialVersionUID.
*/
@Serial
private static final long serialVersionUID = 4645461634548783641L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.lang.Nullable;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

Expand All @@ -26,7 +27,8 @@
@Data
@SuppressWarnings("unused")
@EqualsAndHashCode(callSuper = true)
public class ResponseBodyBean<T> extends TrackableBean implements Serializable{
public class ResponseBodyBean<T> extends TrackableBean implements Serializable {
@Serial
private static final long serialVersionUID = 4645469240048361965L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

/**
Expand All @@ -16,6 +16,8 @@
**/
@Data
public class GetRoleListByUserIdResponse implements Serializable {
@Serial
private static final long serialVersionUID = -8462678958191383914L;

private List<GetRoleListByUserIdSingleResponse> roleList;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.Data;

import java.io.Serial;
import java.io.Serializable;

/**
Expand All @@ -11,7 +12,9 @@
**/
@Data
public class GetRoleListByUserIdSingleResponse implements Serializable {
@Serial
private static final long serialVersionUID = 3758434255123050684L;

private Long id;
private String name;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serial;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

/**
* <h1>UserPrincipal</h1>
Expand All @@ -29,6 +29,7 @@
@NoArgsConstructor
@AllArgsConstructor
public class UserPrincipal implements UserDetails {
@Serial
private static final long serialVersionUID = -53353171692896501L;

/**
Expand Down Expand Up @@ -113,7 +114,7 @@ public static UserPrincipal create(GetUserByLoginTokenResponse user, List<String
val authorities = permissions.stream()
.filter(permission -> StrUtil.isNotBlank(permission.getPermissionExpression()))
.map(permission -> new SimpleGrantedAuthority(permission.getPermissionExpression()))
.collect(Collectors.toList());
.toList();

return new UserPrincipal(user.getId(),
user.getUsername(),
Expand All @@ -132,17 +133,17 @@ public static UserPrincipal create(GetUserByLoginTokenResponse user, List<String

@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return authorities;
return this.authorities;
}

@Override
public String getPassword() {
return password;
return this.password;
}

@Override
public String getUsername() {
return username;
return this.username;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ static <E extends Enum<? extends ValueDescriptionBaseEnum<V>>, V> E getByEnumNam
if (StrUtil.isEmpty(enumName)) {
return null;
}
for (Enum<? extends ValueDescriptionBaseEnum<V>> e : enumClass.getEnumConstants()) {
for (val e : enumClass.getEnumConstants()) {
if (StrUtil.equalsIgnoreCase(e.name(), enumName)) {
return (E) e;
return e;
}
}
return null;
Expand Down Expand Up @@ -165,9 +165,9 @@ static <E extends Enum<? extends ValueDescriptionBaseEnum<V>>, V> E getByValue(
if (ObjectUtil.isNull(value)) {
return null;
}
for (Enum<? extends ValueDescriptionBaseEnum<V>> e : enumClass.getEnumConstants()) {
for (val e : enumClass.getEnumConstants()) {
if (((ValueDescriptionBaseEnum<V>) e).getValue().equals(value)) {
return (E) e;
return e;
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import lombok.EqualsAndHashCode;
import org.springframework.http.HttpStatus;

import java.io.Serial;

/**
* <h1>BaseException</h1>
* <p>
Expand All @@ -14,6 +16,7 @@
@Data
@EqualsAndHashCode(callSuper = true)
public class BaseException extends Exception {
@Serial
private static final long serialVersionUID = 5049763892480652887L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.springframework.http.HttpStatus;

import java.io.Serial;

/**
* <h1>InternalServerException</h1>
* <p>
Expand All @@ -10,6 +12,7 @@
* @author Johnny Miller (锺俊), email: johnnysviva@outlook.com, date: 2019-03-02 17:15
**/
public class InternalServerException extends BaseException {
@Serial
private static final long serialVersionUID = 6403325238832002908L;

public InternalServerException(HttpStatus httpStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.springframework.http.HttpStatus;

import java.io.Serial;

/**
* <h1>ResourceNotFoundException</h1>
* <p>
Expand All @@ -10,6 +12,7 @@
* @author Johnny Miller (鍾俊), e-mail: johnnysviva@outlook.com, date: 2/19/2022 5:05 PM
**/
public class ResourceNotFoundException extends BaseException {
@Serial
private static final long serialVersionUID = -1706570460684455863L;

public ResourceNotFoundException() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.springframework.http.HttpStatus;

import java.io.Serial;

/**
* <h1>SecurityException</h1>
* <p>
Expand All @@ -10,6 +12,7 @@
* @author Johnny Miller (锺俊), email: johnnysviva@outlook.com, date 3/12/20 3:15 PM
**/
public class SecurityException extends BaseException {
@Serial
private static final long serialVersionUID = -767157443094687237L;

public SecurityException(HttpStatus httpStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ public interface ReadResourceService {
* @param object the object
* @return the response entity
*/
ResponseEntity<StreamingResponseBody> asyncGetSingleResource(String bucket, String object);
ResponseEntity<StreamingResponseBody> asyncGetSingleResource(
@NotBlank String bucket,
@NotBlank String object
);

/**
* Stream single resource, more efficiency if the resource is large file, which will be streamed by range.
Expand All @@ -35,8 +38,11 @@ public interface ReadResourceService {
* @param range the range
* @return the response entity
*/
ResponseEntity<StreamingResponseBody> asyncStreamSingleResource(@NotBlank String bucket, @NotBlank String object,
@Nullable String range);
ResponseEntity<StreamingResponseBody> asyncStreamSingleResource(
@NotBlank String bucket,
@NotBlank String object,
@Nullable String range
);

/**
* Async download single resource response entity.
Expand All @@ -45,7 +51,10 @@ ResponseEntity<StreamingResponseBody> asyncStreamSingleResource(@NotBlank String
* @param object the object
* @return the response entity
*/
ResponseEntity<StreamingResponseBody> asyncDownloadSingleResource(@NotBlank String bucket, @NotBlank String object);
ResponseEntity<StreamingResponseBody> asyncDownloadSingleResource(
@NotBlank String bucket,
@NotBlank String object
);

/**
* Gets resource information.
Expand All @@ -54,5 +63,8 @@ ResponseEntity<StreamingResponseBody> asyncStreamSingleResource(@NotBlank String
* @param object the object
* @return the resource detail
*/
SerializableStatObjectResponse stateObject(@NotBlank String bucket, @NotBlank String object);
SerializableStatObjectResponse stateObject(
@NotBlank String bucket,
@NotBlank String object
);
}
Loading

0 comments on commit 0b5a979

Please sign in to comment.