/** * Validates if it can create temporary files. Otherwise, it stores * attachment contents in memory. */ public void validate() { if (!isOnlyMemory()) { try { File tempFile = (tempDir == null) ? File.createTempFile(prefix, suffix) : File.createTempFile(prefix, suffix, tempDir); tempFile.delete(); } catch(Exception ioe) { memoryThreshold = -1L; // whole attachment will be in-memory } } }
/** * Validates if it can create temporary files. Otherwise, it stores * attachment contents in memory. */ public void validate() { if (!isOnlyMemory()) { try { File tempFile = (tempDir == null) ? File.createTempFile(prefix, suffix) : File.createTempFile(prefix, suffix, tempDir); boolean deleted = tempFile.delete(); if (!deleted) { if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, "File {0} was not deleted", tempFile.getAbsolutePath()); } } } catch(RuntimeException e) { memoryThreshold = -1L; // whole attachment will be in-memory } catch(Exception e) { memoryThreshold = -1L; // whole attachment will be in-memory } } }
/** * Validates if it can create temporary files. Otherwise, it stores * attachment contents in memory. */ public void validate() { if (!isOnlyMemory()) { try { File tempFile = (tempDir == null) ? File.createTempFile(prefix, suffix) : File.createTempFile(prefix, suffix, tempDir); boolean deleted = tempFile.delete(); if (!deleted) { if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, "File {0} was not deleted", tempFile.getAbsolutePath()); } } } catch(RuntimeException e) { memoryThreshold = -1L; // whole attachment will be in-memory } catch(Exception e) { memoryThreshold = -1L; // whole attachment will be in-memory } } }
/** * Validates if it can create temporary files. Otherwise, it stores * attachment contents in memory. */ public void validate() { if (!isOnlyMemory()) { try { File tempFile = (tempDir == null) ? File.createTempFile(prefix, suffix) : File.createTempFile(prefix, suffix, tempDir); boolean deleted = tempFile.delete(); if (!deleted) { if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, "File {0} was not deleted", tempFile.getAbsolutePath()); } } } catch(RuntimeException e) { memoryThreshold = -1L; // whole attachment will be in-memory } catch(Exception e) { memoryThreshold = -1L; // whole attachment will be in-memory } } }
if (!config.isOnlyMemory() && dataHead.inMemory >= config.memoryThreshold) { try { String prefix = config.getTempFilePrefix();
if (!config.isOnlyMemory() && dataHead.inMemory >= config.memoryThreshold) { try { String prefix = config.getTempFilePrefix();
if (!config.isOnlyMemory() && dataHead.inMemory >= config.memoryThreshold) { try { String prefix = config.getTempFilePrefix();
if (!config.isOnlyMemory() && dataHead.inMemory >= config.memoryThreshold) { try { String prefix = config.getTempFilePrefix();