Source:
<code>public String compact() { if (this.serializer == null) { <START> InstanceLocator<Serializer<Map<String,?>>> instanceLocator = new RuntimeClasspathSerializerLocator<>(); <END> this.serializer = instanceLocator.getInstance(); } if (payload == null && Collections.isEmpty(claims)) { throw new IllegalStateException("Either 'payload' or 'claims' must be specified."); } if (payload != null && !Collections.isEmpty(claims)) { throw new IllegalStateException("Both 'payload' and 'claims' cannot both be specified. Choose either one."); } Header header = ensureHeader(); JwsHeader jwsHeader; if (header instanceof JwsHeader) { jwsHeader = (JwsHeader) header; } else { jwsHeader = new DefaultJwsHeader(header); } if (key != null) { jwsHeader.setAlgorithm(algorithm.getValue()); } else { jwsHeader.setAlgorithm(SignatureAlgorithm.NONE.getValue()); } if (compressionCodec != null) { jwsHeader.setCompressionAlgorithm(compressionCodec.getAlgorithmName()); } String base64UrlEncodedHeader = base64UrlEncode(jwsHeader, "Unable to serialize header to json."); byte[] bytes; try { bytes = this.payload != null ? payload.getBytes(Strings.UTF_8) : toJson(claims); } catch (SerializationException e) { throw new IllegalArgumentException("Unable to serialize claims object to json: " + e.getMessage(), e); } if (compressionCodec != null) { bytes = compressionCodec.compress(bytes); } String base64UrlEncodedBody = base64UrlEncoder.encode(bytes); String jwt = base64UrlEncodedHeader + JwtParser.SEPARATOR_CHAR + base64UrlEncodedBody; if (key != null) { JwtSigner signer = createSigner(algorithm, key); String base64UrlSignature = signer.sign(jwt); jwt += JwtParser.SEPARATOR_CHAR + base64UrlSignature; } else { jwt += JwtParser.SEPARATOR_CHAR; } return jwt; }</code><technical_language>I this cruft cleaned api impl modules. new change correct</technical_language>

Target:
public String compact() { if (this.serializer == null) { this.serializer = LegacyServices.loadFirst(Serializer.class); } if (payload == null && Collections.isEmpty(claims)) { throw new IllegalStateException("Either 'payload' or 'claims' must be specified."); } if (payload != null && !Collections.isEmpty(claims)) { throw new IllegalStateException("Both 'payload' and 'claims' cannot both be specified. Choose either one."); } Header header = ensureHeader(); JwsHeader jwsHeader; if (header instanceof JwsHeader) { jwsHeader = (JwsHeader) header; } else { jwsHeader = new DefaultJwsHeader(header); } if (key != null) { jwsHeader.setAlgorithm(algorithm.getValue()); } else { jwsHeader.setAlgorithm(SignatureAlgorithm.NONE.getValue()); } if (compressionCodec != null) { jwsHeader.setCompressionAlgorithm(compressionCodec.getAlgorithmName()); } String base64UrlEncodedHeader = base64UrlEncode(jwsHeader, "Unable to serialize header to json."); byte[] bytes; try { bytes = this.payload != null ? payload.getBytes(Strings.UTF_8) : toJson(claims); } catch (SerializationException e) { throw new IllegalArgumentException("Unable to serialize claims object to json: " + e.getMessage(), e); } if (compressionCodec != null) { bytes = compressionCodec.compress(bytes); } String base64UrlEncodedBody = base64UrlEncoder.encode(bytes); String jwt = base64UrlEncodedHeader + JwtParser.SEPARATOR_CHAR + base64UrlEncodedBody; if (key != null) { JwtSigner signer = createSigner(algorithm, key); String base64UrlSignature = signer.sign(jwt); jwt += JwtParser.SEPARATOR_CHAR + base64UrlSignature; } else { jwt += JwtParser.SEPARATOR_CHAR; } return jwt; }