This is an automated email from the ASF dual-hosted git repository. dgriffon pushed a commit to branch bump-yauaa in repository https://gitbox.apache.org/repos/asf/unomi.git
commit f6dde90ba3237de7eb6b98aeb1d4d6b405c889e8 Author: David Griffon <dgrif...@jahia.com> AuthorDate: Tue Nov 15 08:51:39 2022 +0100 UNOMI-710 : bump Yauaa to 7.8.0 --- plugins/request/pom.xml | 9 ++++++++- .../request/useragent/UserAgentDetectorServiceImpl.java | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/plugins/request/pom.xml b/plugins/request/pom.xml index 959031489..f6cf6bea1 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..ffd86e30c 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 @@ -17,10 +17,14 @@ package org.apache.unomi.plugins.request.useragent; +import nl.basjes.parse.useragent.AbstractUserAgentAnalyzer; import nl.basjes.parse.useragent.UserAgentAnalyzer; +import org.apache.commons.collections.map.LRUMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Collections; + /** * @author fpa...@apache.org */ @@ -34,9 +38,18 @@ public class UserAgentDetectorServiceImpl { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); - this.userAgentAnalyzer = UserAgentAnalyzer + final UserAgentAnalyzer.UserAgentAnalyzerBuilder userAgentAnalyzerBuilder = UserAgentAnalyzer .newBuilder() .hideMatcherLoadStats() + .immediateInitialization(); + this.userAgentAnalyzer = userAgentAnalyzerBuilder + // Use custom cache for jdk8 compatibility + .withCacheInstantiator( + (AbstractUserAgentAnalyzer.CacheInstantiator) size -> + Collections.synchronizedMap(new LRUMap(size))) + .withClientHintCacheInstantiator( + (AbstractUserAgentAnalyzer.ClientHintsCacheInstantiator<?>) size -> + Collections.synchronizedMap(new LRUMap(size))) .withCache(10000) .withField(nl.basjes.parse.useragent.UserAgent.OPERATING_SYSTEM_CLASS) .withField(nl.basjes.parse.useragent.UserAgent.OPERATING_SYSTEM_NAME) @@ -46,7 +59,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);