/** * Attempts to read a policy from a given InputStream and logs any errors. * * @param sourceName names the source of the input stream for log messages. * @return the policy or null if unavailable. */ private static SerializationPolicy readPolicy(InputStream in, String sourceName, Logger logger) { try { List<ClassNotFoundException> errs = new ArrayList<ClassNotFoundException>(); SerializationPolicy policy = SerializationPolicyLoader.loadFromStream(in, errs); logger.logInfo("Downloaded serialization policy from " + sourceName); if (!errs.isEmpty()) { logMissingClasses(logger, errs); } return policy; } catch (ParseException e) { logger.logError("Can't parse serialization policy from " + sourceName, e); return null; } catch (IOException e) { logger.logError("Can't read serialization policy from " + sourceName, e); return null; } finally { try { in.close(); } catch (IOException e) { logger.logError("Can't close serialization policy url: " + sourceName, e); } } }
/** * Attempts to read a policy from a given InputStream and logs any errors. * * @param sourceName names the source of the input stream for log messages. * @return the policy or null if unavailable. */ private static SerializationPolicy readPolicy(InputStream in, String sourceName, Logger logger) { try { List<ClassNotFoundException> errs = new ArrayList<ClassNotFoundException>(); SerializationPolicy policy = SerializationPolicyLoader.loadFromStream(in, errs); logger.logInfo("Downloaded serialization policy from " + sourceName); if (!errs.isEmpty()) { logMissingClasses(logger, errs); } return policy; } catch (ParseException e) { logger.logError("Can't parse serialization policy from " + sourceName, e); return null; } catch (IOException e) { logger.logError("Can't read serialization policy from " + sourceName, e); return null; } finally { try { in.close(); } catch (IOException e) { logger.logError("Can't close serialization policy url: " + sourceName, e); } } }
/** * Attempts to read a policy from a given InputStream and logs any errors. * * @param sourceName names the source of the input stream for log messages. * @return the policy or null if unavailable. */ private static SerializationPolicy readPolicy(InputStream in, String sourceName, Logger logger) { try { List<ClassNotFoundException> errs = new ArrayList<ClassNotFoundException>(); SerializationPolicy policy = SerializationPolicyLoader.loadFromStream(in, errs); logger.logInfo("Downloaded serialization policy from " + sourceName); if (!errs.isEmpty()) { logMissingClasses(logger, errs); } return policy; } catch (ParseException e) { logger.logError("Can't parse serialization policy from " + sourceName, e); return null; } catch (IOException e) { logger.logError("Can't read serialization policy from " + sourceName, e); return null; } finally { try { in.close(); } catch (IOException e) { logger.logError("Can't close serialization policy url: " + sourceName, e); } } }