/** * Unmarshal all the elements to their field values if the fields have the {@link Auto} annotation * defined. * * @param reader - The reader where the elements can be read. * @param o - The object for which the value of fields need to be populated. */ private static void autoUnmarshalEligible(HierarchicalStreamReader reader, Object o) { try { String nodeName = reader.getNodeName(); Class c = o.getClass(); Field f = null; try { f = c.getDeclaredField(nodeName); } catch (NoSuchFieldException e) { UNMARSHALL_ERROR_COUNTER.increment(); } if (f == null) { return; } Annotation annotation = f.getAnnotation(Auto.class); if (annotation == null) { return; } f.setAccessible(true); String value = reader.getValue(); Class returnClass = f.getType(); if (value != null) { if (!String.class.equals(returnClass)) { Method method = returnClass.getDeclaredMethod("valueOf", java.lang.String.class); Object valueObject = method.invoke(returnClass, value); f.set(o, valueObject); } else { f.set(o, value); } } } catch (Throwable th) { logger.error("Error in unmarshalling the object:", th); } }
@Override public void run() { Stopwatch start = executionTimeStats.start(); try { HttpClientConnectionManager cm = (HttpClientConnectionManager) apacheHttpClient .getConfiguration() .getProperty(ApacheClientProperties.CONNECTION_MANAGER); cm.closeIdleConnections(connectionIdleTimeout, TimeUnit.SECONDS); } catch (Throwable e) { s_logger.error("Cannot clean connections", e); cleanupFailed.increment(); } finally { if (null != start) { start.stop(); } } }