private JsonNode getRootNode() { try { return rootRef.get(); } catch (LazyReference.InitializationException ie) { final Throwable cause = ie.getCause(); throw new IllegalArgumentException("Invalid JSON", (cause != null) ? cause : ie); } }
/** * Get the lazily loaded reference in a cancellable manner. If your * <code>create()</code> method throws an Exception, calls to * <code>get()</code> will throw a RuntimeException which wraps the previously * thrown exception. * * @return the object that {@link #create()} created. * @throws InitializationException if the {@link #create()} method throws an * exception. The {@link InitializationException#getCause()} will contain the * exception thrown by the {@link #create()} method * @throws InterruptedException If the calling thread is Interrupted while * waiting for another thread to create the value (if the creating thread is * interrupted while blocking on something, the {@link InterruptedException} * will be thrown as the causal exception of the * {@link InitializationException} to everybody calling this method). */ public final T getInterruptibly() throws InterruptedException { if (!sync.isDone()) { sync.run(); } try { return sync.get(); } catch (final ExecutionException e) { throw new InitializationException(e); } }
@Override public UserFormat getModule() { try { return format.get(); } catch (final InitializationException e) { format.reset(); final Throwable cause = e.getCause(); if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } if (cause instanceof Error) { throw (Error) cause; } throw e; } }
@Override protected String getJiraHome() { try { return jiraHomePathRef.get(); } catch (LazyReference.InitializationException e) { /* LazyReference.get() wraps the original exception that was thrown in * LazyReference.create() method inside LazyReference.InitializationException (see its javadoc) * We know that our create method(defined above) does not throw any checked exceptions and * it is safe to cast to RuntimeException */ throw (RuntimeException) e.getCause(); } }