@Override public Object fromString(String str) { byte[] objBytes = Base64.getDecoder().decode(str); try { ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(objBytes)); return ois.readObject(); } catch (IOException | ClassNotFoundException e) { log.error("Error while decoding object", e); throw new CacheException(e); } }
private String obtainEffectiveCacheName() { if (StringUtils.hasText(this.cacheName)) { if (this.logger.isDebugEnabled()) { this.logger.debug("Using custom cache name [" + this.cacheName + "]"); } return this.cacheName; } else { if (this.logger.isDebugEnabled()) { this.logger.debug("Using bean name [" + this.beanName + "] as cache name"); } return this.beanName; } }
private static <T> void addServices(ServiceLoader<T> loadedServices, Map<String, T> services) { Iterator<T> i = loadedServices.iterator(); while (i.hasNext()) { try { T service = i.next(); if (services.putIfAbsent(service.getClass().getName(), service) == null) { LOG.debugf("Loading service impl: %s", service.getClass().getName()); } else { LOG.debugf("Ignoring already loaded service: %s", service.getClass().getName()); } } catch (ServiceConfigurationError e) { LOG.debugf("Skipping service impl", e); } } }
private static void warnLegacy(String oldKey, String newKey) { if (log.isInfoEnabled()) log.infof("Could not find value for key %1$s, but did find value under deprecated key %2$s. Please use %1$s as support for %2$s will eventually be discontinued.", newKey, oldKey); }
public boolean isSafeClass(String className) { // Test for classes first (faster) boolean isClassAllowed = classes.contains(className); if (isClassAllowed) return true; boolean regexMatch = compiled.stream().anyMatch(p -> p.matcher(className).find()); if (regexMatch) return true; if (log.isTraceEnabled()) log.tracef("Class '%s' not in whitelist", className); return false; }
@Test(expected = IllegalArgumentException.class) public void testInvalidGlobalTransaction() { long seed = System.currentTimeMillis(); log.infof("[testInvalidGlobalTransaction] seed: %s", seed); Random random = new Random(seed); Xid xid = XidImpl.create(random.nextInt(), Util.EMPTY_BYTE_ARRAY, new byte[]{0}); log.debugf("Invalid XID: %s", xid); }
@Override public int nextSize(Object obj) { if (isTrace) log.tracef("Next predicted buffer size for object type '%s' will be %d", obj == null ? "Null" : obj.getClass().getName(), nextBufferSize); return nextBufferSize; }
classes.add(claz); } catch (NoClassDefFoundError ncdfe) { log.warnf("%s has reference to a class %s that could not be loaded from classpath", cf.getAbsolutePath(), ncdfe.getMessage()); } catch (Throwable e) { log.warn("On path " + cf.getAbsolutePath() + " could not load class "+ clazz, e); jar = new JarFile(path); } catch (Exception ex) { log.warnf("Could not create jar file on path %s", path); return classes; classes.add(claz); } catch (NoClassDefFoundError ncdfe) { log.warnf("%s has reference to a class %s that could not be loaded from classpath", entry.getName(), ncdfe.getMessage()); } catch (Throwable e) { log.warn("From jar path " + entry.getName() + " could not load class "+ clazz, e); jar.close(); } catch (IOException e) { log.debugf(e, "error closing jar file %s", jar);
/** * Register the given dynamic JMX MBean. * * @param mbean Dynamic MBean to register * @param objectName {@link ObjectName} under which to register the MBean. * @param mBeanServer {@link MBeanServer} where to store the MBean. * @throws Exception If registration could not be completed. */ public static void registerMBean(Object mbean, ObjectName objectName, MBeanServer mBeanServer) throws Exception { if (!mBeanServer.isRegistered(objectName)) { try { SecurityActions.registerMBean(mbean, objectName, mBeanServer); log.tracef("Registered %s under %s", mbean, objectName); } catch (InstanceAlreadyExistsException e) { //this might happen if multiple instances are trying to concurrently register same objectName log.couldNotRegisterObjectName(objectName, e); } } else { log.debugf("Object name %s already registered", objectName); } }
/** * @see InitializingBean#afterPropertiesSet() */ @Override public void afterPropertiesSet() throws Exception { if (this.infinispanCacheContainer == null) { throw new IllegalStateException("No Infinispan CacheContainer has been set"); } this.logger.info("Initializing named Infinispan cache ..."); this.infinispanCache = this.infinispanCacheContainer.getCache(); this.logger.info("New Infinispan cache [" + this.infinispanCache + "] initialized"); }
public boolean enlistResource(XAResource resource) throws RollbackException, IllegalStateException, SystemException { if (trace) { log.tracef("Transaction.enlistResource(%s) invoked in transaction with Xid=%s", resource, xid); try { if (otherResourceEntry.getKey().isSameRM(resource)) { log.debug("Ignoring resource. It is already there."); return true; log.tracef("XaResource.start() invoked in transaction with Xid=%s", xid); format("Resource %s rolled back the transaction while XaResource.start()", resource), e); markRollbackOnly(exception); log.errorEnlistingResource(e); throw exception; log.errorEnlistingResource(e); throw new SystemException(e.getMessage());
/** * Looks up the file, see : {@link DefaultFileLookup}. * * @param filename might be the name of the file (too look it up in the class path) or an url to a file. * @return an input stream to the file or null if nothing found through all lookup steps. * @throws FileNotFoundException if file cannot be found */ @Override public InputStream lookupFileStrict(String filename, ClassLoader cl) throws FileNotFoundException { InputStream is = filename == null || filename.length() == 0 ? null : getAsInputStreamFromClassLoader(filename, cl); if (is == null) { if (log.isDebugEnabled()) log.debugf("Unable to find file %s in classpath; searching for this file on the filesystem instead.", filename); return new FileInputStream(filename); } return is; }
@Override final public void finishObjectOutput(final ObjectOutput oo) { try { if (trace) log.trace("Stop marshaller"); ((org.jboss.marshalling.Marshaller) oo).finish(); } catch (IOException ignored) { } }
public void rollback() throws IllegalStateException, SystemException { if (trace) { log.tracef("Transaction.rollback() invoked in transaction with Xid=%s", xid); runCommit(false); } catch (HeuristicMixedException | HeuristicRollbackException e) { log.errorRollingBack(e); SystemException systemException = new SystemException("Unable to rollback transaction"); systemException.initCause(e); log.trace("RollbackException thrown while rolling back", e);
public boolean runPrepare() { if (trace) { log.tracef("runPrepare() invoked in transaction with Xid=%s", xid); log.tracef("XaResource.prepare() for %s", res); } catch (XAException e) { if (trace) { log.trace("The resource wants to rollback!", e); markRollbackOnly(newRollbackException( format("Unexpected error in XaResource.prepare() for %s. Rollback transaction.", res), th)); log.unexpectedErrorFromResourceManager(th); return false;
@Override public Void apply(EntryView.ReadWriteEntryView<Object, Object> view) { if (trace) { log.tracef("Applying %s to %s", this, view.find().orElse(null)); versionComparator = region.getComparator(subclass); if (versionComparator == null) { log.errorf("Cannot find comparator for %s", subclass); int compareResult = versionComparator.compare(version, oldVersion); if (trace) { log.tracef("Comparing %s and %s -> %d (using %s)", version, oldVersion, compareResult, versionComparator);
private void notifyAfterCompletion(int status) { for (Synchronization s : getEnlistedSynchronization()) { if (trace) { log.tracef("Synchronization.afterCompletion() for %s", s); } try { s.afterCompletion(status); } catch (Throwable t) { log.afterCompletionFailed(s.toString(), t); } } syncs.clear(); }
private void notifyBeforeCompletion() { for (Synchronization s : getEnlistedSynchronization()) { if (trace) { log.tracef("Synchronization.beforeCompletion() for %s", s); } try { s.beforeCompletion(); } catch (Throwable t) { markRollbackOnly( newRollbackException(format("Synchronization.beforeCompletion() for %s wants to rollback.", s), t)); log.beforeCompletionFailed(s.toString(), t); } } }