Ignore:
Timestamp:
09/18/11 13:55:15 (8 months ago)
Author:
xeraph
Branch:
default
Convert:
svn:7c3792e6-d75b-4784-96a6-b298f655ee64/trunk@2777
Message:
  • fixed potential handle leak bugs.
  • added missing license terms
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kraken-linux-api/src/main/java/org/krakenapps/linux/api/UdpConnectionInformation.java

    r2 r343  
    7878                List<ConnectionInformation> stats = new ArrayList<ConnectionInformation>(); 
    7979                BufferedReader br = null; 
    80  
    81                 br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(filePath)))); 
    82                 br.readLine(); // ignore column name line 
    83                 while (true) { 
    84                         String line = br.readLine(); 
    85                         if (line == null) 
    86                                 break; 
    87  
    88                         if (filePath.endsWith("udp")) 
    89                                 stats.add(parse(line, 4, uidToPid)); 
    90                         else if (filePath.endsWith("udp6")) 
    91                                 stats.add(parse(line, 16, uidToPid)); 
    92                 } 
     80                FileInputStream is = null; 
    9381 
    9482                try { 
    95                         br.close(); 
    96                 } catch (IOException e) { 
     83                        is = new FileInputStream(new File(filePath)); 
     84                        br = new BufferedReader(new InputStreamReader(is)); 
     85                        br.readLine(); // ignore column name line 
     86                        while (true) { 
     87                                String line = br.readLine(); 
     88                                if (line == null) 
     89                                        break; 
     90 
     91                                if (filePath.endsWith("udp")) 
     92                                        stats.add(parse(line, 4, uidToPid)); 
     93                                else if (filePath.endsWith("udp6")) 
     94                                        stats.add(parse(line, 16, uidToPid)); 
     95                        } 
     96                } finally { 
     97                        if (is != null) 
     98                                is.close(); 
     99                        if (br != null) 
     100                                br.close(); 
    97101                } 
    98102 
Note: See TracChangeset for help on using the changeset viewer.