Sitelet https://github.com/gephi/gephi/pull/3202
Skip to content

Coerce numeric types when loading saved layout properties - #3202

Merged
mbastian merged 1 commit into
masterfrom
fix/layout-property-numeric-coercion
May 9, 2026
Merged

mbastian merged 1 commit into
masterfrom
fix/layout-property-numeric-coercion

Conversation

@mbastian

@mbastian mbastian commented May 9, 2026

Copy link
Copy Markdown
Member

Summary

  • When a project is saved, the value class name is written to XML (e.g. java.lang.Integer). If a layout later changes a property type (e.g. Integer → Long after a refactor), loading fails with IllegalArgumentException: argument type mismatch from Method.invoke — the deserialized Integer can't be passed to a Long setter.
  • Fix: add a coerceNumeric helper that converts any Number value to the property's expected numeric type before calling setValue, covering all primitive wrapper conversions (Integer ↔ Long ↔ Float ↔ Double ↔ Short ↔ Byte). Non-numeric mismatches still fall through to the catch block.
  • Also downgrade the fallback catch log from WARNING (which triggers Gephi's ReporterHandler and sends a Sentry event) to FINE, without attaching the throwable — a skipped property during version migration is expected noise, not a crash worth reporting.

The Sentry events were being generated because ReporterHandler captures any LogRecord that has a Throwable attached, regardless of log level. The coercion prevents the exception entirely for numeric mismatches; the log-level change silences the fallback for any remaining non-numeric mismatches.

Fixes GEPHI-5GY (11 users, 37 events), GEPHI-5JS (4 users, 4 events)

Test plan

  • Open a project saved with an older Gephi that had a layout with a property since changed from Integer to Long — project opens, property silently skipped or correctly coerced
  • Normal layout selection and property persistence — no regression
  • No Sentry events generated for layout property type mismatches after this change

🤖 Generated with Claude Code

When a project is saved, each layout property's value class name is written
to the XML (e.g. java.lang.Integer). If the layout later changes a property
type (e.g. Integer -> Long after a refactor), loading fails with
IllegalArgumentException from Method.invoke because the deserialized
Integer cannot be passed to a Long setter.

Fix: coerce Number values to the property's expected numeric type before
calling setValue, covering all primitive wrapper conversions
(Integer <-> Long <-> Float <-> Double <-> Short <-> Byte).

Also downgrade the fallback catch log from WARNING (which triggers Gephi's
ReporterHandler and sends a Sentry event) to FINE, since a skipped property
is expected version-migration noise, not a crash.

Fixes GEPHI-5GY, GEPHI-5JS

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mbastian mbastian added this to the 0.11.2 milestone May 9, 2026
@mbastian
mbastian merged commit cad58e8 into master May 9, 2026
1 check passed
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.

1 participant