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

    r2 r343  
    1 package org.krakenapps.linux.api; 
     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 */package org.krakenapps.linux.api; 
    216 
    317import java.io.BufferedReader; 
     
    4357        private List<AddressBinding> addressBindings; 
    4458 
    45         public EthernetInterface(String device) throws FileNotFoundException { 
     59        public EthernetInterface(String device) throws IOException { 
    4660                BufferedReader br = null; 
    4761                String line = null; 
     
    107121                                } 
    108122                        } 
    109                 } catch (IOException e) { 
    110                         e.printStackTrace(); 
    111123                } finally { 
    112                         try { 
     124                        if (br != null) 
    113125                                br.close(); 
    114                         } catch (IOException e) { 
    115                                 e.printStackTrace(); 
    116                         } 
    117126                } 
    118127 
     
    147156                                                subAddr.description.add(line); 
    148157                                } 
    149                                 br.close(); 
    150                         } catch (IOException e) { 
    151                                 e.printStackTrace(); 
    152                         } 
     158                        } finally { 
     159                                if (br != null) 
     160                                        br.close(); 
     161                        } 
     162                         
    153163                        addressBindings.add(subAddr); 
    154164                } 
    155165        } 
    156166 
    157         public static List<EthernetInterface> getEthernetInterfaces() { 
     167        public static List<EthernetInterface> getEthernetInterfaces() throws IOException { 
    158168                List<EthernetInterface> interfaces = new ArrayList<EthernetInterface>(); 
    159169                String[] filenames = new File(cfgPath).list(new FilenameFilter() { 
Note: See TracChangeset for help on using the changeset viewer.