Skip to content

[Core] Handle JSONEncoding in encoding equality hashes - #360

Merged
alexrobin merged 1 commit into
opensensorhub:masterfrom
cam-s-hunt:fix/json-encoding-hash
Nov 4, 2026
Merged

alexrobin merged 1 commit into
opensensorhub:masterfrom
cam-s-hunt:fix/json-encoding-hash

Conversation

@cam-s-hunt

Copy link
Copy Markdown
Contributor

Summary

  • handle SWE JSONEncoding without sending it through the unsupported SWE XML
    encoding serializer;
  • use the same encoding-hash path for encoding-only and combined
    structure/encoding comparisons;
  • add regression coverage for equal JSON encodings, JSON versus Text, and the
    combined structure/JSON hash.

Problem

DataComponentChecks.getEncodingEqualsHashCode() serializes every
DataEncoding with SWEUtils.writeEncoding(..., V2_0). The SWE XML writer has
no representation for JSONEncoding, so equality comparison throws:

Error computing hashcode. Invalid data encoding

This is reachable when SystemTransactionHandler.addOrUpdateDataStream()
compares an existing datastream with a newly registered definition. A first
registration can succeed, but module restart, repeated Connected Systems API
metadata registration, or downstream datastream reconciliation can fail once
the JSON-encoded stream already exists.

Serving existing resources and posting observations to an already provisioned
datastream do not themselves require this comparison. Nodes that register or
reconcile JSON datastream metadata do.

Fix

JSONEncoding has no configurable SWE encoding properties. Hash a delimited
SWE/2.0/JSONEncoding family marker for that interface and preserve the
existing SWE serializer path for all other encoding families. Both
encoding-only and combined structure/encoding hashes call the same helper.

The marker is NUL-delimited so it cannot collide with the UTF-8 XML emitted for
the existing encoding families.

Validation

  • Focused current-master tests:
    ./gradlew :sensorhub-core:test --tests org.sensorhub.utils.TestDataComponentChecks --rerun-tasks --no-daemon --console=plain
    — 10 passed, 0 failed, 0 skipped.
  • Full current-master Core suite:
    ./gradlew :sensorhub-core:test --rerun-tasks --no-daemon --console=plain
    — 238 passed, 0 failed, 0 errors, 0 skipped across 28 suites.
  • Repository-wide current-master build:
    ./gradlew build --no-daemon --console=plain
    — did not pass because the unrelated threaded SensorML test
    TestSMLProcessing.testReadAndExecNestedChainsWithThreads intermittently
    produced 15.56 instead of 20.16. The same test passed when immediately
    rerun alone with --rerun-tasks; no SensorML source is changed by this patch.
  • A backport to OSH Core 2.0.2 was deployed on a node with five persisted JSON
    datastreams. Three consecutive process starts re-registered the unchanged
    streams without deleting or migrating the datastore.

The first local full-suite attempt encountered an unrelated full /tmp
filesystem and failed 10 temporary-file setup cases. The counted full-suite
result above used an alternate JVM temporary directory on a filesystem with
free space; the formerly failing cases and complete suite then passed.

@alexrobin
alexrobin merged commit bb4c796 into opensensorhub:master Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants