Skip to content

Commit 785bdea

Browse files
committed
Close resources fixed
Update of libraries
1 parent b36508d commit 785bdea

28 files changed

+64
-29
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>de.jlo.talendcomp.google</groupId>
66
<artifactId>jlo-talendcomp-google-analytics4</artifactId>
7-
<version>1.2</version>
7+
<version>1.3</version>
88
<name>GoogleAnalytics Talend Component for GA4</name>
99
<properties>
1010
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -25,12 +25,12 @@
2525
<dependency>
2626
<groupId>com.google.analytics</groupId>
2727
<artifactId>google-analytics-data</artifactId>
28-
<version>0.24.0</version>
28+
<version>0.27.0</version>
2929
</dependency>
3030
<dependency>
3131
<groupId>com.google.auth</groupId>
3232
<artifactId>google-auth-library-oauth2-http</artifactId>
33-
<version>1.16.0</version>
33+
<version>1.16.1</version>
3434
</dependency>
3535
<dependency>
3636
<groupId>org.apache.logging.log4j</groupId>

src/main/java/de/jlo/talendcomp/google/analytics/ga4/GoogleAnalyticsBase.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Date;
2222
import java.util.HashMap;
2323
import java.util.Map;
24+
import java.util.concurrent.TimeUnit;
2425

2526
import org.apache.logging.log4j.LogManager;
2627
import org.apache.logging.log4j.Logger;
@@ -116,6 +117,22 @@ public void warn(String message) {
116117
}
117118
}
118119

120+
public void warn(String message, Throwable t) {
121+
if (logger != null) {
122+
logger.warn(message, t);
123+
} else {
124+
System.err.println("WARN:" + message);
125+
}
126+
}
127+
128+
public void error(String message) {
129+
if (logger != null) {
130+
logger.error(message);
131+
} else {
132+
System.err.println("ERROR:" + message);
133+
}
134+
}
135+
119136
public void error(String message, Exception e) {
120137
if (logger != null) {
121138
if (e != null) {
@@ -132,4 +149,21 @@ public int getTimeoutInSeconds() {
132149
return timeoutInSeconds;
133150
}
134151

152+
public void close() {
153+
if (analyticsDataClient != null) {
154+
info("Close analytics client...");
155+
try {
156+
analyticsDataClient.shutdown();
157+
while (true) {
158+
if (analyticsDataClient.awaitTermination(10000, TimeUnit.MILLISECONDS)) {
159+
break;
160+
}
161+
}
162+
} catch (Throwable t) {
163+
warn("Shutdown analytics client interrupted or failed: " + t.getMessage(), t);
164+
}
165+
}
166+
info("Shutdown analytics client finished");
167+
}
168+
135169
}

src/main/java/de/jlo/talendcomp/google/analytics/ga4/v1/GoogleAnalyticsInput.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.List;
2424
import java.util.Locale;
2525
import java.util.Map;
26+
import java.util.concurrent.TimeUnit;
2627

2728
import com.google.analytics.data.v1beta.DateRange;
2829
import com.google.analytics.data.v1beta.Dimension;
@@ -650,5 +651,5 @@ public int getExpectedTotalPlainRowCount() {
650651
public int getFetchSize() {
651652
return fetchSize;
652653
}
653-
654+
654655
}
47.8 KB
Binary file not shown.
-4.47 MB
Binary file not shown.
365 KB
Binary file not shown.
140 KB
Binary file not shown.
149 KB
Binary file not shown.
53.8 KB
Binary file not shown.
241 KB
Binary file not shown.

0 commit comments

Comments
 (0)