Tabnine Logo
IOUtil.shutdownStream
Code IndexAdd Tabnine to your IDE (free)

How to use
shutdownStream
method
in
com.atlassian.jira.util.IOUtil

Best Java code snippets using com.atlassian.jira.util.IOUtil.shutdownStream (Showing top 8 results out of 315)

origin: com.atlassian.jira/jira-core

  /**
   * This must be called to release the lock
   */
  void release()
  {
    IOUtil.shutdownStream(fileOutputStream);
    if (lockFile != null) {
      //noinspection ResultOfMethodCallIgnored
      lockFile.delete();
    }
    fileOutputStream = null;
    lockFile = null;
  }
}
origin: com.atlassian.jira/jira-core

private boolean writeZipResponse(final HttpServletResponse httpServletResponse, final InputStream inputStream)
    throws IOException
{
  boolean bytesWritten = false;
  OutputStream out = httpServletResponse.getOutputStream();
  byte[] buffer = new byte[4096];
  try
  {
    while (true)
    {
      int bytesRead = inputStream.read(buffer);
      if (bytesRead == -1)
      {
        break;
      }
      out.write(buffer, 0, bytesRead);
      bytesWritten = true;
    }
  }
  finally
  {
    IOUtil.shutdownStream(inputStream);
    IOUtil.shutdownStream(out);
  }
  return bytesWritten;
}
origin: com.atlassian.jira/jira-core

private Properties loadPropertiesFromLegacyFile(InputStream propertiesStream)
{
  Properties props = new Properties();
  if (propertiesStream != null)
  {
    try
    {
      props.load(propertiesStream);
      IOUtil.shutdownStream(propertiesStream);
    }
    catch (final IOException e)
    {
      log.warn("Failed to migrate custom default properties from '" + LEGACY_PROPERTIES_FILE + "' file. Please check the new admin configuration options added in " + "JIRA 4.4 to ensure your configuration is correct.");
    }
  }
  else
  {
    log.debug("No " + LEGACY_PROPERTIES_FILE + " file found to migrate, doing nothing.");
  }
  return props;
}
origin: com.atlassian.jira/jira-configurator

  @Nonnull
  @Override
  public KeyStore load(@Nonnull final CertificateDetails certificateDetails) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException
  {
    final String fileName = certificateDetails.getKeyStoreLocation();
    final String password = certificateDetails.getKeyStorePassword();
    final KeyStore keyStore = KeyStore.getInstance("JKS");
    final FileInputStream fileInputStream = new FileInputStream(fileName);
    try
    {
      keyStore.load(fileInputStream, password.length() == 0 ? null : password.toCharArray());
    }
    finally
    {
      IOUtil.shutdownStream(fileInputStream);
    }
    return keyStore;
  }
}
origin: com.atlassian.jira/jira-core

private void streamZipEntry(final ZipArchiveInputStream zipArchiveInputStream, final ZipArchiveEntry zipEntry)
    throws IOException
{
  BufferedInputStream bufferedZipEntryInputStream = null;
  try
  {
    onZipEntryExists.consume(zipEntry);
    bufferedZipEntryInputStream = new BufferedInputStream(zipArchiveInputStream);
    IOUtil.copy(bufferedZipEntryInputStream, outputStream);
  }
  finally
  {
    IOUtil.shutdownStream(bufferedZipEntryInputStream);
  }
}
origin: com.atlassian.jira/jira-core

/**
 * This will return a ZIP file that contains all the attachments of an issue.  The file will be created in the
 * temporary directory and end in .zip
 * <p/>
 * you should delete the file when you are done, otherwise, well this is JIRA not Bamboo!
 *
 * @return a zip file containing all the attachments of an issue
 * @throws IOException if stuff goes wrong
 */
public File toZipFile(final Issue issue) throws IOException
{
  final File zipFile = File.createTempFile(issue.getKey() + "-", ".zip");
  final UniqueFileNameGenerator uniqueFileNameGenerator = new UniqueFileNameGenerator();
  ZipArchiveOutputStream out = null;
  try
  {
    out = new ZipArchiveOutputStream(new FileOutputStream(zipFile));
    copyAttachmentsToZipFile(issue, uniqueFileNameGenerator, out);
  }
  finally
  {
    IOUtil.shutdownStream(out);
  }
  return zipFile;
}
origin: com.atlassian.jira/jira-core

/**
 * Sets the appropriate HTTP response headers on an attachment download response. Depending on the JIRA security
 * settings and the browser making the request, this can contain headers such as {@code Content-Disposition} and
 * {@code X-Download-Options} to force downloading rather than opening attachments.
 *
 * @param attachment the Attachment in play
 * @param userAgent    the User-agent request header
 * @param httpServletResponse the attachment download response
 * @throws IOException if stuff goes wrong
 */
public void setAttachmentResponseHeaders(final Attachment attachment, final String userAgent,
    final HttpServletResponse httpServletResponse) throws IOException
{
  String filename = attachment.getFilename();
  BufferedInputStream inputStream = null;
  try
  {
    OpenAttachmentStrategy strategy = getOpenAttachmentStrategy(filename, attachment.getMimetype());
    strategy.setResponseHeaders(httpServletResponse);
  }
  finally
  {
    if (inputStream != null)
    {
      IOUtil.shutdownStream(inputStream);
    }
  }
}
origin: com.atlassian.jira.plugins/atlassian-jira-rpc-plugin

final Avatar toCreate = AvatarImpl.createCustomAvatar(AVATAR_DEFAULT_BASE_FILENAME, contentType, project);
Avatar createdAvatar = avatarManager.create(toCreate, bais, AvatarManager.ImageSize.LARGE.getOriginSelection());
IOUtil.shutdownStream(bais);
final Long avatarId = createdAvatar.getId();
final com.atlassian.jira.bc.project.ProjectService.UpdateProjectValidationResult result = validateSetAvatar(user, project, avatarId);
com.atlassian.jira.utilIOUtilshutdownStream

Javadoc

Unconditionally close an InputStream. Equivalent to InputStream#close(), except any exceptions will be ignored.

Popular methods of IOUtil

  • toString
    Get the contents of a byte[] as a String.
  • copy
    Copy and convert bytes from a byte[] to chars on aWriter, using the specified encoding.
  • shutdownReader
    Unconditionally close an Reader. Equivalent to Reader#close(), except any exceptions will be ignored
  • shutdownWriter
    Unconditionally close an Writer. Equivalent to Writer#close(), except any exceptions will be ignored
  • toByteArray
    Get the contents of a String as a byte[].

Popular in Java

  • Parsing JSON documents to java classes using gson
  • startActivity (Activity)
  • requestLocationUpdates (LocationManager)
  • getSupportFragmentManager (FragmentActivity)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now