[Mulgara-svn] r2093 - in trunk/src/jar: resolver/java/org/mulgara/resolver resolver-store/java/org/mulgara/store/statement/xa
pag at mulgara.org
pag at mulgara.org
Tue Jan 10 20:34:24 UTC 2012
Author: pag
Date: 2012-01-10 20:34:23 +0000 (Tue, 10 Jan 2012)
New Revision: 2093
Modified:
trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImpl.java
trunk/src/jar/resolver/java/org/mulgara/resolver/TransactionalAnswer.java
Log:
Restructured try/catch/finally to simplify the exception frames
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/TransactionalAnswer.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/TransactionalAnswer.java 2012-01-10 20:34:08 UTC (rev 2092)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/TransactionalAnswer.java 2012-01-10 20:34:23 UTC (rev 2093)
@@ -314,12 +314,13 @@
if (answer != null) {
report("Session forced close");
- Throwable error = null;
closing = true;
try {
answer.close();
+ } catch (TuplesException e) {
+ throw e;
} catch (Throwable th) {
- error = th;
+ throw new TuplesException("Error closing answer", th);
} finally {
try {
transaction.dereference();
@@ -330,13 +331,6 @@
answer = null;
transaction = null;
}
- if (error != null) {
- if (error instanceof TuplesException) {
- throw (TuplesException)error;
- } else {
- throw new TuplesException("Error closing answer", error);
- }
- }
}
// close();
}
Modified: trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImpl.java
===================================================================
--- trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImpl.java 2012-01-10 20:34:08 UTC (rev 2092)
+++ trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImpl.java 2012-01-10 20:34:23 UTC (rev 2093)
@@ -629,36 +629,39 @@
try {
unmap();
} finally {
- try {
- IOException savedEx = null;
-
- for (int i = 0; i < NR_INDEXES; ++i) {
- try {
- if (tripleAVLFiles[i] != null) {
- tripleAVLFiles[i].close();
- }
- } catch (IOException ex) {
- savedEx = ex;
+ IOException savedEx = null;
+ for (int i = 0; i < NR_INDEXES; ++i) {
+ try {
+ if (tripleAVLFiles[i] != null) {
+ tripleAVLFiles[i].close();
}
+ } catch (IOException ex) {
+ if (savedEx == null) savedEx = ex;
}
+ }
- if (metarootFile != null) {
- try {
- metarootFile.close();
- } catch (IOException ex) {
- savedEx = ex;
- }
+ if (metarootFile != null) {
+ try {
+ metarootFile.close();
+ } catch (IOException ex) {
+ if (savedEx == null) savedEx = ex;
}
+ }
- if (savedEx != null) {
- throw new StatementStoreException("I/O error closing graph.", savedEx);
- }
- } finally {
+ try {
if (lockFile != null) {
lockFile.release();
lockFile = null;
}
+ } catch (Exception e) {
+ // only unchecked exceptions may arrive here
+ // Existing I/O exceptions to take priority
+ if (savedEx == null) throw new StatementStoreException("Error releasing lock file", e);
}
+
+ if (savedEx != null) {
+ throw new StatementStoreException("I/O error closing graph.", savedEx);
+ }
}
}
@@ -674,38 +677,42 @@
try {
unmap();
} finally {
- try {
- IOException savedEx = null;
-
- for (int i = 0; i < NR_INDEXES; ++i) {
- try {
- if (tripleAVLFiles[i] != null) tripleAVLFiles[i].delete();
- } catch (IOException ex) {
- savedEx = ex;
- }
+ IOException savedEx = null;
+ for (int i = 0; i < NR_INDEXES; ++i) {
+ try {
+ if (tripleAVLFiles[i] != null) tripleAVLFiles[i].delete();
+ } catch (IOException ex) {
+ savedEx = ex;
}
+ }
- if (metarootFile != null) {
- try {
- metarootFile.delete();
- } catch (IOException ex) {
- savedEx = ex;
- }
+ if (metarootFile != null) {
+ try {
+ metarootFile.delete();
+ } catch (IOException ex) {
+ savedEx = ex;
}
+ }
- if (savedEx != null) {
- throw new StatementStoreException("I/O error deleting graph.", savedEx);
- }
- } finally {
- for (int i = 0; i < NR_INDEXES; ++i) {
- tripleAVLFiles[i] = null;
- }
- metarootFile = null;
+ for (int i = 0; i < NR_INDEXES; ++i) {
+ tripleAVLFiles[i] = null;
+ }
+ metarootFile = null;
+
+ try {
if (lockFile != null) {
lockFile.release();
lockFile = null;
}
+ } catch (Exception e) {
+ // only unchecked exceptions may arrive here
+ // Existing I/O exceptions to take priority
+ if (savedEx == null) throw new StatementStoreException("Error releasing lock file", e);
}
+
+ if (savedEx != null) {
+ throw new StatementStoreException("I/O error deleting graph.", savedEx);
+ }
}
}
More information about the Mulgara-svn
mailing list