Changeset b84682f


Ignore:
Timestamp:
Apr 21, 2014 10:54:52 AM (7 years ago)
Author:
dg2-new <dg2-new@…>
Branches:
master
Children:
49f4f33
Parents:
b9491b2
Message:
  • findbugs: mostly stream closure fixes in router, apps, core
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/PeerConnectionOut.java

    rb9491b2 rb84682f  
    136136                          }
    137137                         
    138                         if (m == null && nm != null)
     138                        if (nm != null)
    139139                          {
    140140                            m = nm;
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java

    rb9491b2 rb84682f  
    14161416                //notifyEvent("genkeysResult", "error");
    14171417                return;
     1418            } finally {
     1419                if(pubdest != null) try { pubdest.close(); } catch(IOException ioe) {}
    14181420            }
    14191421        } else if (args.length != 1) {
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/IrcInboundFilter.java

    rb9491b2 rb84682f  
    9595            _log.error("Error filtering inbound data", re);
    9696        } finally {
    97             try { local.close(); } catch (IOException e) {}
     97            try { in.close(); } catch (IOException e) {}
     98            try { local.close(); } catch(IOException e) {}
    9899        }
    99100        if(_log.shouldLog(Log.DEBUG))
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKS5Server.java

    rb9491b2 rb84682f  
    469469            throw new SOCKSException("Outproxy not found");
    470470        I2PSocket destSock = tun.createI2PSocket(I2PAppContext.getGlobalContext().namingService().lookup(proxy), proxyOpts);
     471        DataOutputStream out = null;
     472        DataInputStream in = null;
    471473        try {
    472             DataOutputStream out = new DataOutputStream(destSock.getOutputStream());
     474            out = new DataOutputStream(destSock.getOutputStream());
    473475            boolean authAvail = Boolean.parseBoolean(props.getProperty(I2PTunnelHTTPClientBase.PROP_OUTPROXY_AUTH));
    474476            String configUser =  null;
     
    498500
    499501            // read init reply
    500             DataInputStream in = new DataInputStream(destSock.getInputStream());
     502            in = new DataInputStream(destSock.getInputStream());
    501503            // is this right or should we not try to do 5-to-4 conversion?
    502504            int hisVersion = in.readByte();
     
    574576            // throw away the address in the response
    575577            // todo pass the response through?
     578            out.close();
     579            in.close();
    576580        } catch (IOException e) {
    577581            try { destSock.close(); } catch (IOException ioe) {}
  • apps/routerconsole/java/src/net/i2p/router/web/LogsHelper.java

    rb9491b2 rb84682f  
    169169        if (!f.exists()) return null;
    170170        FileInputStream fis = null;
     171        BufferedReader in = null;
    171172        try {
    172173            fis = new FileInputStream(f);
    173             BufferedReader in = new BufferedReader(new InputStreamReader(fis));
     174            in = new BufferedReader(new InputStreamReader(fis));
    174175            List<String> lines = new ArrayList<String>(maxNumLines);
    175176            String line = null;
     
    187188            return null;
    188189        } finally {
    189             if (fis != null) try { fis.close(); } catch (IOException ioe) {}
     190            if (in != null) try { in.close(); } catch (IOException ioe) {}
    190191        }
    191192    }
  • apps/sam/java/src/net/i2p/sam/client/SAMStreamSend.java

    rb9491b2 rb84682f  
    8282            Sender sender = null;
    8383            synchronized (_remotePeers) {
    84                 sender = _remotePeers.remove(new Integer(id));
     84                sender = _remotePeers.remove(Integer.valueOf(id));
    8585            }
    8686            if (sender != null) {
     
    172172                synchronized (_remotePeers) {
    173173                    _connectionId = _remotePeers.size() + 1;
    174                     _remotePeers.put(new Integer(_connectionId), Sender.this);
     174                    _remotePeers.put(Integer.valueOf(_connectionId), Sender.this);
    175175                }
    176176
  • apps/sam/java/src/net/i2p/sam/client/SAMStreamSink.java

    rb9491b2 rb84682f  
    8484            Sink sink = null;
    8585            synchronized (_remotePeers) {
    86                 sink = _remotePeers.remove(new Integer(id));
     86                sink = _remotePeers.remove(Integer.valueOf(id));
    8787            }
    8888            if (sink != null) {
     
    9797            Sink sink = null;
    9898            synchronized (_remotePeers) {
    99                 sink = _remotePeers.get(new Integer(id));
     99                sink = _remotePeers.get(Integer.valueOf(id));
    100100            }
    101101            if (sink != null) {
     
    112112                Sink sink = new Sink(id, dest);
    113113                synchronized (_remotePeers) {
    114                     _remotePeers.put(new Integer(id), sink);
     114                    _remotePeers.put(Integer.valueOf(id), sink);
    115115                }
    116116            } catch (IOException ioe) {
     
    170170   
    171171    private boolean writeDest(String dest) {
     172        FileOutputStream fos = null;
    172173        try {
    173             FileOutputStream fos = new FileOutputStream(_destFile);
     174            fos = new FileOutputStream(_destFile);
    174175            fos.write(dest.getBytes());
    175             fos.close();
    176             return true;
    177176        } catch (Exception e) {
    178177            _log.error("Error writing to " + _destFile, e);
    179178            return false;
    180         }
     179        } finally {
     180            if(fos != null) try { fos.close(); } catch(IOException ioe) {}
     181        }
     182        return true;
    181183    }
    182184   
  • apps/susimail/src/src/i2p/susi/util/Config.java

    rb9491b2 rb84682f  
    2828import java.io.File;
    2929import java.io.FileInputStream;
     30import java.io.InputStream;
    3031import java.io.IOException;
    3132import java.util.Properties;
     
    9293                // DEBUG level logging won't work here since we haven't loaded the config yet...
    9394                properties = new Properties();
     95                InputStream iv = null;
    9496                try {
    95                         properties.load( Config.class.getResourceAsStream( "/susimail.properties" ) );
     97                        iv = Config.class.getResourceAsStream("/susimail.properties");
     98                        properties.load(iv);
    9699                } catch (Exception e) {
    97100                        Debug.debug(Debug.ERROR, "Could not open WEB-INF/classes/susimail.properties (possibly in jar), reason: " + e);
     101                } finally {
     102                        if(iv != null) try { iv.close(); } catch(IOException ioe) {}
    98103                }
    99104                try {
  • core/java/src/net/i2p/crypto/CertUtil.java

    rb9491b2 rb84682f  
    4040    public static boolean saveCert(Certificate cert, File file) {
    4141        OutputStream os = null;
     42        PrintWriter wr = null;
    4243        try {
    4344           // Get the encoded form which is suitable for exporting
    4445           byte[] buf = cert.getEncoded();
    4546           os = new SecureFileOutputStream(file);
    46            PrintWriter wr = new PrintWriter(os);
     47           wr = new PrintWriter(os);
    4748           wr.println("-----BEGIN CERTIFICATE-----");
    4849           String b64 = Base64.encode(buf, true);     // true = use standard alphabet
  • core/java/src/net/i2p/util/FileUtil.java

    rb9491b2 rb84682f  
    356356        if (!f.exists()) return null;
    357357        FileInputStream fis = null;
     358        BufferedReader in = null;
    358359        try {
    359360            fis = new FileInputStream(f);
    360             BufferedReader in = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
     361            in = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
    361362            List<String> lines = new ArrayList<String>(maxNumLines > 0 ? maxNumLines : 64);
    362363            String line = null;
     
    378379            return null;
    379380        } finally {
    380             if (fis != null) try { fis.close(); } catch (IOException ioe) {}
     381            if (in != null) try { in.close(); } catch (IOException ioe) {}
    381382        }
    382383    }
  • core/java/src/net/i2p/util/TranslateReader.java

    rb9491b2 rb84682f  
    392392
    393393    private static void test(String file) throws IOException {
     394        FileInputStream fio = new FileInputStream(file);
    394395        TranslateReader r = new TranslateReader(I2PAppContext.getGlobalContext(),
    395396                                                "net.i2p.router.web.messages",
    396                                                 new FileInputStream(file));
     397                                                fio);
    397398        int c;
    398399        while ((c = r.read()) >= 0) {
     
    400401        }
    401402        System.out.flush();
     403        r.close();
    402404    }
    403405
  • history.txt

    rb9491b2 rb84682f  
     12014-04-21 dg
     2 * findbugs: mostly stream closure fixes in router, apps, core
     3
    142014-04-20 zzz
    25 * SusiMail:
  • router/java/src/net/i2p/router/Router.java

    rb9491b2 rb84682f  
    13151315        // this is similar to FileUtil.readTextFile() but we can't use any I2P classes here
    13161316        FileInputStream fis = null;
     1317        BufferedReader in = null;
    13171318        try {
    13181319            fis = new FileInputStream(deleteFile);
    1319             BufferedReader in = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
     1320            in = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
    13201321            String line;
    13211322            while ( (line = in.readLine()) != null) {
     
    13321333                }
    13331334            }
    1334         } catch (IOException ioe) {
    1335         } finally {
    1336             if (fis != null) try { fis.close(); } catch (IOException ioe) {}
     1335        } catch (IOException ioe) {}
     1336        finally {
     1337            if (in != null) try { in.close(); } catch(IOException ioe) {}
    13371338            if (deleteFile.delete())
    13381339                System.out.println("INFO: File [" + DELETE_FILE + "] deleted");
Note: See TracChangeset for help on using the changeset viewer.