Skip to content

[1 - 2단계 Tomcat 구현하기] 조조(조은별) 미션 제출합니다#518

Merged
ChooSeoyeon merged 22 commits intowoowacourse:eun-byeolfrom
eun-byeol:step1
Sep 10, 2024
Merged

[1 - 2단계 Tomcat 구현하기] 조조(조은별) 미션 제출합니다#518
ChooSeoyeon merged 22 commits intowoowacourse:eun-byeolfrom
eun-byeol:step1

Conversation

@eun-byeol
Copy link
Copy Markdown

@eun-byeol eun-byeol commented Sep 6, 2024

도라 반가워요😄

1~2.2단계까지 구현했습니다.
자세한 기능 목록은 README에 적어놓았으니, 확인해주시면 좋을 것 같아요!

아직 코드가 많이 깔끔하지 못해요. 더 많이 리팩터링을 하고싶었는데 시간상 하지 못했네요..! 아래 TODO는 추후 반영해놓겠습니다.

TODO:
- response 중복 코드 제거
- 회원가입시 중복 account 예외처리
- Content-Type or Accept로 분기처리(현재는 path의 확장자로 확인하고 있음)

코드에서 읽기 힘든 부분이 있다면 주저없이 바로 DM 주세요!
감사합니다:)

@3Juhwan 3Juhwan deleted the branch woowacourse:eun-byeol September 6, 2024 06:51
@3Juhwan 3Juhwan closed this Sep 6, 2024
@eun-byeol eun-byeol reopened this Sep 6, 2024
@eun-byeol eun-byeol changed the title [1 -2단계 - Tomcat 구현하기] 조조(조은별) 미션 제출합니다 [1 - 2단계 Tomcat 구현하기] 조조(조은별) 미션 제출합니다 Sep 6, 2024
Copy link
Copy Markdown
Member

@ChooSeoyeon ChooSeoyeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안녕하세요 조조!

미션 요구사항을 잘 만족해주신 거 같아요!
리팩토링은 다음 단계에 집중적으로 리뷰할 예정이라,
구조적인 부분보단 기능적인 부분 위주로 리뷰 남겼습니다:)

학습테스트 관련해선 조조의 생각 위주로 답변 남겨주시면 감사하겠습니다!

다음 리뷰 요청 시 머지할 예정입니다! 화이팅입니다~

// todo
final String actual = "";
URL url = getClass().getClassLoader().getResource(fileName);
final String actual = Objects.requireNonNull(url).getFile();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null 처리 명시적으로 해주는 거 좋네요~
사소한 부분이긴 한데, getFile과 getPath 간에 어떤 차이가 있는지 알아보셔도 좋을 거 같아요!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • getPath: 경로만 반환
  • getFile: 경로 + 쿼리 문자열 반환

덕분에 새로운 내용 학습하고 갑니다👍

Comment thread study/src/test/java/study/FileTest.java Outdated

assertThat(actual).containsOnly("nextstep");
try (BufferedReader bufferedReader = Files.newBufferedReader(path)) {
List<String> actual = bufferedReader.lines().toList();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

바꾸자는 건 아니고 궁금한 점입니다:)
해당 테스트에서 Files.lines(path)를 사용하는 대신,
Files.newBufferedReader(path)와 bufferedReader.lines()를 조합해 사용하는 방식을 선택하신 이유가 궁금합니다!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

큰 이유는 없었어요. 테스트가 돌아가게 하는게 먼저였습니다.
언급해주신 Files.lines(path)으로 바로 Stream을 만드는게 더 간단하네요.
현재 로직에서는 BufferedReader를 Stream으로 바꾸고 다시 List로 만들고 있으니 불필요하구요👍


try (inputStream) {
} catch (Exception e) {
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

자원해제를 위해 반드시 catch가 필요한 건 아니기에,
지금처럼 예외를 별도로 처리하지 않고 있다면 catch문을 빼보는 것도 고려해볼 수 있을 거 같습니다!
어떻게 생각하시는지 궁금합니다!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

자원해제시에 catch문이 꼭 필요하지 않다는 것에 동의해요!
다만, catch 문을 둔 이유는 자원해제시 에러가 발생했을 때 예외를 던지지 않게 하기 위함이었어요. 코드는 없지만 예외를 처리하고 있다고 생각해요. 다만, 로그를 남겼으면 더 좋을 것 같네요!

String responseBody = new String(Files.readAllBytes(new File(resource.getFile()).toPath()));
return String.join("\r\n",
"HTTP/1.1 200 OK ",
"Content-Type: text/css;charset=utf-8 ",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Content-Type css 의도하신거 맞나용?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

실수한 부분이 있었네요😅 javascript로 수정했습니다! 예리하시네요👍

email = tokenizer.nextToken();
}
}
InMemoryUserRepository.save(new User(account, password, email));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

account, password, email 값이 없을 때 "", "", "" 값이 user에 저장되는거 의도하신 거 맞나용??

Copy link
Copy Markdown
Author

@eun-byeol eun-byeol Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해피케이스만 고려를 해서, 아직 예외처리를 하지 못했어요.

+) 우선은 간단하게 예외 발생시키는 부분만 추가했어요. 핸들링과 다른 예외처리 부분도 추후 구현하겠습니다👍

if (account.isBlank() || password.isBlank() || email.isBlank()) { // TODO: 예외처리 개선
    throw new IllegalArgumentException("올바르지 않은 request body 형식입니다.");
}

Copy link
Copy Markdown
Member

@ChooSeoyeon ChooSeoyeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안녕하세요 조조!

미션 요구사항을 잘 만족해주신 거 같아요!
리팩토링은 다음 단계에 집중적으로 리뷰할 예정이라,
구조적인 부분보단 기능적인 부분 위주로 리뷰 남겼습니다:)

학습테스트 관련해선 조조의 생각 위주로 답변 남겨주시면 감사하겠습니다!

다음 리뷰 요청 시 머지할 예정입니다! 화이팅입니다~

@eun-byeol
Copy link
Copy Markdown
Author

도라, 조조입니다! 코드가 많이 지저분했을텐데, 꼼꼼하게 봐주셔서 감사해요☺️
2.4까지 구현 완료하고 추가 리뷰보내려고 했는데, 더 길어질 것 같아 리뷰만 반영 후에 다시 요청드렸어요.
다음 PR에는 2.4 + 3단계를 구현 후에 PR 보낼 예정입니다.
요즘도 많이 바쁠텐데, 화이팅합시다!💪

@ChooSeoyeon
Copy link
Copy Markdown
Member

조조! 도라입니다:)
리뷰 남겼던 부분 꼼꼼히 반영해주셨네요!
이번 단계는 여기까지 진행하고 다음 단계에서 뵙겠습니다:)

@ChooSeoyeon ChooSeoyeon merged commit 2b53964 into woowacourse:eun-byeol Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants