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

    r2 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 
     
    107122        } 
    108123 
    109         public static List<NetworkInterface> getNetworkInterfaces() { 
     124        public static List<NetworkInterface> getNetworkInterfaces() throws IOException { 
    110125                List<NetworkInterface> ifaces = new ArrayList<NetworkInterface>(); 
    111126                java.lang.Process p = null; 
     
    122137                                ifaces.add(iface); 
    123138                        } 
    124                 } catch (IOException e) { 
    125                         e.printStackTrace(); 
    126139                } finally { 
    127140                        if (p != null) 
    128141                                p.destroy(); 
    129                         try { 
    130                                 if (br != null) 
    131                                         br.close(); 
    132                         } catch (IOException e) { 
    133                                 e.printStackTrace(); 
    134                         } 
     142                        if (br != null) 
     143                                br.close(); 
    135144                } 
    136145 
     
    258267                @Override 
    259268                public String toString() { 
    260                         return "RxPacket [packets=" + packets + ", errors=" + errors + ", dropped=" + dropped + ", overruns=" 
    261                                         + overruns + ", frame=" + frame + "]"; 
     269                        return "RxPacket [packets=" + packets + ", errors=" + errors + ", dropped=" + dropped + ", overruns=" + overruns 
     270                                        + ", frame=" + frame + "]"; 
    262271                } 
    263272        } 
     
    332341                @Override 
    333342                public String toString() { 
    334                         return "TxPacket [packets=" + packets + ", errors=" + errors + ", dropped=" + dropped + ", overruns=" 
    335                                         + overruns + ", carrier=" + carrier + ", collisions=" + collisions + ", queuelen=" + queuelen + "]"; 
     343                        return "TxPacket [packets=" + packets + ", errors=" + errors + ", dropped=" + dropped + ", overruns=" + overruns 
     344                                        + ", carrier=" + carrier + ", collisions=" + collisions + ", queuelen=" + queuelen + "]"; 
    336345                } 
    337346        } 
     
    339348        @Override 
    340349        public String toString() { 
    341                 return "NetworkInterface [name=" + name + ", linkEncap=" + linkEncap + ", hwaddr=" + hwaddr + ", inet=" + inet 
    342                                 + ", ptp=" + ptp + ", mask=" + mask + ", inet6=" + inet6 + ", cidr=" + cidr + ", scope=" + scope 
    343                                 + ", options=" + options + ", mtu=" + mtu + ", metric=" + metric + ", rxPacket=" + rxPacket 
    344                                 + ", txPacket=" + txPacket + ", rxBytes=" + rxBytes + ", txBytes=" + txBytes + ", interrupt=" 
    345                                 + interrupt + ", baseAddress=" + baseAddress + ", memory=" + memory + "]"; 
     350                return "NetworkInterface [name=" + name + ", linkEncap=" + linkEncap + ", hwaddr=" + hwaddr + ", inet=" + inet + ", ptp=" 
     351                                + ptp + ", mask=" + mask + ", inet6=" + inet6 + ", cidr=" + cidr + ", scope=" + scope + ", options=" + options 
     352                                + ", mtu=" + mtu + ", metric=" + metric + ", rxPacket=" + rxPacket + ", txPacket=" + txPacket + ", rxBytes=" 
     353                                + rxBytes + ", txBytes=" + txBytes + ", interrupt=" + interrupt + ", baseAddress=" + baseAddress + ", memory=" 
     354                                + memory + "]"; 
    346355        } 
    347356} 
Note: See TracChangeset for help on using the changeset viewer.