Big findbugs cleanup

This commit is contained in:
zzz
2008-10-19 22:09:14 +00:00
parent 8a756a6e81
commit 20effe3a7f
77 changed files with 261 additions and 245 deletions

View File

@@ -85,9 +85,11 @@ public class AddressbookBean
if( properties.size() > 0 && currentTime - configLastLoaded < 10000 )
return;
FileInputStream fis = null;
try {
properties.clear();
properties.load( new FileInputStream( ConfigBean.configFileName ) );
fis = new FileInputStream( ConfigBean.configFileName );
properties.load( fis );
// added in 0.5, for compatibility with 0.4 config.txt
if( properties.getProperty(PRIVATE_BOOK) == null)
properties.setProperty(PRIVATE_BOOK, DEFAULT_PRIVATE_BOOK);
@@ -95,6 +97,9 @@ public class AddressbookBean
}
catch (Exception e) {
Debug.debug( e.getClass().getName() + ": " + e.getMessage() );
} finally {
if (fis != null)
try { fis.close(); } catch (IOException ioe) {}
}
}
public String getFileName()
@@ -143,9 +148,10 @@ public class AddressbookBean
addressbook = new Properties();
String message = "";
FileInputStream fis = null;
try {
addressbook.load( new FileInputStream( getFileName() ) );
fis = new FileInputStream( getFileName() );
addressbook.load( fis );
LinkedList list = new LinkedList();
Enumeration e = addressbook.keys();
while( e.hasMoreElements() ) {
@@ -182,8 +188,10 @@ public class AddressbookBean
}
catch (Exception e) {
Debug.debug( e.getClass().getName() + ": " + e.getMessage() );
} finally {
if (fis != null)
try { fis.close(); } catch (IOException ioe) {}
}
if( message.length() > 0 )
message = "<p>" + message + "</p>";
return message;
@@ -243,7 +251,11 @@ public class AddressbookBean
{
String filename = properties.getProperty( getBook() + "_addressbook" );
addressbook.store( new FileOutputStream( ConfigBean.addressbookPrefix + filename ), null );
FileOutputStream fos = new FileOutputStream( ConfigBean.addressbookPrefix + filename );
addressbook.store( fos, null );
try {
fos.close();
} catch (IOException ioe) {}
}
public String getFilter() {
return filter;

View File

@@ -38,8 +38,8 @@ public class ConfigBean implements Serializable {
/*
* as this is not provided as constant in addressbook, we define it here
*/
public static String addressbookPrefix = "addressbook/";
public static String configFileName = addressbookPrefix + "config.txt";
public static final String addressbookPrefix = "addressbook/";
public static final String configFileName = addressbookPrefix + "config.txt";
private String action, config;
private String serial, lastSerial;
@@ -80,8 +80,9 @@ public class ConfigBean implements Serializable {
File file = new File( configFileName );
if( file != null && file.isFile() ) {
StringBuffer buf = new StringBuffer();
BufferedReader br = null;
try {
BufferedReader br = new BufferedReader( new FileReader( file ) );
br = new BufferedReader( new FileReader( file ) );
String line;
while( ( line = br.readLine() ) != null ) {
buf.append( line );
@@ -95,6 +96,9 @@ public class ConfigBean implements Serializable {
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (br != null)
try { br.close(); } catch (IOException ioe) {}
}
}
}

View File

@@ -37,7 +37,6 @@ import java.util.Properties;
public class SubscriptionsBean
{
private String action, fileName, content, serial, lastSerial;
private boolean saved;
Properties properties;
@@ -53,13 +52,18 @@ public class SubscriptionsBean
if( properties.size() > 0 && currentTime - configLastLoaded < 10000 )
return;
FileInputStream fis = null;
try {
properties.clear();
properties.load( new FileInputStream( ConfigBean.configFileName ) );
fis = new FileInputStream( ConfigBean.configFileName );
properties.load( fis );
configLastLoaded = currentTime;
}
catch (Exception e) {
Debug.debug( e.getClass().getName() + ": " + e.getMessage() );
} finally {
if (fis != null)
try { fis.close(); } catch (IOException ioe) {}
}
}
public String getAction() {
@@ -83,21 +87,24 @@ public class SubscriptionsBean
File file = new File( getFileName() );
if( file != null && file.isFile() ) {
StringBuffer buf = new StringBuffer();
BufferedReader br = null;
try {
BufferedReader br = new BufferedReader( new FileReader( file ) );
br = new BufferedReader( new FileReader( file ) );
String line;
while( ( line = br.readLine() ) != null ) {
buf.append( line );
buf.append( "\n" );
}
content = buf.toString();
saved = true;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (br != null)
try { br.close(); } catch (IOException ioe) {}
}
}
}
@@ -110,7 +117,6 @@ public class SubscriptionsBean
out.print( content );
out.flush();
out.close();
saved = true;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -148,7 +154,6 @@ public class SubscriptionsBean
}
public void setContent(String content) {
this.content = content;
this.saved = false;
/*
* as this is a property file we need a newline at the end of the last line!