From 8117d0465c9fa3e1ab12977e96231be1a7e80c72 Mon Sep 17 00:00:00 2001
From: sponge <sponge@mail.i2p>
Date: Sat, 11 Oct 2008 21:59:18 +0000
Subject: [PATCH] BOB fixes: Default Properties work, files are properly
 closed.

---
 apps/BOB/src/net/i2p/BOB/BOB.java    | 95 ++++++++++++++++++++++++----
 apps/BOB/src/net/i2p/BOB/doCMDS.java |  2 +-
 2 files changed, 83 insertions(+), 14 deletions(-)

diff --git a/apps/BOB/src/net/i2p/BOB/BOB.java b/apps/BOB/src/net/i2p/BOB/BOB.java
index 0221723410..ca2d6f878a 100644
--- a/apps/BOB/src/net/i2p/BOB/BOB.java
+++ b/apps/BOB/src/net/i2p/BOB/BOB.java
@@ -35,9 +35,73 @@ import net.i2p.client.I2PClient;
 import net.i2p.client.streaming.RetransmissionTimer;
 import net.i2p.util.Log;
 import net.i2p.util.SimpleTimer;
-
 /**
- *
+ * <span style="font-size:8px;font-family:courier;color:#EEEEEE;background-color:#000000">
+ * ################################################################################<br>
+ * ############################.#..........#..#..........##########################<br>
+ * #######################......................................###################<br>
+ * ####################...........................#.......#........################<br>
+ * #################..................##...................#.........##############<br>
+ * ###############................###...####.....#..###.....#.........#############<br>
+ * #############...........###..#..###...#####...###.##........#.......############<br>
+ * ###########................#......##...#####...##..##.......#..#........########<br>
+ * ##########.........................#....##.##..#...##.....................######<br>
+ * #########...................................#....#.........................#####<br>
+ * ########.........................................#...............#..........####<br>
+ * ########.........................................#..........#######..........###<br>
+ * #######.................................................############..........##<br>
+ * #######..........................................####################.........##<br>
+ * #######............####################......########################.........##<br>
+ * ######.............###############################################.##.........##<br>
+ * ######............################################################..##........##<br>
+ * ######............################################################..##........##<br>
+ * ######.............##############################################..##.........##<br>
+ * ######............##############################################...##..........#<br>
+ * ######............#..###########################################...##..........#<br>
+ * ######.............#############################################....#..........#<br>
+ * #######...........###############################################..##.........##<br>
+ * #######...........#####.#.#.#.########################.....#.####...##........##<br>
+ * ######............#..............##################.................##.........#<br>
+ * ######................####.........###############........#####......##........#<br>
+ * ######..............####..#.........############.......##.#.######...##.......##<br>
+ * ######.................#.####.........########...........##....###...##.......##<br>
+ * #######....#....###...................#######...............#...###..##.......##<br>
+ * #######.........###..###.....###.......######.##.#####.........####..##.......##<br>
+ * #######.....#...##############.........############......###########.###......##<br>
+ * #######....##...##########.......##...##############......#.############.....###<br>
+ * ########....#..########......######...##################################....####<br>
+ * ########....##.####################...##################################....####<br>
+ * ########..#.##..###################..##################################..#..####<br>
+ * ##########..###..#################...##################################...#.####<br>
+ * #########....##...##############....########..#####.################.##..#.#####<br>
+ * ############.##....##########.......#########.###.......###########..#.#########<br>
+ * ###############.....#######...#.......########.....##.....######.....###########<br>
+ * ###############......###....##..........##.......######....#.........#.#########<br>
+ * ##############............##..................##########..............##########<br>
+ * ##############..............................##########..#.............##########<br>
+ * ###############.......##..................#####..............####....###########<br>
+ * ###############.......#####.......#.............####.....#######.....###########<br>
+ * ################...#...####......##################.....########....############<br>
+ * ################...##..#####.........####.##.....#....##########....############<br>
+ * ##################..##..####...........#####.#....############.....#############<br>
+ * ##################......#####.................################....##############<br>
+ * ###################.....####..........##########..###########....###############<br>
+ * ####################..#..#..........................########.....###############<br>
+ * #####################.##.......###.................########....#################<br>
+ * ######################.........#.......#.##.###############....#################<br>
+ * #############.#######...............#####################....###################<br>
+ * ###..#.....##...####..........#.....####################....####################<br>
+ * ####......##........................##################....######################<br>
+ * #.##...###..............###.........###############......#######################<br>
+ * #...###..##............######...........................########################<br>
+ * ##.......###..........##########....#...#...........############################<br>
+ * ##.........##.......############################################################<br>
+ * ###........##.....##############################################################<br>
+ * ####.............###############################################################<br>
+ * ######.........#################################################################<br>
+ * #########....###################################################################<br>
+ * ################################################################################<br>
+ * </span>
  * BOB, main command socket listener, launches the command parser engine.
  *
  * @author sponge
@@ -89,16 +153,19 @@ public class BOB {
 		// This is here just to ensure there is no interference with our threadgroups.
 		SimpleTimer Y = RetransmissionTimer.getInstance();
 		i = Y.hashCode();
-
-		try {
-			props.load(new FileInputStream(configLocation));
-		} catch(FileNotFoundException fnfe) {
-			warn("Unable to load up the BOB config file " + configLocation + ", Using defaults.");
-			warn(fnfe.toString());
-			save = true;
-		} catch(IOException ioe) {
-			warn("IOException on BOB config file " + configLocation + ", using defaults.");
-			warn(ioe.toString());
+		{
+			try {
+				FileInputStream fi = new FileInputStream(configLocation);
+				props.load(fi);
+				fi.close();
+			} catch(FileNotFoundException fnfe) {
+				warn("Unable to load up the BOB config file " + configLocation + ", Using defaults.");
+				warn(fnfe.toString());
+				save = true;
+			} catch(IOException ioe) {
+				warn("IOException on BOB config file " + configLocation + ", using defaults.");
+				warn(ioe.toString());
+			}
 		}
 		// Global router and client API configurations that are missing are set to defaults here.
 		if(!props.containsKey(I2PClient.PROP_TCP_HOST)) {
@@ -131,7 +198,9 @@ public class BOB {
 		if(save) {
 			try {
 				warn("Writing new defaults file " + configLocation);
-				props.store(new FileOutputStream(configLocation), configLocation);
+				FileOutputStream fo = new FileOutputStream(configLocation);
+				props.store(fo, configLocation);
+				fo.close();
 			} catch(IOException ioe) {
 				warn("IOException on BOB config file " + configLocation + ", " + ioe);
 			}
diff --git a/apps/BOB/src/net/i2p/BOB/doCMDS.java b/apps/BOB/src/net/i2p/BOB/doCMDS.java
index 2fb363b189..e6c7b6fd78 100644
--- a/apps/BOB/src/net/i2p/BOB/doCMDS.java
+++ b/apps/BOB/src/net/i2p/BOB/doCMDS.java
@@ -151,7 +151,7 @@ public class doCMDS implements Runnable {
 	 */
 	doCMDS(Socket server, Properties props, nickname database, Log _log) {
 		this.server = server;
-		this.props = props;
+		this.props = new Properties(props);
 		this.database = database;
 		this._log = _log;
 	}
-- 
GitLab