You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2014/04/04 20:19:44 UTC
svn commit: r1584859 -
/db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneSupport.java
Author: rhillegas
Date: Fri Apr 4 18:19:44 2014
New Revision: 1584859
URL: http://svn.apache.org/r1584859
Log:
DERBY-590: Eliminate some file-closure race conditions by explicitly closing the stream from which index properties are read; commit derby-590-17-aa-closeInputStreamOnPropertiesFile.diff.
Modified:
db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneSupport.java
Modified: db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneSupport.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneSupport.java?rev=1584859&r1=1584858&r2=1584859&view=diff
==============================================================================
--- db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneSupport.java (original)
+++ db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneSupport.java Fri Apr 4 18:19:44 2014
@@ -1095,8 +1095,10 @@ public class LuceneSupport implements Op
else
{
Properties properties = new Properties();
+ FileInputStream fis = new FileInputStream( file );
- properties.load( new FileInputStream( file ) );
+ properties.load( fis );
+ fis.close();
return properties;
}
@@ -1516,9 +1518,11 @@ public class LuceneSupport implements Op
* and files underneath it first.
*/
static boolean deleteFile( File file )
- throws IOException, PrivilegedActionException
+ throws IOException, SQLException, PrivilegedActionException
{
boolean retval = true;
+
+ if ( !fileExists( file ) ) { return false; }
if ( isDirectory( file ) )
{
@@ -1547,15 +1551,22 @@ public class LuceneSupport implements Op
/** Really delete a file */
private static boolean clobberFile( final File file )
- throws IOException, PrivilegedActionException
+ throws IOException, SQLException, PrivilegedActionException
{
return AccessController.doPrivileged
(
new PrivilegedExceptionAction<Boolean>()
{
- public Boolean run() throws IOException
+ public Boolean run() throws IOException, SQLException
{
- return file.delete();
+ boolean result = file.delete();
+
+ if ( !result )
+ {
+ throw newSQLException( SQLState.UNABLE_TO_DELETE_FILE, file.getAbsolutePath() );
+ }
+
+ return result;
}
}
).booleanValue();