Skip to content

Commit

Permalink
refactor: null 가능성 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
limehee committed Jul 19, 2024
1 parent 7f984ba commit 46b220f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;

Expand Down Expand Up @@ -79,7 +80,7 @@ public String saveFile(MultipartFile multipartFile, String category) throws IOEx
try {
if (isImageFile(multipartFile)) {
BufferedImage originalImage = adjustImageDirection(multipartFile);
ImageIO.write(originalImage, extension, file);
ImageIO.write(originalImage, Objects.requireNonNull(extension), file);
} else {
multipartFile.transferTo(file);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import org.thymeleaf.spring6.templateresolver.SpringResourceTemplateResolver;
import org.thymeleaf.templatemode.TemplateMode;

import java.util.Objects;

@Configuration
public class ThymeleafConfig {

@Bean
public SpringResourceTemplateResolver springResourceTemplateResolver() {
SpringResourceTemplateResolver springResourceTemplateResolver = new SpringResourceTemplateResolver();
springResourceTemplateResolver.setPrefix(getClass().getResource("/templates/").toString());
springResourceTemplateResolver.setPrefix(Objects.requireNonNull(getClass().getResource("/templates/")).toString());
springResourceTemplateResolver.setCharacterEncoding("UTF-8");
springResourceTemplateResolver.setTemplateMode(TemplateMode.HTML);
springResourceTemplateResolver.setCacheable(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
Expand All @@ -14,13 +15,13 @@
public class ApiLoggingInterceptor implements HandlerInterceptor {

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
public boolean preHandle(HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler) throws Exception {
request.setAttribute("startTime", System.currentTimeMillis());
return true;
}

@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, @NotNull Object handler, Exception ex) throws Exception {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String id = (authentication == null || authentication.getName() == null) ? "anonymous" : authentication.getName();
String clientIpAddress = HttpReqResUtil.getClientIpAddressIfServletRequestExist();
Expand Down

0 comments on commit 46b220f

Please sign in to comment.