fix: instanceof 사용 fix

dev
gitea-관리자 1 year ago
parent 7c4adc2a34
commit d864e23fc9

@ -48,10 +48,9 @@ public class AuthentificationInterceptor implements AsyncHandlerInterceptor {//A
log.info("==== AuthentificationInterceptor checking ====");
SecurityPolicy policy = null;
if(handler instanceof HandlerMethod){
if(handler instanceof HandlerMethod method){
policy = SecurityPolicy.DEFAULT;
HandlerMethod method = (HandlerMethod)handler;
Secured secured = method.getMethod().getAnnotation(Secured.class);
if(secured != null){

@ -188,7 +188,7 @@ public class CustomRestExceptionHandler extends ResponseEntityExceptionHandler {
@ExceptionHandler(value = {RuntimeException.class})
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
protected ApiResponseDTO handleRuntimeException(RuntimeException e) {
log.error("==== throw RuntimeException ====================", e.getMessage());
log.error("==== throw RuntimeException ====================\n{}", e.getMessage());
return sendError(e);
}

@ -1,6 +1,7 @@
package kr.xit.core.spring.resolver;
import java.util.Locale;
import java.util.Objects;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.view.AbstractUrlBasedView;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
@ -25,9 +26,8 @@ public class HtmlViewResolver extends InternalResourceViewResolver {
protected View loadView(String viewName, Locale locale) throws Exception {
AbstractUrlBasedView view = buildView(viewName);
View viewObj = (View) getApplicationContext().getAutowireCapableBeanFactory().initializeBean(view, viewName);
if (viewObj instanceof JstlView) {
JstlView jv = (JstlView) viewObj;
if (jv.getBeanName().indexOf(".html") == -1) {
if (viewObj instanceof JstlView jv) {
if (!Objects.requireNonNull(jv.getBeanName()).contains(".html")) {
return null;
}
}

@ -2,6 +2,7 @@ package kr.xit.core.spring.resolver;
import java.util.Locale;
import java.util.Objects;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.view.AbstractUrlBasedView;
import org.springframework.web.servlet.view.JstlView;
@ -26,9 +27,8 @@ public class JspViewResolver extends InternalResourceViewResolver {
protected View loadView(String viewName, Locale locale) throws Exception {
AbstractUrlBasedView view = buildView(viewName);
View viewObj = (View) getApplicationContext().getAutowireCapableBeanFactory().initializeBean(view, viewName);
if (viewObj instanceof JstlView) {
JstlView jv = (JstlView) viewObj;
if (jv.getBeanName().indexOf(".jsp") == -1) {
if (viewObj instanceof JstlView jv) {
if (!Objects.requireNonNull(jv.getBeanName()).contains(".jsp")) {
return null;
}
}

@ -27,23 +27,21 @@ import org.springframework.web.reactive.function.client.WebClientRequestExceptio
*/
public class ErrorParse {
@SuppressWarnings("rawtypes")
public static ApiResponseDTO extractError(final Throwable e){
String errCode = String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value());
String message = Checks.isNotNull(e) ? e.getLocalizedMessage() : StringUtils.EMPTY;
HttpStatus httpStatus = null;
if(e instanceof BizRuntimeException be) {
//BizRuntimeException be = (BizRuntimeException)e;
return ApiResponseDTO.error(be.getCode(), be.getMessage(), HttpStatus.BAD_REQUEST);
}
if(e instanceof ClientError) {
ClientError ce = (ClientError)e;
if(e instanceof ClientError ce) {
return ApiResponseDTO.error(String.valueOf(ce.getStatus()), ce.getBody(), ce.getStatus());
}
if(e instanceof ServerError) {
ServerError ce = (ServerError) e;
if(e instanceof ServerError ce) {
return ApiResponseDTO.error(String.valueOf(ce.getStatus()), ce.getBody(), ce.getStatus());
}

@ -43,8 +43,7 @@ public class ObjectTypeHandler extends BaseTypeHandler<Object> {
public Object getNullableResult(ResultSet rs, String columnName) throws SQLException {
Object object = rs.getObject(columnName);
if (object instanceof Clob) {
Clob clob = (Clob) object;
if (object instanceof Clob clob) {
try {
int size = (int) clob.length();
return clob.getSubString(1, size);
@ -65,9 +64,8 @@ public class ObjectTypeHandler extends BaseTypeHandler<Object> {
throws SQLException {
Object object = rs.getObject(columnIndex);
if (object instanceof Clob) {
if (object instanceof Clob clob) {
Clob clob = (Clob) object;
try {
int size = (int) clob.length();
return clob.getSubString(1, size);

@ -195,10 +195,10 @@ public class JsonUtils {
for (Object key : json.keySet()) {
Object value = json.get(key);
if (value instanceof JSONObject)
extractJsonKeyValue((JSONObject)value, keyName, valueName);
else if (value instanceof JSONArray)
((JSONArray)value).forEach(obj -> extractJsonKeyValue((JSONObject)obj, keyName, valueName));
if (value instanceof JSONObject jo)
extractJsonKeyValue(jo, keyName, valueName);
else if (value instanceof JSONArray ja)
ja.forEach(obj -> extractJsonKeyValue((JSONObject)obj, keyName, valueName));
else{
//System.out.println(key + ", " + value);
keys.add(String.valueOf(key));
@ -238,10 +238,10 @@ public class JsonUtils {
for (Object key : json.keySet()) {
Object value = json.get(key);
if (value instanceof JSONObject)
extractJsonKeyValue((JSONObject)value, keyName, valueName);
else if (value instanceof JSONArray)
((JSONArray)value).forEach(obj -> extractJsonKeyValue((JSONObject)obj, keyName, valueName));
if (value instanceof JSONObject jo)
extractJsonKeyValue(jo, keyName, valueName);
else if (value instanceof JSONArray ja)
ja.forEach(obj -> extractJsonKeyValue((JSONObject)obj, keyName, valueName));
else{
//System.out.println(key + ", " + value);
keys.add(String.valueOf(key));

Loading…
Cancel
Save