public InputStreamWrapper(InputStream delegate) { super(); Lang.denyNull("delegate", delegate); this.delegate = delegate; }
/** * Initializes the JDK logger and loads the configuration file from the specified stream. * * @throws Exception * Thrown on any error. */ private void initializeJUL(InputStream logConfig) throws Exception { Lang.denyNull("log configuration stream", logConfig); try { LogManager.getLogManager() .readConfiguration(logConfig); } catch (Exception e) { throw e; } finally { Lang.closeQuietly(logConfig); } }
@Override public Void run() { StackTraceElement[] stackTraceElements = Thread.getAllStackTraces() .get(Thread.currentThread()); String stackTraceAsString = Lang.stackTraceAsString(stackTraceElements); System.out.println("Logging stacktrace of the request:"); System.out.println(stackTraceAsString); return null; } });
@Override protected void destroyTarget(OutputStream target) { Lang.closeQuietly(target); }
/** * This method installs the stream handler to make streamed resources available through URLs in this JVM. */ public static void installURLStreamHandler() { String property = System.getProperty("java.protocol.handler.pkgs"); if (Lang.isEmpty(property)) { property = parentPackage(); } else { property = property + "|" + parentPackage(); } System.setProperty("java.protocol.handler.pkgs", property); }
try (FileInputStream fin = new FileInputStream(path.toFile()); ByteArrayOutputStream bout = new ByteArrayOutputStream()) { Lang.copy(fin, bout); byte[] byteArray = bout.toByteArray(); String logFile = new String(byteArray); } catch (Exception e) { textBox.addLine("Cannot read log file: " + path.toString()); String exceptionAsString = Lang.exceptionAsString(e); textBox.addLine("Cannot read log file: " + path.toString()); textBox.addLine(exceptionAsString); } catch (IOException e) { fileChooser.addItem("I/O error", () -> { String exceptionAsString = Lang.exceptionAsString(e); textBox.setText(exceptionAsString); });
@Override protected void performInitialize() throws Exception { super.performInitialize(); PublisherUtils.denyRequired("databaseUrl", databaseUrl); PublisherUtils.denyRequired("username", username); PublisherUtils.denyRequired("password", password); PublisherUtils.denyRequired("database", database); Lang.defaultIfNull(retentionPolicy, "default"); influxDB = InfluxDBFactory.connect(databaseUrl, username, password); influxDB.enableBatch(2000, 1000, TimeUnit.MILLISECONDS); influxDB.setLogLevel(LogLevel.NONE); }
private void closeAllRequestedStreamsOnDemand() { if (closeTrackedStreams()) { Iterator<WeakReference<InputStreamWrapper>> iterator = inputStreamList.iterator(); while (iterator.hasNext()) { WeakReference<InputStreamWrapper> reference = iterator.next(); InputStreamWrapper stream = reference.get(); Lang.closeQuietly(stream); stream = null; System.gc(); } } }
private void addJavaArchiveAsURL(List<URL> urls, JavaArchive a, String archiveName) throws IOException, MalformedURLException { byte[] resource = archiveToBytes(a); String jarURLStr = null; if (Lang.isEmpty(archiveName)) { jarURLStr = createJarURL(a); } else { jarURLStr = createJarURL(archiveName); } URL jarURL = new URL(jarURLStr);// , resourceHandler); urls.add(jarURL); addResourceToStagingHandler(resource, jarURL); }
public ThreadSensitiveRecorderStream(OutputStream delegate) { Lang.denyNull("delegate", delegate); this.delegate = delegate; this.recordSubscriber = new ConcurrentHashMap<ClassloaderThreadID, ByteArrayOutputStream>(); }
/** * Constructs a System Engine that reads the system descriptor from the specified input stream. * * @param descriptorInput * The input stream containing the XML system descriptor. * @throws SerializeException * Thrown if the Limbus System cannot be deserialized. */ public SystemEngine(InputStream descriptorInput) throws SerializeException { Lang.denyNull("descriptorInput", descriptorInput); try { this.system = fromInputStream(descriptorInput); } finally { Lang.closeQuietly(descriptorInput); } }
Lang.closeQuietly(inputStream);
@Override public final void stopEngine() { wasStopped = true; if (this.observer != null) { try { this.observer.interrupt(); this.observer.join(SHUTDOWN_TIMEOUT); } catch (InterruptedException e) { // Nothing to do } finally { if (this.observer.isAlive()) { StackTraceElement[] stackTrace = this.observer.getStackTrace(); String stackTraceStr = Lang.stackTraceAsString(stackTrace); log.warn("Engine observer thread could not be terminated:\n{}", stackTraceStr); } this.observer = null; } } }
@Override public boolean hasClasspath(String deployName) { Lang.denyNull("deployName", deployName); return deploynames.containsKey(deployName); }
static List<String> getClassNames(URL url) throws LimbusClasspathException { Lang.denyNull("URL", url); ZipInputStream inputStream = null; try { List<String> classNames = new ArrayList<String>(); URLConnection connection = url.openConnection(); inputStream = new ZipInputStream(connection.getInputStream()); for (ZipEntry entry = inputStream.getNextEntry(); entry != null; entry = inputStream.getNextEntry()) { if (!entry.isDirectory() && entry.getName() .endsWith(".class")) { // This ZipEntry represents a class. Now, what class does it represent? String className = entry.getName() .replace('/', '.'); // including ".class" classNames.add(className.substring(0, className.length() - ".class".length())); } inputStream.closeEntry(); } return classNames; } catch (Exception e) { throw new LimbusClasspathException("Cannot scan the contents of " + url.toString(), e); } finally { Lang.closeQuietly(inputStream); } }
try { String deployName = textBox.getText(); if (Lang.isEmpty(deployName)) { new MessageDialogBuilder().setTitle("Deploy from filesystem") .setText("Enter deployment folder name first!")
String stackTraceStr = Lang.stackTraceAsString(thread.getStackTrace()); log.warn("The thread '{}' was requested to terminate but did not respond.", thread.getName()); log.warn("Stacktrace of the thread '{}' in thread group '{}':\n{}", thread.getName(), thread.getThreadGroup()
public boolean containsKey(Object key) { Lang.denyNull("key", key); return properties.containsKey(key); }