This is an automated email from the ASF dual-hosted git repository.
dgriffon pushed a commit to branch unomi-1.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/unomi-1.x by this push:
new b5a073057 UNOMI-710 : bump Yauaa to 7.8.0 (#539)
b5a073057 is described below
commit b5a0730575cfa19b5c83395a5cf1c91b34dcd082
Author: David Griffon <[email protected]>
AuthorDate: Tue Nov 15 22:24:47 2022 +0100
UNOMI-710 : bump Yauaa to 7.8.0 (#539)
* UNOMI-710 : bump Yauaa to 7.8.0
* UNOMI-710 : add specific cache for jdk8
* UNOMI-710 : use "java.version" for version check instead of
"java.class.version"
---
plugins/request/pom.xml | 9 +++++++-
.../useragent/UserAgentDetectorServiceImpl.java | 24 +++++++++++++++++++---
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/plugins/request/pom.xml b/plugins/request/pom.xml
index c7132aa83..4405f1ae4 100644
--- a/plugins/request/pom.xml
+++ b/plugins/request/pom.xml
@@ -31,7 +31,7 @@
<packaging>bundle</packaging>
<properties>
- <yauaa.version>5.9</yauaa.version>
+ <yauaa.version>7.8.0</yauaa.version>
<kryo.version>2.24.0</kryo.version>
<minlog.version>1.3.1</minlog.version>
<prefixmap>1.1</prefixmap>
@@ -165,6 +165,13 @@
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.logging</groupId>
+ <artifactId>pax-logging-api</artifactId>
+ <version>1.11.13</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git
a/plugins/request/src/main/java/org/apache/unomi/plugins/request/useragent/UserAgentDetectorServiceImpl.java
b/plugins/request/src/main/java/org/apache/unomi/plugins/request/useragent/UserAgentDetectorServiceImpl.java
index ffff6c904..1097fca63 100644
---
a/plugins/request/src/main/java/org/apache/unomi/plugins/request/useragent/UserAgentDetectorServiceImpl.java
+++
b/plugins/request/src/main/java/org/apache/unomi/plugins/request/useragent/UserAgentDetectorServiceImpl.java
@@ -28,16 +28,35 @@ public class UserAgentDetectorServiceImpl {
private static final Logger logger =
LoggerFactory.getLogger(UserAgentDetectorServiceImpl.class.getName());
+ private final static int JDK11 = 11;
+ private final static String JDK_VERSION = "java.version";
+
private UserAgentAnalyzer userAgentAnalyzer;
public void postConstruct() {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- this.userAgentAnalyzer = UserAgentAnalyzer
+ final UserAgentAnalyzer.UserAgentAnalyzerBuilder
userAgentAnalyzerBuilder = UserAgentAnalyzer
.newBuilder()
.hideMatcherLoadStats()
- .withCache(10000)
+ .immediateInitialization();
+ // Check JDK Version
+ // Versions prior to 10 are named 1.x
+ String[] versionElements =
System.getProperty(JDK_VERSION).split("\\.");
+ int discard = Integer.parseInt(versionElements[0]);
+ int currentJDK;
+ if (discard == 1) {
+ currentJDK = Integer.parseInt(versionElements[1]);
+ } else {
+ currentJDK = discard;
+ }
+ if (currentJDK < JDK11) {
+ // Use custom cache for jdk8 compatibility
+ logger.info("Use JDK8 compliant version of the agent analyzer
caching");
+ userAgentAnalyzerBuilder.useJava8CompatibleCaching();
+ }
+ this.userAgentAnalyzer = userAgentAnalyzerBuilder.withCache(10000)
.withField(nl.basjes.parse.useragent.UserAgent.OPERATING_SYSTEM_CLASS)
.withField(nl.basjes.parse.useragent.UserAgent.OPERATING_SYSTEM_NAME)
.withField(nl.basjes.parse.useragent.UserAgent.AGENT_NAME)
@@ -46,7 +65,6 @@ public class UserAgentDetectorServiceImpl {
.withField(nl.basjes.parse.useragent.UserAgent.DEVICE_NAME)
.withField(nl.basjes.parse.useragent.UserAgent.DEVICE_BRAND)
.build();
- this.userAgentAnalyzer.immediateInitialization();
this.userAgentAnalyzer.initializeMatchers();
} finally {
Thread.currentThread().setContextClassLoader(tccl);