Source:
<code>public static SensitiveDataCodec<String> getCodec(String codecDesc) throws ActiveMQException { SensitiveDataCodec<String> codecInstance; String[] parts = codecDesc.split(";"); if (parts.length < 1) throw new ActiveMQException(ActiveMQExceptionType.ILLEGAL_STATE, "Invalid PasswordCodec value: " + codecDesc); final String codecClassName = parts[0]; <START> codecInstance = AccessController.doPrivileged((PrivilegedAction<SensitiveDataCodec<String>>) () -> { <END> ServiceLoader<SensitiveDataCodec> serviceLoader = ServiceLoader.load(SensitiveDataCodec.class, PasswordMaskingUtil.class.getClassLoader()); Iterator<SensitiveDataCodec> serviceLoaderIterator = serviceLoader.iterator(); try { if (serviceLoaderIterator.hasNext()) { return serviceLoaderIterator.next().getClass().newInstance(); } return (SensitiveDataCodec<String>) PasswordMaskingUtil.class.getClassLoader().loadClass(codecClassName).newInstance(); } catch (Exception e) { try { return (SensitiveDataCodec<String>) PasswordMaskingUtil.class.getClassLoader().loadClass(codecClassName).newInstance(); } catch (Exception e2) { try { return (SensitiveDataCodec<String>) Thread.currentThread().getContextClassLoader().loadClass(codecClassName).newInstance(); } catch (Exception e3) { throw ActiveMQUtilBundle.BUNDLE.errorCreatingCodec(e2, codecClassName); } } } }); if (parts.length > 1) { Map<String, String> props = new HashMap<>(); for (int i = 1; i < parts.length; i++) { String[] keyVal = parts[i].split("="); if (keyVal.length != 2) throw ActiveMQUtilBundle.BUNDLE.invalidProperty(parts[i]); props.put(keyVal[0], keyVal[1]); } try { codecInstance.init(props); } catch (Exception e) { throw new ActiveMQException("Fail to init codec", e, ActiveMQExceptionType.SECURITY_EXCEPTION); } } return codecInstance; }</code><technical_language>a nice feature.. tests</technical_language>

Target:
public static SensitiveDataCodec<String> getCodec(String codecDesc) throws ActiveMQException { SensitiveDataCodec<String> codecInstance; String[] parts = codecDesc.split(";"); if (parts.length < 1) throw new ActiveMQException(ActiveMQExceptionType.ILLEGAL_STATE, "Invalid PasswordCodec value: " + codecDesc); final String codecClassName = parts[0]; codecInstance = AccessController.doPrivileged((PrivilegedAction<SensitiveDataCodec<String>>) () -> { ServiceLoader<SensitiveDataCodec> serviceLoader = ServiceLoader.load(SensitiveDataCodec.class, PasswordMaskingUtil.class.getClassLoader()); try { for (SensitiveDataCodec<String> codec : serviceLoader) { if ((codec.getClass().getCanonicalName()).equals(codecClassName)) { return codec.getClass().newInstance(); } } } catch (Exception e) { } try { return (SensitiveDataCodec<String>) PasswordMaskingUtil.class.getClassLoader().loadClass(codecClassName).newInstance(); } catch (Exception e) { try { return (SensitiveDataCodec<String>) Thread.currentThread().getContextClassLoader().loadClass(codecClassName).newInstance(); } catch (Exception e2) { throw ActiveMQUtilBundle.BUNDLE.errorCreatingCodec(e2, codecClassName); } } }); if (parts.length > 1) { Map<String, String> props = new HashMap<>(); for (int i = 1; i < parts.length; i++) { String[] keyVal = parts[i].split("="); if (keyVal.length != 2) throw ActiveMQUtilBundle.BUNDLE.invalidProperty(parts[i]); props.put(keyVal[0], keyVal[1]); } try { codecInstance.init(props); } catch (Exception e) { throw new ActiveMQException("Fail to init codec", e, ActiveMQExceptionType.SECURITY_EXCEPTION); } } return codecInstance; }