@@ -36,19 +36,16 @@ public class WxCryptUtil {
3636 private static final Base64 BASE64 = new Base64 ();
3737 private static final Charset CHARSET = StandardCharsets .UTF_8 ;
3838
39- private static final ThreadLocal <DocumentBuilder > BUILDER_LOCAL = new ThreadLocal <DocumentBuilder >() {
40- @ Override
41- protected DocumentBuilder initialValue () {
42- try {
43- final DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance ();
44- factory .setExpandEntityReferences (false );
45- factory .setFeature ("http://apache.org/xml/features/disallow-doctype-decl" , true );
46- return factory .newDocumentBuilder ();
47- } catch (ParserConfigurationException exc ) {
48- throw new IllegalArgumentException (exc );
49- }
39+ private static final ThreadLocal <DocumentBuilder > BUILDER_LOCAL = ThreadLocal .withInitial (() -> {
40+ try {
41+ final DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance ();
42+ factory .setExpandEntityReferences (false );
43+ factory .setFeature ("http://apache.org/xml/features/disallow-doctype-decl" , true );
44+ return factory .newDocumentBuilder ();
45+ } catch (ParserConfigurationException exc ) {
46+ throw new IllegalArgumentException (exc );
5047 }
51- };
48+ }) ;
5249
5350 protected byte [] aesKey ;
5451 protected String token ;
@@ -67,7 +64,7 @@ public WxCryptUtil() {
6764 public WxCryptUtil (String token , String encodingAesKey , String appidOrCorpid ) {
6865 this .token = token ;
6966 this .appidOrCorpid = appidOrCorpid ;
70- this .aesKey = BaseEncoding . base64 (). decode (CharMatcher .whitespace ().removeFrom (encodingAesKey ));
67+ this .aesKey = Base64 . decodeBase64 (CharMatcher .whitespace ().removeFrom (encodingAesKey ));
7168 }
7269
7370 private static String extractEncryptPart (String xml ) {
0 commit comments