I want to suppress an error that I got by running mvn spotbugs:check
I have a file named requestBodyDto.java
in my code as below:
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
/**
* Data Transfer Object (DTO) representing the request body.
*/
@Getter
@Setter
@AllArgsConstructor
public class RequestBodyDto {
/**
* Reference of the sender.
*/
@JsonProperty("sender_reference")
private String senderReference;
/**
* Type of the message.
*/
@JsonProperty("message_type")
private String messageType;
/**
* Sender information.
*/
private String sender;
/**
* Receiver information.
*/
private String receiver;
/**
* Network information.
*/
@JsonProperty("network_info")
private NetworkInfo networkInfo;
/**
* Payload of the message.
*/
private String payload;
/**
* Network information nested class.
*/
@Getter
@Setter
@AllArgsConstructor
public static class NetworkInfo {
/**
* Priority of the network.
*/
private NetworkPriority networkPriority;
/**
* Unique End-to-End Transaction Reference (UETR).
*/
private String uetr;
/**
* Delivery monitoring status.
*/
private DeliveryMonitoring deliveryMonitoring;
/**
* Indicates if the message is a possible duplicate.
*/
private boolean possibleDuplicate;
/**
* Identifier for validation.
*/
private String validationIdentifier;
/**
* Identifier for the service type.
*/
private String serviceTypeIdentifier;
}
/**
* Enum representing network priority.
*/
public enum NetworkPriority {
/**
* Normal network priority.
*/
Normal,
/**
* Urgent network priority.
*/
Urgent,
/**
* System-level network priority.
*/
System
}
/**
* Enum representing delivery monitoring status.
*/
public enum DeliveryMonitoring {
/**
* No delivery monitoring.
*/
None,
/**
* Monitoring for non-delivery.
*/
NonDelivery,
/**
* Monitoring for both non-delivery and delivery.
*/
NonDeliveryAndDelivery,
/**
* Monitoring for successful delivery.
*/
Delivery
}
On running mvn spotbugs:check
I am receiving the following error :
[ERROR] new com.guardianlife.connector.client.messaging.dto.RequestBodyDto(String, String, String, String, RequestBodyDto$NetworkInfo, String) may expose internal representation by storing an externally mutable object into RequestBodyDto.networkInfo [com.guardianlife.connector.client.messaging.dto.RequestBodyDto] At RequestBodyDto.java:[line 13] EI_EXPOSE_REP2
I have written a spotbugsSuppression.xml
file that suppresses two errors :
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<!-- Suppress SpotBugs warnings for internal representation exposure -->
<Match>
<Bug pattern="EI_EXPOSE_REP" />
<Class name="com.guardianlife.connector.client.messaging.dto.RequestBodyDto" />
<Method name="getNetworkInfo" />
</Match>
<Match>
<Bug pattern="EI_EXPOSE_REP2" />
<Class name="com.guardianlife.connector.client.messaging.dto.RequestBodyDto" />
<Method name="setNetworkInfo" />
</Match>
</FindBugsFilter>
I am not able to suppress the above error, I have tried every possible way of doing that but I am not able to do so. What can I try next?