Skip to content

Fix #122: Change transfer field getter/setter type from Long to Double#128

Open
namaskrutipal wants to merge 1 commit intojeevatkm:masterfrom
namaskrutipal:fix-issue-122-transfer-field-type
Open

Fix #122: Change transfer field getter/setter type from Long to Double#128
namaskrutipal wants to merge 1 commit intojeevatkm:masterfrom
namaskrutipal:fix-issue-122-transfer-field-type

Conversation

@namaskrutipal
Copy link

The DigitalOcean API returns decimal values for the transfer field (e.g., 0.5 TB), which was causing JsonSyntaxException when the getter/setter methods expected Long type. Updated getter and setter methods to use Double type to match the field declaration and properly handle both integer and decimal transfer values.

Problem

The getAvailableSizes() method was throwing JsonSyntaxException because the transfer field getter and setter methods were defined as Long, while the field itself was already declared as Double. The DigitalOcean API returns decimal values (e.g., 0.5 TB for smaller droplet sizes), causing a type mismatch during JSON deserialization.

Solution

Updated the getter and setter methods for the transfer field in Size.java to use Double type instead of Long, matching the field declaration.

Changes Made

  • Modified Size.java:
    • Changed getTransfer() return type from Long to Double
    • Changed setTransfer(Long transfer) parameter type from Long to Double

Testing

  • Ran ./mvnw verify successfully
  • Code formatted with ./mvnw com.coveo:fmt-maven-plugin:format

API Response Example

The DigitalOcean API returns:

   {
     "transfer": 0.5,
     "price_monthly": 4,
     "price_hourly": 0.00595
   }

This change ensures the API response can be properly deserialized without exceptions.

…to Double

The DigitalOcean API returns decimal values for the transfer field
(e.g., 0.5 TB), which was causing JsonSyntaxException when the
getter/setter methods expected Long type. Updated getter and setter
methods to use Double type to match the field declaration and
properly handle both integer and decimal transfer values.
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