I'm trying to solve the following violation reported by sonarQube plugin for Jenkins: "make 'update' transient or serializable.". Gravity: critical, tag: serialization.
I have the following shared interface
public interface MPUpdate {
void apply( SoapService svc, byte[] jerseyClientResp ) throws MPException ;
}
The following enum is the entry point for the application logic
public enum DomainResource implements MPUpdate {
PROGRAMMES( new ProgrammeUpdate() ),
PRODUCTIONS( new ProductionUpdate() );
// more enums
private DomainResource( MPUpdate update ) {
this.update = update;
}
private final MPUpdate update; // Sonar: make "update" transient or serializable, priority: critical, tag: serialization
@Override
public void apply( SoapService svc, byte[] jerseyClientResp ) throws MPException {
update.apply( svc, jerseyClientResp );
}
}
One of the unit of logic initialized through the enum
public class ProgrammeUpdate implements MPUpdate {
private final ResponseConverter<ProgrammeDto> responseConverter = new ResponseConverter<>( ProgrammeDto.class );
@Override
public void apply( SoapService svc, byte[] jerseyClientResp ) throws MPException {
// APPLICATION LOGIC
}
}
And finally this is how it's used:
...
String levelFromUrl = getLevel(); // eg. "programmes"
MPUpdate resource;
resource = DomainResource.valueOf( levelFromUrl.toUpperCase() );
...
resource.apply( soapService, jerseyClientOutcome );
...
Any help? Does the use of enum improve performance for logging?
Many thanks