Repository navigation
Coerce numeric types when loading saved layout properties - #3202
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
java.lang.Integer). If a layout later changes a property type (e.g.Integer→Longafter a refactor), loading fails withIllegalArgumentException: argument type mismatchfromMethod.invoke— the deserializedIntegercan't be passed to aLongsetter.coerceNumerichelper that converts anyNumbervalue to the property's expected numeric type before callingsetValue, covering all primitive wrapper conversions (Integer ↔ Long ↔ Float ↔ Double ↔ Short ↔ Byte). Non-numeric mismatches still fall through to the catch block.WARNING(which triggers Gephi'sReporterHandlerand sends a Sentry event) toFINE, 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
ReporterHandlercaptures anyLogRecordthat has aThrowableattached, 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
IntegertoLong— project opens, property silently skipped or correctly coerced🤖 Generated with Claude Code