jdk/src/share/classes/sun/tools/jstat/OptionFinder.java
changeset 5778 ca3811dc046d
parent 5506 202f599c92aa
child 7668 d4a77089c587
--- a/jdk/src/share/classes/sun/tools/jstat/OptionFinder.java	Tue Jun 08 18:52:17 2010 -0700
+++ b/jdk/src/share/classes/sun/tools/jstat/OptionFinder.java	Thu Jun 10 14:14:17 2010 -0700
@@ -39,9 +39,9 @@
 
     private static final boolean debug = false;
 
-    URL[] optionsSources;
+    List<URL> optionsSources;
 
-    public OptionFinder(URL[] optionsSources) {
+    public OptionFinder(List<URL> optionsSources) {
         this.optionsSources = optionsSources;
     }
 
@@ -59,24 +59,25 @@
         return of;
     }
 
-    protected OptionFormat getOptionFormat(String option, URL[] sources) {
+    protected OptionFormat getOptionFormat(String option, List<URL> sources) {
         OptionFormat of = null;
-        for (int i = 0; (i < sources.length) && (of == null); i++) {
+        for (URL u : sources) {
             try {
-                URL u = sources[i];
                 Reader r = new BufferedReader(
                         new InputStreamReader(u.openStream()));
                 of = new Parser(r).parse(option);
+                if (of != null)
+                    break;
             } catch (IOException e) {
                 if (debug) {
-                    System.err.println("Error processing " + sources[i]
+                    System.err.println("Error processing " + u
                                        + " : " + e.getMessage());
                     e.printStackTrace();
                 }
             } catch (ParserException e) {
                 // Exception in parsing the options file.
-                System.err.println(sources[i] + ": " + e.getMessage());
-                System.err.println("Parsing of " + sources[i] + " aborted");
+                System.err.println(u + ": " + e.getMessage());
+                System.err.println("Parsing of " + u + " aborted");
             }
         }
         return of;