Refine search
@SuppressWarnings({"unchecked", "rawtypes"}) private void doInvokeListener(ApplicationListener listener, ApplicationEvent event) { try { listener.onApplicationEvent(event); } catch (ClassCastException ex) { String msg = ex.getMessage(); if (msg == null || matchesClassCastMessage(msg, event.getClass())) { // Possibly a lambda-defined listener which we could not resolve the generic event type for // -> let's suppress the exception and just log a debug message. Log logger = LogFactory.getLog(getClass()); if (logger.isDebugEnabled()) { logger.debug("Non-matching event type for listener: " + listener, ex); } } else { throw ex; } } }
@Override public List<MetricDatum> toMetricData(MetricType metricType, Request<?> request, Response<?> response) { try { return toMetricData0(metricType, request, response); } catch (SecurityException e) { } catch (NoSuchMethodException e) { } catch (IllegalAccessException e) { } catch (InvocationTargetException e) { LogFactory.getLog(getClass()).debug("", e.getCause()); } catch (Exception e) { LogFactory.getLog(getClass()).debug("", e); } return null; }
private static Future<?> quietlyCallListener(final ProgressListener listener, final ProgressEvent event) { try { listener.progressChanged(event); } catch(Throwable t) { // That's right, we need to suppress all errors so as to be on par // with the async mode where all failures will be ignored. LogFactory.getLog(SDKProgressPublisher.class) .debug("Failure from the event listener", t); } return null; }
/** * Returns the root cause of the given throwable, or null if the given * throwable is null. If the root cause is over 1000 level deep, the * original throwable will be returned defensively as this is heuristically * considered a circular reference, however unlikely. */ public static Throwable getRootCause(Throwable orig) { if (orig == null) return orig; Throwable t = orig; // defend against (malicious?) circularity for (int i=0; i < 1000; i++) { Throwable cause = t.getCause(); if (cause == null) return t; t = cause; } // Too bad. Return the original exception. LogFactory.getLog(Throwables.class).debug( "Possible circular reference detected on " + orig.getClass() + ": [" + orig + "]"); return orig; }
public static synchronized void enableBouncyCastle() { if (isBouncyCastleAvailable()) { return; } try { @SuppressWarnings("unchecked") Class<Provider> c = (Class<Provider>)Class.forName(BC_PROVIDER_FQCN); Provider provider = c.newInstance(); Security.addProvider(provider); } catch (Exception e) { LogFactory.getLog(CryptoRuntime.class).debug( "Bouncy Castle not available", e); } }
private static Future<?> quietlyCallListener( final S3ProgressListener listener, final PersistableTransfer persistableTransfer) { try { listener.onPersistableTransfer(persistableTransfer); } catch(Throwable t) { // That's right, we need to suppress all errors so as to be on par // with the async mode where all failures will be ignored. LogFactory.getLog(S3ProgressPublisher.class) .debug("Failure from the event listener", t); } return null; } }
@Override public void addSubMeasurement(String subMeasurementName, TimingInfo ti) { List<TimingInfo> timings = subMeasurementsByName.get(subMeasurementName); if (timings == null) { timings = new ArrayList<TimingInfo>(); subMeasurementsByName.put(subMeasurementName, timings); } if (ti.isEndTimeKnown()) { timings.add(ti); } else { LogFactory.getLog(getClass()).debug( "Skip submeasurement timing info with no end time for " + subMeasurementName); } }
@SuppressWarnings({"unchecked", "rawtypes"}) private void doInvokeListener(ApplicationListener listener, ApplicationEvent event) { try { listener.onApplicationEvent(event); } catch (ClassCastException ex) { String msg = ex.getMessage(); if (msg == null || matchesClassCastMessage(msg, event.getClass())) { // Possibly a lambda-defined listener which we could not resolve the generic event type for // -> let's suppress the exception and just log a debug message. Log logger = LogFactory.getLog(getClass()); if (logger.isDebugEnabled()) { logger.debug("Non-matching event type for listener: " + listener, ex); } } else { throw ex; } } }
/** * @param fqcn fully qualified class name. */ private RequestMetricTransformer loadRequestMetricTransformer(String fqcn) { Log log = LogFactory.getLog(AWSMetricTransformerFactory.class); if (log.isDebugEnabled()) { log.debug("Loading " + fqcn); } try { Class<?> c = Class.forName(fqcn); return (RequestMetricTransformer)c.newInstance(); } catch (Throwable e) { if (log.isDebugEnabled()) { log.debug("Failed to load " + fqcn + "; therefore ignoring " + this.name() + " specific predefined metrics", e); } } return RequestMetricTransformer.NONE; }
/** * Computes the MD5 hash of the data in the given input stream and returns * it as an array of bytes. * Note this method closes the given input stream upon completion. */ public static byte[] computeMD5Hash(InputStream is) throws IOException { BufferedInputStream bis = new BufferedInputStream(is); try { MessageDigest messageDigest = MessageDigest.getInstance("MD5"); byte[] buffer = new byte[SIXTEEN_K]; int bytesRead; while ( (bytesRead = bis.read(buffer, 0, buffer.length)) != -1 ) { messageDigest.update(buffer, 0, bytesRead); } return messageDigest.digest(); } catch (NoSuchAlgorithmException e) { // should never get here throw new IllegalStateException(e); } finally { try { bis.close(); } catch (Exception e) { LogFactory.getLog(Md5Utils.class).debug( "Unable to close input stream of hash candidate: " + e); } } }
/** * Unregisters the MBean under the given object name to the first MBean * server, or the platform MBean server if there is no explicitly registered * MBean server. * * @return true if the unregistration succeeded, or false if the MBean * doesn't exist under the given object name. * @throws MBeanRegistrationException * Wraps exceptions thrown by the preRegister(), preDeregister() * methods of the MBeanRegistration interface. */ public static <T> boolean unregisterMBean(String objectName) throws MBeanRegistrationException { MBeanServer server = getMBeanServer(); try { server.unregisterMBean(new ObjectName(objectName)); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException(e); } catch (InstanceNotFoundException e) { LogFactory.getLog(MBeans.class).debug( "Failed to unregister mbean " + objectName, e); return false; } return true; }