/** * This method is guaranteed to not throw any exception. If writer is already * closed then does nothing.<br> * Any buffered data is flushed by this method. */ @Override public void close() { JOrphanUtils.closeQuietly(writer); this.writer = null; }
/** * {@inheritDoc} */ @Override public void close() { JOrphanUtils.closeQuietly(OUTPUT); }
@Override public void close() { JOrphanUtils.closeQuietly(isr); JOrphanUtils.closeQuietly(fis); JOrphanUtils.closeQuietly(reader); } }
@Override public void threadFinished() { if(channel != null) { try { channel.close(); } catch(IOException iex) { log.debug("Error closing channel",iex); } } channel = null; JOrphanUtils.closeQuietly(body); body = null; stringBody = null; }
/** * */ private void closeThreadLocalConnections() { // Does not need to be synchronised, as all access is from same thread Map<HttpClientKey, Pair<CloseableHttpClient, PoolingHttpClientConnectionManager>> mapHttpClientPerHttpClientKey = HTTPCLIENTS_CACHE_PER_THREAD_AND_HTTPCLIENTKEY.get(); if ( mapHttpClientPerHttpClientKey != null ) { for ( Pair<CloseableHttpClient, PoolingHttpClientConnectionManager> pair : mapHttpClientPerHttpClientKey.values() ) { JOrphanUtils.closeQuietly(pair.getLeft()); JOrphanUtils.closeQuietly(pair.getRight()); } mapHttpClientPerHttpClientKey.clear(); } }
/** * Set the new writer on which samples will be written by this sample writer.<br> * If any writer exists on the sample writer, it is flushed and closed before * being replaced by the new one. * * @param newWriter * The destination writer where samples will be written by this * sample writer */ public void setWriter(Writer newWriter) { Validate.notNull(newWriter, "writer must not be null."); // NOSONAR if (this.writer != null) { // flush and close previous writer JOrphanUtils.closeQuietly(this.writer); } this.writer = new PrintWriter(new BufferedWriter(newWriter, BUF_SIZE), false); }
if(!noException) { JOrphanUtils.closeQuietly(in); } else { in.close();
@Override public void destroyObject(SocketConnectionInfos socketConnectionInfos, PooledObject<SocketOutputStream> socketOutputStream) throws Exception { super.destroyObject(socketConnectionInfos, socketOutputStream); SocketOutputStream outputStream = socketOutputStream.getObject(); JOrphanUtils.closeQuietly(outputStream); JOrphanUtils.closeQuietly(outputStream.getSocket()); }
JOrphanUtils.closeQuietly(is);
JOrphanUtils.closeQuietly(is);
log.warn("HTTP(S) Test Script Recorder stopped", e); } finally { JOrphanUtils.closeQuietly(mainSocket);
this.reader = new BufferedReader(isr, BUF_SIZE); } catch (FileNotFoundException | UnsupportedEncodingException ex) { JOrphanUtils.closeQuietly(isr); JOrphanUtils.closeQuietly(fis); JOrphanUtils.closeQuietly(this.reader); throw new SampleException("Could not create file reader !", ex);
@Override public void actionPerformed(ActionEvent ev) { if (ev.getSource() == saveTable) { JFileChooser chooser = FileDialoger .promptToSaveFile("synthesis.csv"); if (chooser == null) { return; } FileWriter writer = null; try { writer = new FileWriter(chooser.getSelectedFile()); // TODO // Charset ? CSVSaveService.saveCSVStats(getAllDataAsTable(model, FORMATS, getLabels(COLUMNS)), writer, saveHeaders.isSelected()); } catch (IOException e) { log.warn(e.getMessage()); } finally { JOrphanUtils.closeQuietly(writer); } } }
@Override public void actionPerformed(ActionEvent ev) { if (ev.getSource() == saveTable) { JFileChooser chooser = FileDialoger .promptToSaveFile("synthesis.csv"); if (chooser == null) { return; } FileWriter writer = null; try { writer = new FileWriter(chooser.getSelectedFile()); // TODO // Charset ? CSVSaveService.saveCSVStats(getAllTableData(model, FORMATS), writer, saveHeaders.isSelected() ? getLabels(COLUMNS) : null); } catch (FileNotFoundException e) { log.warn(e.getMessage()); } catch (IOException e) { log.warn(e.getMessage()); } finally { JOrphanUtils.closeQuietly(writer); } } }
JOrphanUtils.closeQuietly(clientSocket); threadPoolExecutor.shutdownNow(); JOrphanUtils.closeQuietly(mainSocket);
/** * Use Batik to save a PNG of the graph * * @param filename * name of the file to store the image into * @param image * to be stored */ public void savePNGWithBatik(String filename, BufferedImage image) { File outfile = new File(filename); OutputStream fos = createFile(outfile); if (fos == null) { return; } PNGEncodeParam param = PNGEncodeParam.getDefaultEncodeParam(image); PNGImageEncoder encoder = new PNGImageEncoder(fos, param); try { encoder.encode(image); } catch (IOException e) { JMeterUtils.reportErrorToUser("PNGImageEncoder reported: "+e.getMessage(), "Problem creating image file"); } finally { JOrphanUtils.closeQuietly(fos); } }
/** * Use Batik to save a TIFF file of the graph * * @param filename * name of the file to store the image into * @param image * to be stored */ public void saveTIFFWithBatik(String filename, BufferedImage image) { File outfile = new File(filename); OutputStream fos = createFile(outfile); if (fos == null) { return; } TIFFEncodeParam param = new TIFFEncodeParam(); TIFFImageEncoder encoder = new TIFFImageEncoder(fos, param); try { encoder.encode(image); } catch (IOException e) { JMeterUtils.reportErrorToUser("TIFFImageEncoder reported: "+e.getMessage(), "Problem creating image file"); } catch (Error e) { // NOSONAR TIFFImageEncoder uses Error to report runtime problems JMeterUtils.reportErrorToUser("TIFFImageEncoder reported: "+e.getMessage(), "Problem creating image file"); if (e.getClass() != Error.class){// NOSONAR rethrow other errors throw e; } } finally { JOrphanUtils.closeQuietly(fos); } }
cl = (int)input.length(); if(body != null) { JOrphanUtils.closeQuietly(body); body = null;
@Override protected HTTPSampleResult sample(URL url, String method, boolean frd, int fd) { HTTPSampleResult res = new HTTPSampleResult(); res.setSampleLabel(url.toExternalForm()); res.sampleStart(); try { setupConnection(url, method, res); activeChannel = channel; execute(method, res); res.sampleEnd(); res.setResponseData(responseData.toByteArray()); return res; } catch(IOException iex) { res.sampleEnd(); lastPort = -1; // force reopen on next sample channel = null; return errorResult(iex, res); } finally { activeChannel = null; JOrphanUtils.closeQuietly(body); body = null; } }
return res; } finally { JOrphanUtils.closeQuietly(instream); if (httpMethod != null) { httpMethod.releaseConnection();