Data loss after decoding and then encoding again a fit file

Hi everybody.

Good morning.

I'm using the Garmin Fit SDK version 21.67.00. Starting from the Java examples, I've written a test class that decodes a .fit file, downloaded from Strava, encodes the file again into another file, decodes it back. The aim was to see if the roundtrip, with no modification to the messages, was working fine. Unfortunately, in my case when I save the  FitMessages using the FileEncoder class, something is changed and so the encoded file gets different content for the DeviceInfoMesgs and the contained DeveloperFields.

Basically, I write the messages as follows

FileEncoder fileEncoder = new FileEncoder(filePath.toFile(), com.garmin.fit.Fit.ProtocolVersion.V2_0);

FitMessages fitMessages = ... // content read using FitDecoder class

// Same order found in FitListener
fileEncoder.write(fitMessages.getFileIdMesgs());
fileEncoder.write(fitMessages.getCapabilitiesMesgs());
fileEncoder.write(fitMessages.getDeviceSettingsMesgs());
// ... more messages
fileEncoder.write(fitMessages.getEventMesgs());
fileEncoder.write(fitMessages.getDeviceInfoMesgs());
fileEncoder.write(fitMessages.getWorkoutMesgs());
// ... more messages

fileEncoder.close();

Any idea of what I am doing wrong or what is happening when I encode the fit file?