Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
97af6d5
Test: a cache neither stores nor serves a cloud response with a top-l…
jwrosewell Nov 15, 2026
d26dd96
Test: only the result with a 51Did found in the cache is kept out of it
jwrosewell Nov 15, 2026
277e08d
Fix: keep a cloud response with a top-level fodid out of the result c…
jwrosewell Nov 15, 2026
2acc1b9
Test: the Pipeline interface exposes isSuppressProcessExceptions
jwrosewell Nov 15, 2026
7d91183
Fix: expose isSuppressProcessExceptions on the Pipeline interface
jwrosewell Nov 15, 2026
4486b4f
Test: only one thread at a time reads the Device Detection native res…
jwrosewell Nov 15, 2026
1366d15
Fix: hold the results lock for every read of the Device Detection nat…
jwrosewell Nov 15, 2026
7802440
Test: Latitude and Longitude are given rounded to 3 decimal places
jwrosewell Nov 15, 2026
1a4236f
Fix: move cxx to 178371ac, which rounds Azimuth and Declination numbers
jwrosewell Nov 15, 2026
bec88e9
Test: a built Pipeline's elements cannot be changed, even through its…
jwrosewell Nov 15, 2026
e72bbb7
Fix: give each Pipeline its own copy of the builder's elements
jwrosewell Nov 15, 2026
99763c0
Test: cloud and on-premise engines give results under one key and one…
jwrosewell Nov 15, 2026
f7bb902
Test: one JSON Builder in two Pipelines uses each Pipeline's own conf…
jwrosewell Nov 15, 2026
075ea83
Test: Flow Data takes writes from several threads, and locks only whe…
jwrosewell Nov 15, 2026
bed28c7
Test: FlowElement requires the Evidence keys, the Properties and the …
jwrosewell Nov 15, 2026
8a8f512
Test: cache keys come from the advertised Evidence, with values compa…
jwrosewell Nov 15, 2026
f9b0f3b
Test: a cached engine takes Evidence keys in any case as the same key
jwrosewell Nov 15, 2026
b4419d0
Test: an error in the web filter does not stop the request when excep…
jwrosewell Nov 15, 2026
d4e4bdd
Fix: let the web filter suppress its own errors as the Pipeline is se…
jwrosewell Nov 15, 2026
0425ec7
Test: an unexpected error in the background update check is logged an…
jwrosewell Nov 15, 2026
6dc6f2c
Fix: log an unexpected error in a background data update task
jwrosewell Nov 15, 2026
83eea04
Test: a Pipeline set not to close its elements leaves a shared elemen…
jwrosewell Nov 15, 2026
c334cd8
Test: closing Flow Data leaves Element Data that needs no cleanup alone
jwrosewell Nov 15, 2026
616eb15
Test: FlowData declares the exceptions its methods throw, and throws …
jwrosewell Nov 15, 2026
9497185
Fix: declare on FlowData the exceptions its methods throw
jwrosewell Nov 15, 2026
e52c0ad
Test: getWhere leaves out data that is not there rather than throwing
jwrosewell Nov 15, 2026
cab1d74
Fix: leave out of getWhere the data that is not there, and say what g…
jwrosewell Nov 15, 2026
2317375
Test: every builder setter in the pipeline packages gives its default…
jwrosewell Nov 15, 2026
5f5c8d2
Fix: give the default value beside every builder setter in the pipeli…
jwrosewell Nov 15, 2026
44eebc4
Test: only one thread at a time reads the IP Intelligence native results
jwrosewell Nov 15, 2026
3e88f26
Fix: hold the results lock for every read of the IP Intelligence nati…
jwrosewell Nov 15, 2026
b4b0df1
Test: every Device Detection and IP Intelligence builder setter gives…
jwrosewell Nov 15, 2026
55661b7
Fix: give the default beside every Device Detection and IP Intelligen…
jwrosewell Nov 15, 2026
8ad48e8
Test: a cached lazy cloud engine returns without waiting for the clou…
jwrosewell Nov 15, 2026
089dfbb
Fix: decide whether a lazy result may be cached without waiting for it
jwrosewell Nov 15, 2026
9f27d7a
Merge rc into the section 13 branch
jwrosewell Nov 18, 2026
8a51631
Merge rc into the section 13 branch
jwrosewell Nov 19, 2026
6212cb9
Take no lock on native results in the on-premise Element Data
jwrosewell Nov 19, 2026
a662e96
Test that two adds of one key neither wait nor keep two instances
jwrosewell Nov 19, 2026
4be153c
Test that a lazy result is offered to the cache on the processing thread
jwrosewell Nov 19, 2026
94e4c75
Store a lazy result in the cache on the processing thread
jwrosewell Nov 19, 2026
8bd7e35
Test that the web filter closes the Flow Data when serving fails
jwrosewell Nov 19, 2026
b39a1e2
Close the Flow Data when serving the JavaScript or JSON fails
jwrosewell Nov 19, 2026
07c6142
Merge rc into remote/java-13
jwrosewell Nov 19, 2026
7559668
Merge rc into remote/java-13, keeping rc's two setIndexedProperties s…
Jamesr51d Nov 19, 2026
da25456
Merge rc, which now runs one refresh of an engine at a time (#214)
Eddie51D Nov 20, 2026
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 cxx
Submodule cxx updated 157 files
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public DeviceDetectionHashEngineBuilder setPerformanceProfile(
}
}

