Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
usfalami committed May 17, 2024
2 parents b4e9acd + 536f592 commit 3142f93
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.oneteme.traceapi</groupId>
<artifactId>traceapi-core</artifactId>
<version>0.0.19</version>
<version>0.0.20</version>
<packaging>jar</packaging>
<name>traceapi-core</name>
<description>traceapi-core</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttp
warnNoSession();
return execution.execute(request, body);
}
session.lock();
log.trace("outcoming request : {}", request.getURI());
var out = new ApiRequest();
ClientHttpResponse res = null;
Expand Down Expand Up @@ -79,7 +78,6 @@ public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttp
log.warn("error while tracing : " + request, e);
//do not throw exception
}
session.unlock();
}
return res;
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/usf/traceapi/core/DataSourceWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ private Connection getConnection(SQLSupplier<Connection> cnSupp) throws SQLExcep
warnNoSession();
return cnSupp.get();
}
session.lock();
log.trace("outcoming query.."); // no id
JDBCActionTracer tracer = new JDBCActionTracer();
var out = new DatabaseRequest();
Expand Down Expand Up @@ -94,7 +93,6 @@ private Connection getConnection(SQLSupplier<Connection> cnSupp) throws SQLExcep
log.warn("error while tracing : " + cn, e);
//do not throw exception
}
session.unlock();
}
return cn;
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/usf/traceapi/core/PreparedStatementWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,16 @@ public long executeLargeUpdate() throws SQLException {
public ResultSetMetaData getMetaData() throws SQLException {
return tracer.resultSetMetadata(ps::getMetaData);
}

// Override StatementWrapper

@Override
public int[] executeBatch() throws SQLException {
return tracer.executeBatch(sql, st::executeBatch);
}

@Override
public long[] executeLargeBatch() throws SQLException {
return tracer.executeLargeBatch(sql, st::executeLargeBatch);
}
}
8 changes: 7 additions & 1 deletion src/main/java/org/usf/traceapi/core/Session.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.usf.traceapi.core;

import static java.util.UUID.randomUUID;
import static org.usf.traceapi.core.Helper.log;

import java.util.Collection;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -41,7 +42,12 @@ default void lock(){
}

default void unlock() {
getLock().decrementAndGet();
if(getLock().get() > 0) {
getLock().decrementAndGet();
}
else {
log.warn("no more lock");
}
}

default boolean wasCompleted() {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/org/usf/traceapi/core/TraceableAspect.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ Object aroundBatch(ProceedingJoinPoint joinPoint) throws Throwable {
}

static Object aroundStage(ProceedingJoinPoint joinPoint, Session session) throws Throwable {
session.lock();
log.trace("stage : {} <= {}", session.getId(), joinPoint.getSignature());
Exception ex = null;
var beg = now();
Expand All @@ -106,7 +105,6 @@ static Object aroundStage(ProceedingJoinPoint joinPoint, Session session) throws
log.warn("error while tracing : " + joinPoint.getSignature(), e);
//do not throw exception
}
session.unlock();
}
}

Expand Down

0 comments on commit 3142f93

Please sign in to comment.