Project

Profile

Help

Revision eb954fa3

Added by Michael Kay over 12 years ago

Diagnostic patch for ArrayIndexOutOfBoundsException occurring in NamespaceIterator line 288

View differences:

latest9.1/bj/net/sf/saxon/om/NamespaceIterator.java
281 281
            return XML_NAMESPACE_CODE_ARRAY;
282 282
        } else {
283 283

  
284
            int[] codes = new int[declared.size()];
285
            int i = 0;
286
            IntIterator ii = declared.iterator();
287
            while (ii.hasNext()) {
288
                codes[i++] = ii.next();
284
            try {
285
                int[] codes = new int[declared.size()];
286
                int i = 0;
287
                IntIterator ii = declared.iterator();
288
                while (ii.hasNext()) {
289
                    codes[i++] = ii.next();
290
                }
291
                return codes;
292
            } catch (ArrayIndexOutOfBoundsException e) {
293
                // Diagnostic patch for a rarely-occurring problem, observed in both 8.6 and 9.1
294
                System.err.println("*** Internal error in NamespaceIterator ***");
295
                declared.diagnosticDump();
296
                throw e;
289 297
            }
290
            return codes;
291 298
        }
292 299
    }
293 300

  
latest9.1/bj/net/sf/saxon/sort/IntHashSet.java
1 1
package net.sf.saxon.sort;
2 2

  
3
import net.sf.saxon.om.FastStringBuffer;
4

  
3 5
import java.io.Serializable;
4 6

  
5 7
/**
......
340 342
    }
341 343

  
342 344
    /**
345
     * Diagnostic output
346
     */
347

  
348
    public void diagnosticDump() {
349
        System.err.println("Contents of IntHashSet");
350
        FastStringBuffer sb = new FastStringBuffer(100);
351
        for (int i = 0; i < _values.length; i++) {
352
            if (i % 10 == 0) {
353
                System.err.println(sb.toString());
354
                sb.setLength(0);
355
            }
356
            if (_values[i] == ndv) {
357
                sb.append("*, ");
358
            } else {
359
                sb.append(_values[i] + ", ");
360
            }
361
        }
362
        System.err.println(sb.toString());
363
        sb.setLength(0);
364
        System.err.println("size: " + _size);
365
        System.err.println("ndv: " + ndv);
366
        System.err.println("nlo: " + _nlo);
367
        System.err.println("nhi: " + _nhi);
368
        System.err.println("nmax: " + _nmax);
369
        System.err.println("shift: " + _shift);
370
        System.err.println("mask: " + _mask);
371
        System.err.println("Result of iterator:");
372
        IntIterator iter = iterator();
373
        int i = 0;
374
        while (iter.hasNext()) {
375
            if (i++ % 10 == 0) {
376
                System.err.println(sb.toString());
377
                sb.setLength(0);
378
            }
379
            sb.append(iter.next() + ", ");
380
        }
381
        System.err.println(sb.toString());
382
        System.err.println("=====================");
383
    }
384
    
385

  
386
    /**
343 387
     * Iterator class
344 388
     */
345 389

  

Also available in: Unified diff