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/RoutingTable.java

    r307 r343  
     1/* 
     2 * Copyright 2011 Future Systems 
     3 *  
     4 * Licensed under the Apache License, Version 2.0 (the "License"); 
     5 * you may not use this file except in compliance with the License. 
     6 * You may obtain a copy of the License at 
     7 *  
     8 * http://www.apache.org/licenses/LICENSE-2.0 
     9 *  
     10 * Unless required by applicable law or agreed to in writing, software 
     11 * distributed under the License is distributed on an "AS IS" BASIS, 
     12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
     13 * See the License for the specific language governing permissions and 
     14 * limitations under the License. 
     15 */ 
    116package org.krakenapps.linux.api; 
    217 
     
    1227 
    1328public class RoutingTable { 
    14         public static List<RoutingEntry> getRoutingEntries() { 
     29        public static List<RoutingEntry> getRoutingEntries() throws IOException { 
    1530                List<RoutingEntry> entries = new ArrayList<RoutingEntry>(); 
    1631                java.lang.Process p = null; 
     
    3752                                        int use = Integer.parseInt(tokens[6]); 
    3853                                        String iface = tokens[7]; 
    39                                         entries.add(new RoutingEntry(destination, gateway, genmask, flags, metric, ref, use, iface, null, 
    40                                                         null, null)); 
     54                                        entries.add(new RoutingEntry(destination, gateway, genmask, flags, metric, ref, use, iface, null, null, null)); 
    4155                                } else if (tokens.length == 11) { 
    4256                                        InetAddress destination = (!tokens[0].equals("default")) ? InetAddress.getByName(tokens[0]) : null; 
     
    5165                                        int window = Integer.parseInt(tokens[9]); 
    5266                                        int irtt = Integer.parseInt(tokens[10]); 
    53                                         entries.add(new RoutingEntry(destination, gateway, genmask, flags, metric, ref, use, iface, mss, 
    54                                                         window, irtt)); 
     67                                        entries.add(new RoutingEntry(destination, gateway, genmask, flags, metric, ref, use, iface, mss, window, irtt)); 
    5568                                } 
    5669                        } 
    57                 } catch (IOException e) { 
    58                         e.printStackTrace(); 
    5970                } finally { 
    6071                        if (p != null) 
    6172                                p.destroy(); 
    62                         try { 
    63                                 if (br != null) 
    64                                         br.close(); 
    65                         } catch (IOException e) { 
    66                                 e.printStackTrace(); 
    67                         } 
     73                        if (br != null) 
     74                                br.close(); 
    6875                } 
    6976 
     
    7178        } 
    7279 
    73         public static List<RoutingEntryV6> getIpv6RoutingEntries() { 
     80        public static List<RoutingEntryV6> getIpv6RoutingEntries() throws IOException { 
    7481                List<RoutingEntryV6> entries = new ArrayList<RoutingEntryV6>(); 
    7582                java.lang.Process p = null; 
     
    106113                                entries.add(new RoutingEntryV6(destination, nextHop, mask, flags, metric, ref, use, iface)); 
    107114                        } 
    108                 } catch (IOException e) { 
    109                         e.printStackTrace(); 
    110115                } finally { 
    111116                        if (p != null) 
    112117                                p.destroy(); 
    113                         try { 
    114                                 if (br != null) 
    115                                         br.close(); 
    116                         } catch (IOException e) { 
    117                                 e.printStackTrace(); 
    118                         } 
     118                        if (br != null) 
     119                                br.close(); 
    119120                } 
    120121 
     
    170171        } 
    171172 
    172         public static RoutingEntry findRoute(InetAddress ip) { 
     173        public static RoutingEntry findRoute(InetAddress ip) throws IOException { 
    173174                int target = toInt((Inet4Address) ip); 
    174175 
Note: See TracChangeset for help on using the changeset viewer.