exception cleanup
This commit is contained in:
@ -202,10 +202,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
||||
if (total <= 0)
|
||||
_log.error("Warning - initialized database with zero entries");
|
||||
return rv;
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
} catch (Error e) {
|
||||
// blockfile noxiously converts IOEs to Errors with no message
|
||||
} catch (RuntimeException e) {
|
||||
throw new IOException(e.toString());
|
||||
}
|
||||
}
|
||||
@ -247,10 +244,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
||||
_lists.addAll(skiplists);
|
||||
_log.error("DB init took " + DataHelper.formatDuration(_context.clock().now() - start));
|
||||
return bf;
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
} catch (Error e) {
|
||||
// blockfile noxiously converts IOEs to Errors with no message
|
||||
} catch (RuntimeException e) {
|
||||
throw new IOException(e.toString());
|
||||
}
|
||||
}
|
||||
@ -272,8 +266,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
||||
_log.error("DB Lookup error", ioe);
|
||||
// delete index??
|
||||
throw ioe;
|
||||
} catch (Error e) {
|
||||
// blockfile noxiously converts IOEs to Errors with no message
|
||||
} catch (RuntimeException e) {
|
||||
_log.error("DB Lookup error", e);
|
||||
throw new IOException(e.toString());
|
||||
}
|
||||
@ -302,8 +295,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
||||
_log.error("DB add error", ioe);
|
||||
// delete index??
|
||||
throw ioe;
|
||||
} catch (Error e) {
|
||||
// blockfile noxiously converts IOEs to Errors with no message
|
||||
} catch (RuntimeException e) {
|
||||
_log.error("DB add error", e);
|
||||
throw new IOException(e.toString());
|
||||
}
|
||||
@ -312,7 +304,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
||||
/**
|
||||
* Caller must synchronize
|
||||
* @param source may be null
|
||||
* @throws Error
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private void addEntry(SkipList sl, String key, Destination dest, String source) {
|
||||
Properties props = new Properties();
|
||||
@ -325,7 +317,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
||||
/**
|
||||
* Caller must synchronize
|
||||
* @param props may be null
|
||||
* @throws Error
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private static void addEntry(SkipList sl, String key, Destination dest, Properties props) {
|
||||
DestEntry de = new DestEntry();
|
||||
@ -374,7 +366,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
||||
try {
|
||||
_bf.close();
|
||||
} catch (IOException ioe) {
|
||||
} catch (Error e) {
|
||||
} catch (RuntimeException e) {
|
||||
}
|
||||
try {
|
||||
_raf.close();
|
||||
@ -488,7 +480,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
||||
|
||||
public static void main(String[] args) {
|
||||
BlockfileNamingService bns = new BlockfileNamingService(I2PAppContext.getGlobalContext());
|
||||
System.out.println("zzz.i2p: " + bns.lookup("zzz.i2p"));
|
||||
//System.out.println("zzz.i2p: " + bns.lookup("zzz.i2p"));
|
||||
List<String> names = null;
|
||||
try {
|
||||
Properties props = new Properties();
|
||||
|
@ -25,6 +25,9 @@ Changes for i2p:
|
||||
|
||||
- Commented out some System.out.println()
|
||||
|
||||
- Convert Errors without message or cause to RuntimeExceptions with a message and cause
|
||||
|
||||
|
||||
TODO:
|
||||
|
||||
- Change PAGESIZE from default 1024 to 4096? No, wastes too much disk.
|
||||
|
@ -91,13 +91,13 @@ public class BSkipLevels extends SkipLevels {
|
||||
if(levels[i]==null) { break; }
|
||||
bf.file.writeInt(((BSkipLevels) levels[i]).levelPage);
|
||||
}
|
||||
} catch (IOException ioe) { throw new Error(); }
|
||||
} catch (IOException ioe) { throw new RuntimeException("Error writing to database", ioe); }
|
||||
}
|
||||
|
||||
public void killInstance() {
|
||||
try {
|
||||
bf.freePage(levelPage);
|
||||
} catch (IOException ioe) { throw new Error(); }
|
||||
} catch (IOException ioe) { throw new RuntimeException("Error freeing database page", ioe); }
|
||||
}
|
||||
|
||||
public SkipLevels newInstance(int levels, SkipSpan ss, SkipList sl) {
|
||||
@ -107,6 +107,6 @@ public class BSkipLevels extends SkipLevels {
|
||||
int page = bf.allocPage();
|
||||
BSkipLevels.init(bf, page, bss.page, levels);
|
||||
return new BSkipLevels(bf, page, bsl);
|
||||
} catch (IOException ioe) { throw new Error(); }
|
||||
} catch (IOException ioe) { throw new RuntimeException("Error creating database page", ioe); }
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class BSkipList extends SkipList {
|
||||
}
|
||||
|
||||
public BSkipList(int spanSize, BlockFile bf, int skipPage, Serializer key, Serializer val, boolean fileOnly) throws IOException {
|
||||
if(spanSize < 1) { throw new Error("Span size too small"); }
|
||||
if(spanSize < 1) { throw new RuntimeException("Span size too small"); }
|
||||
|
||||
this.skipPage = skipPage;
|
||||
this.bf = bf;
|
||||
@ -88,7 +88,7 @@ public class BSkipList extends SkipList {
|
||||
bf.file.writeInt(size);
|
||||
bf.file.writeInt(spans);
|
||||
|
||||
} catch (IOException ioe) { throw new Error(); }
|
||||
} catch (IOException ioe) { throw new RuntimeException("Error writing to database", ioe); }
|
||||
}
|
||||
|
||||
public void delete() throws IOException {
|
||||
|
@ -65,7 +65,7 @@ public class BSkipSpan extends SkipSpan {
|
||||
int newPage = bf.allocPage();
|
||||
init(bf, newPage, bf.spanSize);
|
||||
return new BSkipSpan(bf, (BSkipList) sl, newPage, keySer, valSer);
|
||||
} catch (IOException ioe) { throw new Error(); }
|
||||
} catch (IOException ioe) { throw new RuntimeException("Error creating database page", ioe); }
|
||||
}
|
||||
|
||||
public void killInstance() {
|
||||
@ -79,7 +79,7 @@ public class BSkipSpan extends SkipSpan {
|
||||
curPage = next;
|
||||
}
|
||||
bf.freePage(page);
|
||||
} catch(IOException ioe) { throw new Error(); }
|
||||
} catch (IOException ioe) { throw new RuntimeException("Error freeing database page", ioe); }
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
@ -124,7 +124,7 @@ public class BSkipSpan extends SkipSpan {
|
||||
}
|
||||
BlockFile.pageSeek(bf.file, this.page);
|
||||
this.overflowPage = bf.file.readInt();
|
||||
} catch(IOException ioe) { throw new Error(); }
|
||||
} catch (IOException ioe) { throw new RuntimeException("Error writing to database", ioe); }
|
||||
}
|
||||
|
||||
private static void load(BSkipSpan bss, BlockFile bf, BSkipList bsl, int spanPage, Serializer key, Serializer val) throws IOException {
|
||||
|
@ -69,7 +69,7 @@ public class IBSkipSpan extends BSkipSpan {
|
||||
rv.keys = new Comparable[bf.spanSize];
|
||||
rv.vals = new Object[bf.spanSize];
|
||||
return rv;
|
||||
} catch (IOException ioe) { throw new Error(ioe); }
|
||||
} catch (IOException ioe) { throw new RuntimeException("Error creating database page", ioe); }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -247,7 +247,7 @@ public class IBSkipSpan extends BSkipSpan {
|
||||
try {
|
||||
seekAndLoadData();
|
||||
} catch (IOException ioe) {
|
||||
throw new Error(ioe);
|
||||
throw new RuntimeException("Error reading database", ioe);
|
||||
}
|
||||
SkipSpan rv = super.getSpan(key, search);
|
||||
this.keys = null;
|
||||
@ -266,7 +266,7 @@ public class IBSkipSpan extends BSkipSpan {
|
||||
return next.get(key);
|
||||
return getData(key);
|
||||
} catch (IOException ioe) {
|
||||
throw new Error(ioe);
|
||||
throw new RuntimeException("Error reading database", ioe);
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,7 +278,7 @@ public class IBSkipSpan extends BSkipSpan {
|
||||
try {
|
||||
seekAndLoadData();
|
||||
} catch (IOException ioe) {
|
||||
throw new Error(ioe);
|
||||
throw new RuntimeException("Error reading database", ioe);
|
||||
}
|
||||
SkipSpan rv = super.put(key, val, sl);
|
||||
// flush() nulls out the data
|
||||
@ -293,7 +293,7 @@ public class IBSkipSpan extends BSkipSpan {
|
||||
try {
|
||||
seekAndLoadData();
|
||||
} catch (IOException ioe) {
|
||||
throw new Error(ioe);
|
||||
throw new RuntimeException("Error reading database", ioe);
|
||||
}
|
||||
Object[] rv = super.remove(key, sl);
|
||||
// flush() nulls out the data
|
||||
|
Reference in New Issue
Block a user