@DefaultValue("Balanced")
@Override
public DeviceDetectionHashEngineBuilder setPerformanceProfile(
PerformanceProfiles profile) {
Expand Down Expand Up @@ -327,6 +328,7 @@ public DeviceDetectionHashEngineBuilder setIndexedProperties(
return setIndexedProperties(list);
}

@DefaultValue("No results cache, and none can be set for this engine")
@Override
public DeviceDetectionHashEngineBuilder setCache(
CacheConfiguration cacheConfiguration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@

/**
* Base class used for all 51Degrees on-premise device detection results classes.
* <p>
* An instance reads its values from native results, and reading a value
* writes into them, so an instance is not safe to use from several threads
* at once. The caller is responsible for thread-safe access, for example by
* wrapping its calls in a lock of its own. See the
* <a href="https://github.com/51Degrees/specifications/blob/d79bbe3b2aef86273570742f6b660f29bfe72816/pipeline-specification/features/thread-safety.md#L196-L221">thread safety specification</a>.
*/
public abstract class DeviceDataBaseOnPremise extends DeviceDataBase
implements ProvidesValuesAsString {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import fiftyone.devicedetection.hash.engine.onpremise.flowelements.DeviceDetectionHashEngine;
import fiftyone.devicedetection.hash.engine.onpremise.flowelements.DeviceDetectionHashEngineBuilder;
import fiftyone.pipeline.annotations.DefaultValue;
import fiftyone.pipeline.core.exceptions.PipelineConfigurationException;
import fiftyone.pipeline.core.flowelements.FlowElement;
import fiftyone.pipeline.core.flowelements.Pipeline;
Expand Down Expand Up @@ -139,6 +140,8 @@ DeviceDetectionOnPremisePipelineBuilder setEngineData(byte[] data) {
* @param enabled True to enable usage sharing. False to disable.
* @return This builder instance.
*/
@DefaultValue(booleanValue = fiftyone.pipeline.engines.fiftyone
.flowelements.Constants.SHARE_USAGE_DEFAULT_ENABLED)
public DeviceDetectionOnPremisePipelineBuilder setShareUsage(
boolean enabled) {
shareUsageEnabled = enabled;
Expand All @@ -153,6 +156,7 @@ public DeviceDetectionOnPremisePipelineBuilder setShareUsage(
* @param enabled True to enable auto update. False to disable.
* @return This builder instance.
*/
@DefaultValue(booleanValue = Constants.DEFAULT_AUTOUPDATE_ENABLED)
public DeviceDetectionOnPremisePipelineBuilder setAutoUpdate(
boolean enabled) {
autoUpdateEnabled = enabled;
Expand All @@ -167,6 +171,7 @@ public DeviceDetectionOnPremisePipelineBuilder setAutoUpdate(
* @param enabled True to enable file system watcher. False to disable.
* @return This builder instance.
*/
@DefaultValue(booleanValue = Constants.DEFAULT_WATCHER_ENABLED)
public DeviceDetectionOnPremisePipelineBuilder setDataFileSystemWatcher(
boolean enabled) {
dataFileSystemWatcher = enabled;
Expand All @@ -178,6 +183,7 @@ public DeviceDetectionOnPremisePipelineBuilder setDataFileSystemWatcher(
* @param dataUpdateService an instance of a dataUpdateService
* @return This builder instance.
*/
@DefaultValue("The DataUpdateService given to the constructor")
public DeviceDetectionOnPremisePipelineBuilder setDataUpdateService(
DataUpdateService dataUpdateService) {
this.dataUpdateService = dataUpdateService;
Expand All @@ -186,7 +192,7 @@ public DeviceDetectionOnPremisePipelineBuilder setDataUpdateService(

/**
* Enable/Disable update on startup.
* Defaults to enabled.
* Defaults to disabled.
* If enabled, the auto update system will be used to check for
* an update before the device detection engine is created.
* If an update is available, it will be downloaded and applied
Expand All @@ -195,6 +201,7 @@ public DeviceDetectionOnPremisePipelineBuilder setDataUpdateService(
* @param enabled True to enable update on startup. False to disable.
* @return This builder instance.
*/
@DefaultValue(booleanValue = Constants.DEFAULT_UPDATE_ON_STARTUP)
public DeviceDetectionOnPremisePipelineBuilder setDataUpdateOnStartup(
boolean enabled) {
dataUpdateOnStartup = enabled;
Expand All @@ -208,6 +215,7 @@ public DeviceDetectionOnPremisePipelineBuilder setDataUpdateOnStartup(
* @param pollingIntervalSeconds The number of seconds between checks.
* @return This builder instance.
*/
@DefaultValue(intValue = Constants.DATA_UPDATE_POLLING_DEFAULT)
public DeviceDetectionOnPremisePipelineBuilder setUpdatePollingInterval(
int pollingIntervalSeconds) {

Expand All @@ -221,6 +229,7 @@ public DeviceDetectionOnPremisePipelineBuilder setUpdatePollingInterval(
* @param pollingIntervalMillis The number of milliseconds between checks.
* @return This builder instance.
*/
@DefaultValue(intValue = Constants.DATA_UPDATE_POLLING_DEFAULT * 1000)
public DeviceDetectionOnPremisePipelineBuilder setUpdatePollingIntervalMillis(
long pollingIntervalMillis) {
updatePollingInterval = pollingIntervalMillis;
Expand All @@ -235,6 +244,7 @@ public DeviceDetectionOnPremisePipelineBuilder setUpdatePollingIntervalMillis(
* polling interval in seconds.
* @return This builder instance.
*/
@DefaultValue(intValue = Constants.DATA_UPDATE_RANDOMISATION_DEFAULT)
public DeviceDetectionOnPremisePipelineBuilder setUpdateRandomisationMax(
int randomisationMaxSeconds) {
updateRandomisationMax = (long)randomisationMaxSeconds * 1000;
Expand All @@ -249,6 +259,7 @@ public DeviceDetectionOnPremisePipelineBuilder setUpdateRandomisationMax(
* polling interval in milliseconds.
* @return This builder instance.
*/
@DefaultValue(intValue = Constants.DATA_UPDATE_RANDOMISATION_DEFAULT * 1000)
public DeviceDetectionOnPremisePipelineBuilder setUpdateRandomisationMaxMillis(
long randomisationMaxMillis) {
updateRandomisationMax = randomisationMaxMillis;
Expand All @@ -262,6 +273,7 @@ public DeviceDetectionOnPremisePipelineBuilder setUpdateRandomisationMaxMillis(
* @param key The license key.
* @return This builder instance.
*/
@DefaultValue("No license key")
public DeviceDetectionOnPremisePipelineBuilder setDataUpdateLicenseKey(
String key) {
dataUpdateLicenseKey = key;
Expand All @@ -274,6 +286,7 @@ public DeviceDetectionOnPremisePipelineBuilder setDataUpdateLicenseKey(
* @param profile The performance profile to use.
* @return This builder instance.
*/
@DefaultValue("Balanced")
public DeviceDetectionOnPremisePipelineBuilder setPerformanceProfile(
Constants.PerformanceProfiles profile) {
performanceProfile = profile;
Expand All @@ -287,6 +300,7 @@ public DeviceDetectionOnPremisePipelineBuilder setPerformanceProfile(
* @param concurrency expected concurrent accesses
* @return this builder
*/
@DefaultValue("The result of Runtime#getRuntime().getAvailableProcessors()")
public DeviceDetectionOnPremisePipelineBuilder setConcurrency(int concurrency) {
this.concurrency = concurrency;
return this;
Expand All @@ -301,6 +315,7 @@ public DeviceDetectionOnPremisePipelineBuilder setConcurrency(int concurrency) {
* @param difference to allow
* @return this builder
*/
@DefaultValue(intValue = 0)
public DeviceDetectionOnPremisePipelineBuilder setDifference(int difference) {
this.difference = difference;
return this;
Expand All @@ -317,6 +332,7 @@ public DeviceDetectionOnPremisePipelineBuilder setDifference(int difference) {
* considered valid
* @return this builder
*/
@DefaultValue(booleanValue = false)
public DeviceDetectionOnPremisePipelineBuilder setAllowUnmatched(boolean allow) {
this.allowUnmatched = allow;
return this;
Expand All @@ -329,6 +345,7 @@ public DeviceDetectionOnPremisePipelineBuilder setAllowUnmatched(boolean allow)
* @param drift to set
* @return this builder
*/
@DefaultValue(intValue = 0)
public DeviceDetectionOnPremisePipelineBuilder setDrift(int drift) {
this.drift = drift;
return this;
Expand All @@ -346,6 +363,7 @@ public DeviceDetectionOnPremisePipelineBuilder setDrift(int drift) {
* @param use true if the performance graph should be used
* @return this builder
*/
@DefaultValue(booleanValue = false)
public DeviceDetectionOnPremisePipelineBuilder setUsePerformanceGraph(boolean use) {
this.usePerformanceGraph = use;
return this;
Expand All @@ -362,6 +380,7 @@ public DeviceDetectionOnPremisePipelineBuilder setUsePerformanceGraph(boolean us
* @param use true if the predictive graph should be used
* @return this builder
*/
@DefaultValue(booleanValue = true)
public DeviceDetectionOnPremisePipelineBuilder setUsePredictiveGraph(boolean use) {
this.usePredictiveGraph = use;
return this;
Expand All @@ -373,6 +392,7 @@ public DeviceDetectionOnPremisePipelineBuilder setUsePredictiveGraph(boolean use
* @param property the property that we want the engine to populate
* @return this builder
*/
@DefaultValue("All properties")
public DeviceDetectionOnPremisePipelineBuilder setProperty(String property) {
this.properties.add(property);
return this;
Expand All @@ -387,6 +407,7 @@ public DeviceDetectionOnPremisePipelineBuilder setProperty(String property) {
* @param url the URL to check for a new data file
* @return this builder
*/
@DefaultValue("51Degrees default, set by the engine's builder")
public DeviceDetectionOnPremisePipelineBuilder setDataUpdateUrl(String url) {
dataUpdateUrl = url;
return this;
Expand All @@ -403,6 +424,7 @@ public DeviceDetectionOnPremisePipelineBuilder setDataUpdateUrl(String url) {
* False otherwise
* @return this builder
*/
@DefaultValue(booleanValue = Constants.DEFAULT_VERIFY_MD5)
public DeviceDetectionOnPremisePipelineBuilder setDataUpdateVerifyMd5(Boolean verify) {
dataUpdateVerifyMd5 = verify;
return this;
Expand All @@ -416,6 +438,7 @@ public DeviceDetectionOnPremisePipelineBuilder setDataUpdateVerifyMd5(Boolean ve
* @param formatter the formatter to use
* @return this builder
*/
@DefaultValue("51Degrees default, set by the engine's builder")
public DeviceDetectionOnPremisePipelineBuilder setDataUpdateUrlFormatter(DataUpdateUrlFormatter formatter) {
dataUpdateUrlFormatter = formatter;
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
* ********************************************************************* */

package fiftyone.devicedetection;

import fiftyone.devicedetection.hash.engine.onpremise.flowelements.DeviceDetectionHashEngineBuilder;
import fiftyone.pipeline.annotations.DefaultValue;
import org.junit.Test;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertEquals;

/**
* Every configuration setter of the Device Detection on-premise builders
* gives its default value beside it, with {@link DefaultValue}. See
* <a href="https://github.com/51Degrees/specifications/blob/706de1f0cb3edd560eb7fd7ef3bb19b93a4883dc/pipeline-specification/reference-implementation-notes.md#L79">reference-implementation-notes.md line 79</a>:
* "In all cases, there SHOULD be some mechanism to specify the default
* values alongside configuration property setters."
*/
public class BuilderDefaultValueTests {

static List<String> missingDefaults(Class<?>... builders) {
List<String> missing = new ArrayList<>();
for (Class<?> builder : builders) {
for (Method method : builder.getDeclaredMethods()) {
if (Modifier.isPublic(method.getModifiers()) &&
method.getName().startsWith("set") &&
method.isSynthetic() == false &&
method.isBridge() == false &&
method.getAnnotation(DefaultValue.class) == null) {
missing.add(builder.getSimpleName() + "#" +
method.getName() +
Arrays.toString(method.getParameterTypes()));
}
}
}
return missing;
}

@Test
public void builderSetters_GiveTheirDefaults() {
assertEquals(new ArrayList<String>(), missingDefaults(
DeviceDetectionOnPremisePipelineBuilder.class,
DeviceDetectionHashEngineBuilder.class));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
* ********************************************************************* */

package fiftyone.devicedetection;

import fiftyone.devicedetection.cloud.flowelements.DeviceDetectionCloudEngine;
import fiftyone.devicedetection.hash.engine.onpremise.flowelements.DeviceDetectionHashEngine;
import fiftyone.devicedetection.shared.DeviceData;
import fiftyone.pipeline.core.flowelements.FlowElement;
import org.junit.Test;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.CALLS_REAL_METHODS;
import static org.mockito.Mockito.mock;

/**
* The cloud and on-premise Device Detection engines put their results in
* Flow Data under the same key and as the same interface, so a consuming
* application reads them in the same way whichever engine is in the
* Pipeline. See
* <a href="https://github.com/51Degrees/specifications/blob/706de1f0cb3edd560eb7fd7ef3bb19b93a4883dc/pipeline-specification/README.md#L95">README.md line 95</a>:
* "Where both Cloud and On-Premise variants of an Engine are available,
* they MUST arrange that the Properties and values produced are compatible
* with each other so that the Engines can be substituted in the Pipeline
* without alteration to the consuming application."
* <p>
* Comparing the values each engine gives needs a resource key and the
* native engine with a data file, so it is left to the example tests.
*/
public class CloudOnPremiseSubstitutionTests {

/**
* The engines are created without running a constructor, as only the
* data key, which is a constant, is read from them.
*/
@Test
public void elementDataKey_IsTheSame() {
FlowElement<?, ?> cloud =
mock(DeviceDetectionCloudEngine.class, CALLS_REAL_METHODS);
FlowElement<?, ?> onPremise =
mock(DeviceDetectionHashEngine.class, CALLS_REAL_METHODS);
assertEquals(
onPremise.getElementDataKey(),
cloud.getElementDataKey());
}

/**
* Each engine's Element Data is a {@link DeviceData}, which the
* consuming application asks Flow Data for.
*/
@Test
public void elementData_IsDeviceData() {
assertTrue(DeviceData.class.isAssignableFrom(
elementDataType(DeviceDetectionCloudEngine.class)));
assertTrue(DeviceData.class.isAssignableFrom(
elementDataType(DeviceDetectionHashEngine.class)));
}

/**
* The first type argument of the nearest generic superclass, which is
* the engine's Element Data type.
*/
private static Class<?> elementDataType(Class<?> engine) {
for (Class<?> c = engine; c != null; c = c.getSuperclass()) {
Type type = c.getGenericSuperclass();
if (type instanceof ParameterizedType) {
Type first =
((ParameterizedType) type).getActualTypeArguments()[0];
if (first instanceof Class) {
return (Class<?>) first;
}
}
}
assertNotNull("No Element Data type found for " + engine, null);
return null;
}
}
Loading
Loading