Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB Replication 시 P6spy 로깅으로 인하여 발생하는 문제 해결 #741

Merged
merged 4 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/backend-submodule
1 change: 1 addition & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
implementation 'com.amazonaws:aws-java-sdk-s3:1.12.528'
implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.9.0'

testImplementation 'io.rest-assured:rest-assured:5.3.1'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
public class ConnectionProxyHandler implements MethodInterceptor {

private static final String JDBC_PREPARE_STATEMENT_METHOD_NAME = "prepareStatement";
private static final String HIKARI_CONNECTION_NAME = "HikariProxyConnection";

private final Object connection;
private final LoggingForm loggingForm;
Expand All @@ -30,7 +31,13 @@ public Object invoke(@Nonnull final MethodInvocation invocation) throws Throwabl
}

private boolean hasPreparedStatementInvoked(final MethodInvocation invocation) {
return invocation.getMethod().getName().equals(JDBC_PREPARE_STATEMENT_METHOD_NAME);
final Object targetObject = invocation.getThis();
if (targetObject == null) {
return false;
}
final Class<?> targetClass = targetObject.getClass();
return targetClass.getName().contains(HIKARI_CONNECTION_NAME) &&
invocation.getMethod().getName().equals(JDBC_PREPARE_STATEMENT_METHOD_NAME);
Copy link
Member

Choose a reason for hiding this comment

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

targetClass로 먼저 받은 이유가 있나용
별 이유 없다면
invocation.getMethod()도 targetMethod로 변수 뺀다음 return값에 넣는게 일관성에 맞을거 같긴 한데

뭐 이런걸 가지고 뭐라 그러냐.. 라는 생각이 들었다면 그냥 무시하고 바로 머지 ㄱㄱ

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

}

private boolean hasConnection(final Object result) {
Expand Down