Buggy code:
@ Service public class MessageService { private static final Logger LOGGER = LoggerFactory . getLogger ( MessageService . class ) ; private static final int NUMBER_OF_MESSAGES_PER_PAGE = 100 ; @ Autowired private MessageRepository messageRepository ; @ Autowired private DocumentRepository documentRepository ; @ Autowired private Oppslagstjeneste1405 oppslagstjeneste ; @ Autowired private StringUtil stringUtil ; @ Autowired private StringWriter xmlRetrievePersonsRequest ; @ Autowired private StringWriter xmlRetrievePersonsRequestPayload ; @ Autowired private StringWriter xmlRetrievePersonsResponse ; @ Autowired private StringWriter xmlRetrievePersonsResponsePayload ; @ Autowired private Holder < StringWriter > postKlientSoapRequest ; @ Autowired private Holder < StringWriter > postKlientSoapRequestPayload ; @ Autowired private Holder < Date > postKlientSoapRequestSentDate ; @ Autowired private Holder < StringWriter > postKlientSoapResponse ; @ Autowired private Holder < StringWriter > postKlientSoapResponsePayload ; @ Autowired private Holder < Date > postKlientSoapResponseReceivedDate ; @ Autowired private CryptoUtil cryptoUtil ; @ Autowired private ConfigurationService configurationService ; @ Autowired private PostklientService postklientService ; private HentPersonerForespoersel buildHentPersonerForespoersel ( String ssn ) { } private void enrichMessage ( Message message , HentPersonerRespons hentPersonerRespons ) { } private void enrichMessage ( Message message , Forsendelse forsendelse ) { } private EpostVarsel buildEpostVarsel ( Message message ) { } private SmsVarsel buildSmsVarsel ( Message message ) { } private Sertifikat buildSertifikat ( Message message ) { } private Mottaker buildMottaker ( Message message ) { } private Dokument buildDokument ( Document document ) { } private List < Dokument > buildVedlegg ( Message message ) { } private Behandlingsansvarlig buildBehandlingsansvarlig ( Message message ) { } private Dokumentpakke buildDokumentpakke ( Message message ) { } private Forsendelse buildDigitalForsendelse ( Message message ) { } private KonvoluttAdresse buildAdressatAdresse ( Message message ) { } private KonvoluttAdresse buildReturAdresse ( Message message ) { } private Forsendelse buildFysiskForsendelse ( Message message ) { FysiskPost fysiskPost = message . getFysiskPost ( ) ; Returhaandtering returhaandtering = Returhaandtering . valueOf ( fysiskPost . getReturhaandtering ( ) . toString ( ) ) ; Posttype posttype = Posttype . valueOf ( message . getFysiskPost ( ) . getPosttype ( ) . toString ( ) ) ; Utskriftsfarge utskriftsfarge = Utskriftsfarge . valueOf ( fysiskPost . getUtskriftsfarge ( ) . toString ( ) ) ; Sertifikat sertifikat = Sertifikat . fraCertificate ( fysiskPost . getUtskriftsleverandoer ( ) . getSertifikat ( ) ) ; <START_BUG> TekniskMottaker tekniskMottaker = new TekniskMottaker ( fysiskPost . getUtskriftsleverandoer ( ) . organisasjonsnummer , sertifikat ) ; <END_BUG> no . difi . sdp . client . domain . fysisk_post . FysiskPost fysiskpost = no . difi . sdp . client . domain . fysisk_post . FysiskPost . builder ( ) . adresse ( buildAdressatAdresse ( message ) ) . retur ( returhaandtering , buildReturAdresse ( message ) ) . sendesMed ( posttype ) . utskrift ( utskriftsfarge , tekniskMottaker ) . build ( ) ; Behandlingsansvarlig behandlingsansvarlig = buildBehandlingsansvarlig ( message ) ; Dokumentpakke dokumentPakke = buildDokumentpakke ( message ) ; return Forsendelse . fysisk ( behandlingsansvarlig , fysiskpost , dokumentPakke ) . build ( ) ; } public void sendMessage ( Message message ) { } private void removeBinaryContent ( Message message ) { } private void retrieveContactDetailsFromOppslagstjeneste ( Message message ) throws MessageService . MessageServiceException { } private void sendMessageToMeldingsformidler ( Message message ) throws MessageService . MessageServiceException { } private void extractOppslagstjenesteMessages ( HentPersonerForespoersel hentPersonerForespoersel , HentPersonerRespons hentPersonerRespons ) { } public Page < Message > getMessages ( int pageNumber ) { } public Page < Message > getMessages ( MessageStatus messageStatus , int pageNumber ) { } private PageRequest buildPageRequest ( int pageNumber ) { } private Page < Message > toMessagePage ( Page < Object [ ] > rawMessagePage , PageRequest pageRequest ) { } public Message getMessage ( Long id ) { } @ Async @ Scheduled ( fixedRate = 60000 , initialDelay = 60000 ) public void getPrioritizedReceipts ( ) { } @ Async @ Scheduled ( fixedRate = 60000 , initialDelay = 60000 ) public void getNormalReceipts ( ) { } public void getReceipts ( Prioritet prioritet ) { } private boolean getReceipt ( Prioritet prioritet , SikkerDigitalPostKlient postklient ) { } public void deleteMessage ( Long id ) { } public void deleteAllMessages ( ) { } public Document getDocument ( Long id ) { } public List < Object [ ] > getReport ( ) { } public List < Object [ ] > getCountByStatus ( ) { } private class MessageServiceException extends Exception { private static final long serialVersionUID = 1L ; private MessageStatus status ; public MessageServiceException ( MessageStatus status , Exception e ) { } public MessageServiceException ( MessageStatus status , String message ) { } public MessageStatus getStatus ( ) { } } }

Fix:
TekniskMottaker tekniskMottaker = new TekniskMottaker ( fysiskPost . getUtskriftsleverandoer ( ) . getOrganisasjonsnummer ( ) , sertifikat ) ;