void umount1() { // START SNIPPET: umount1 try { TVFS.umount(); // with or without parameters } catch (SequentialIOException ouch) { // Print the sequential I/O exception chain in order of // descending priority and ascending appearance. ouch.sortPriority().printStackTrace(); //ouch.printStackTrace(); // equivalent } // END SNIPPET: umount1 }
void umount2() { // START SNIPPET: umount2 try { TVFS.umount(); // with or without parameters } catch (SequentialIOException ouch) { // Print the sequential I/O exception chain in order of // appearance instead. ouch.sortAppearance().printStackTrace(); } // END SNIPPET: umount2 }
SequentialIOException exc1, exc2; exc1 = new SequentialIOException(); exc2 = new SequentialIOException(); exc1.initPredecessor(exc1); fail("A chainable exception can't be the predecessor of itself!"); } catch (IllegalArgumentException expected) { exc2.initPredecessor(exc1); fail("A chainable exception's predecessor's predecessor must be initialized!"); } catch (IllegalArgumentException expected) { exc1.initPredecessor(null); exc1.initPredecessor(null); exc1.initPredecessor(exc2); fail("Predecessor reinitialization not allowed!"); } catch (IllegalStateException expected) { exc2.initPredecessor(exc1); exc2.initPredecessor(exc1); exc2.initPredecessor(null); fail("Predecessor reinitialization not allowed!"); } catch (IllegalStateException expected) {
assertChain(indexCheck, appearance, exc); final SequentialIOException appearanceExc = exc.sortAppearance(); assertEquals(maxIndex, appearanceExc.maxIndex); assertChain(indexCheck, appearance, appearanceExc); final SequentialIOException priorityExc = exc.sortPriority(); assertNotSame(exc, priorityExc); assertEquals(maxIndex, priorityExc.maxIndex);
void umount2() { // START SNIPPET: umount2 try { TVFS.umount(); // with or without parameters } catch (FsSyncException ouch) { // Print the sequential I/O exception chain strictly in order of // ascending appearance instead. ouch.sortAppearance().printStackTrace(); } // END SNIPPET: umount2 }
@SuppressWarnings({ "unchecked", "element-type-mismatch" }) private void assertSequence(final Mapper mapper) throws X { final IOException warning = new IOException("warning"); final IOException failure = new IOException("failure"); builder.warn(warning); final SequentialIOException ex1 = builder.fail(failure); builder.check(); assertTrue(clazz.isInstance(ex1)); final SequentialIOException ex2 = mapper.map(ex1); assertTrue(clazz.isInstance(ex2)); final Set<IOException> causes = new HashSet<IOException>( Arrays.asList(warning, failure)); assertTrue(causes.remove(ex2.getCause())); assertTrue(causes.remove(ex2.getPredecessor().getCause())); assertTrue(causes.isEmpty()); assertNull(ex2.getPredecessor().getPredecessor()); }
private void assertChain( final Check c, final SequentialIOException[] expected, SequentialIOException exc) { assert c != null; for (int i = 0; i < expected.length; i++) { final SequentialIOException exp = expected[i]; assertNotNull(exp); assertNotNull(exc); assertTrue(c.equals(exp, exc)); exc = exc.getPredecessor(); } assertNull(exc); }
@Test public void testChainingExceptionWithInitializedPredecessor() { builder.warn(newCause()); builder.warn(newCause()); try { builder.check(); fail(); } catch (final SequentialIOException expected) { assert expected.isInitPredecessor(); builder.warn(newCause()); builder.warn(expected); builder.warn(newCause()); } }
void umount1() { // START SNIPPET: umount1 try { TVFS.umount(); // with or without parameters } catch (FsSyncException ouch) { // Print the sequential I/O exception chain in order of descending // priority and ascending appearance. // This is the default so you wouldn't have to call sortPriority(). ouch.sortPriority().printStackTrace(); //ouch.printStackTrace(); // equivalent } // END SNIPPET: umount1 }