HessianCodec implements Codec { @Override public Message decode(Payload payload) { try { byte[] bytesData = crypt.decrypt(payload.getData().array()); byte[] bytesHeaders = crypt.decrypt(payload.getMetadata().array()); ByteArrayInputStream streamData = new ByteArrayInputStream(bytesData); Hessian2StreamingInput hessianData = new Hessian2StreamingInput(streamData); ByteArrayInputStream streamHeader = new ByteArrayInputStream(bytesHeaders); Hessian2StreamingInput hessianHeader = new Hessian2StreamingInput(streamHeader); try { Message message = new Message((HashMap<String, String>)hessianHeader.readObject(), hessianData.readObject()); String c = message.getHeader("Crypt"); if (crypt.cryptSign().equals(c)){ return message; } else { throw new RuntimeException("Crypt Error! Excepted " + crypt.cryptSign() + ", get " + c ); } } catch (IOException e){ throw new RuntimeException(); } } catch (BadPaddingException e){ throw new RuntimeException("Crypt Error! Invalid Key"); } } HessianCodec(Crypt crypt); @Override Payload encode(Message message); @Override Message decode(Payload payload);  }
@Test void decode() { Mono.justOrEmpty("dsf") .switchIfEmpty(Mono.just("12312")) .subscribe(System.out::print); }