SonarQube - makes a field temporary or serializable

I am trying to solve the following violation reported by the sonarQube plugin for Jenkins: "make" update "transient or serializable". Gravity: critical, tag: serialization.

I have the following general interface

public interface MPUpdate {

    void apply( SoapService svc, byte[] jerseyClientResp ) throws MPException ;
}

The following listing is an entry point for 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 logic blocks initialized through 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, the way it is used:

...
String levelFromUrl = getLevel(); // eg. "programmes"
MPUpdate resource;
resource = DomainResource.valueOf( levelFromUrl.toUpperCase() ); 
...
resource.apply( soapService, jerseyClientOutcome );
...

Any help? Does enum use performance enhancement for logging?

Many thanks

+4
source share
1 answer

. . , . , ( ).

+3

All Articles