BlackListFileLoader { static List<String> loadFile(String path) { List<String> blackPrefixList = new ArrayList<String>(); InputStream input = null; try { input = BlackListFileLoader.class.getResourceAsStream(path); if (input != null) { readToList(input, "UTF-8", blackPrefixList); } String overStr = SofaConfigs.getStringValue(SofaOptions.CONFIG_SERIALIZE_BLACKLIST_OVERRIDE, ""); if (StringUtils.isNotBlank(overStr)) { if (LOGGER.isInfoEnabled()) { LOGGER.info("Serialize blacklist will override with configuration: {}", overStr); } overrideBlackList(blackPrefixList, overStr); } } catch (Exception e) { if (LOGGER.isErrorEnabled()) { LOGGER.error(e.getMessage(), e); } } finally { closeQuietly(input); } return blackPrefixList; }   static final List<String> SOFA_SERIALIZE_BLACK_LIST; }
@Test public void testAll() throws Exception { List<String> blacks = BlackListFileLoader.SOFA_SERIALIZE_BLACK_LIST; Assert.assertNotNull(blacks); String s = System.getProperty(SofaOptions.CONFIG_SERIALIZE_BLACKLIST_OVERRIDE); try { System.setProperty(SofaOptions.CONFIG_SERIALIZE_BLACKLIST_OVERRIDE, "-java.net.Socket"); blacks = BlackListFileLoader.loadFile("/sofa-rpc/serialize_blacklist.txt"); } finally { if (s != null) { System.setProperty(SofaOptions.CONFIG_SERIALIZE_BLACKLIST_OVERRIDE, s); } } NameBlackListFilter filter = new NameBlackListFilter(blacks); boolean pass = true; String className = null; try { className = filter.resolve("com.alipay.xx"); } catch (Exception e) { pass = false; } Assert.assertNotNull(className); Assert.assertTrue(pass); pass = true; try { className = filter.resolve("com.sun.rowset.JdbcRowSetImpl"); } catch (Exception e) { pass = false; } Assert.assertFalse(pass); }